Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions prqlc/prqlc/tests/integration/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ mod compileall {
let generic_sql = prqlc::compile(&prql, &options).unwrap();

// next compile with each dialect
let mut diffsnap = "".to_owned();
let mut diffs = Vec::new();
for dialect in Dialect::iter() {
if !should_run_query(dialect, &prql) {
continue;
Expand All @@ -96,13 +96,16 @@ mod compileall {
let dialect_sql = prqlc::compile(&prql, &dialect_options).unwrap();

let diff = TextDiff::from_lines(&generic_sql, &dialect_sql);
diffsnap = format!(
"{diffsnap}\n{}",
diff.unified_diff()
.context_radius(10)
.header("generic", &dialect.to_string())
);
let udiff = diff
.unified_diff()
.context_radius(10)
.header("generic", &dialect.to_string())
.to_string();
if !udiff.is_empty() {
diffs.push(udiff);
}
}
let diffsnap = diffs.join("\n");
with_settings!({ input_file => prql_path }, {
assert_snapshot!(test_name, diffsnap, &prql)
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ source: prqlc/prqlc/tests/integration/queries.rs
expression: "# mysql:skip\n# clickhouse:skip\n# glaredb:skip (the string_agg function is not supported)\nfrom tracks\nfilter genre_id == 100\nderive empty_name = name == ''\naggregate {sum track_id, concat_array name, all empty_name, any empty_name}\n"
input_file: prqlc/prqlc/tests/integration/queries/aggregation.prql
---





--- generic
+++ sqlite
@@ -1,9 +1,9 @@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ source: prqlc/prqlc/tests/integration/queries.rs
expression: "from invoices\nselect { customer_id, invoice_id, billing_country }\ntake 10..15\nappend (\n from invoices\n select { customer_id, invoice_id, billing_country }\n take 40..45\n)\nselect { billing_country, invoice_id }\n"
input_file: prqlc/prqlc/tests/integration/queries/append_select.prql
---






--- generic
+++ postgres
@@ -1,26 +1,19 @@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ source: prqlc/prqlc/tests/integration/queries.rs
expression: "from invoices\nderive total = case [total < 10 => total * 2, true => total]\nselect { customer_id, invoice_id, total }\ntake 5\nappend (\n from invoice_items\n derive unit_price = case [unit_price < 1 => unit_price * 2, true => unit_price]\n select { invoice_line_id, invoice_id, unit_price }\n take 5\n)\nselect { a = customer_id * 2, b = math.round 1 (invoice_id * total) }\n"
input_file: prqlc/prqlc/tests/integration/queries/append_select_compute.prql
---




--- generic
+++ glaredb
@@ -29,13 +29,13 @@
Expand All @@ -25,7 +21,6 @@ input_file: prqlc/prqlc/tests/integration/queries/append_select_compute.prql
FROM
table_1


--- generic
+++ postgres
@@ -1,41 +1,34 @@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ source: prqlc/prqlc/tests/integration/queries.rs
expression: "from invoices\nselect { customer_id, invoice_id, billing_country }\ntake 5\nappend (\n from employees\n select { employee_id, employee_id, country }\n take 5\n)\nappend (\n from invoice_items\n select { invoice_line_id, invoice_id, null }\n take 5\n)\nselect { billing_country, invoice_id }\n"
input_file: prqlc/prqlc/tests/integration/queries/append_select_multiple_with_null.prql
---






--- generic
+++ postgres
@@ -1,40 +1,29 @@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ source: prqlc/prqlc/tests/integration/queries.rs
expression: "from invoices\nselect {an_id = invoice_id, name = null}\ntake 2\nappend (\n from employees\n select {an_id = null, name = first_name}\n take 2\n)\n"
input_file: prqlc/prqlc/tests/integration/queries/append_select_nulls.prql
---






--- generic
+++ postgres
@@ -1,26 +1,19 @@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@ source: prqlc/prqlc/tests/integration/queries.rs
expression: "from invoices\nselect { invoice_id, billing_country }\nappend (\n from invoices\n select { invoice_id = `invoice_id` + 100, billing_country }\n)\nfilter (billing_country | text.starts_with(\"I\"))\n"
input_file: prqlc/prqlc/tests/integration/queries/append_select_simple.prql
---








--- generic
+++ sqlite
@@ -11,11 +11,11 @@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ source: prqlc/prqlc/tests/integration/queries.rs
expression: "# mssql:test\nfrom [\n { id = 1, x_int = 13, x_float = 13.0, k_int = 5, k_float = 5.0 },\n { id = 2, x_int = -13, x_float = -13.0, k_int = 5, k_float = 5.0 },\n { id = 3, x_int = 13, x_float = 13.0, k_int = -5, k_float = -5.0 },\n { id = 4, x_int = -13, x_float = -13.0, k_int = -5, k_float = -5.0 },\n]\nselect {\n id,\n\n x_int / k_int,\n x_int / k_float,\n x_float / k_int,\n x_float / k_float,\n\n q_ii = x_int // k_int,\n q_if = x_int // k_float,\n q_fi = x_float // k_int,\n q_ff = x_float // k_float,\n\n r_ii = x_int % k_int,\n r_if = x_int % k_float,\n r_fi = x_float % k_int,\n r_ff = x_float % k_float,\n\n (q_ii * k_int + r_ii | math.round 0),\n (q_if * k_float + r_if | math.round 0),\n (q_fi * k_int + r_fi | math.round 0),\n (q_ff * k_float + r_ff | math.round 0),\n}\nsort id\n"
input_file: prqlc/prqlc/tests/integration/queries/arithmetic.prql
---

--- generic
+++ clickhouse
@@ -25,42 +25,36 @@
Expand Down Expand Up @@ -120,7 +119,6 @@ input_file: prqlc/prqlc/tests/integration/queries/arithmetic.prql
ORDER BY
id


--- generic
+++ glaredb
@@ -25,42 +25,46 @@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ source: prqlc/prqlc/tests/integration/queries.rs
expression: "# mssql:test\nfrom tracks\nsort {-bytes}\nselect {\n name,\n bin = ((album_id | as REAL) * 99)\n}\ntake 20\n"
input_file: prqlc/prqlc/tests/integration/queries/cast.prql
---





--- generic
+++ mssql
@@ -1,19 +1,19 @@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ source: prqlc/prqlc/tests/integration/queries.rs
expression: "from genres\ntake 10\nfilter true\ntake 20\nfilter true\nselect d = 10\n"
input_file: prqlc/prqlc/tests/integration/queries/constants_only.prql
---






--- generic
+++ postgres
@@ -1,20 +1,18 @@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ source: prqlc/prqlc/tests/integration/queries.rs
expression: "# mssql:test\nfrom tracks\nselect {genre_id, media_type_id, album_id}\ngroup {genre_id, media_type_id} (sort {-album_id} | take 1)\nsort {-genre_id, media_type_id}\n"
input_file: prqlc/prqlc/tests/integration/queries/distinct_on.prql
---

--- generic
+++ clickhouse
@@ -1,25 +1,21 @@
Expand Down Expand Up @@ -74,10 +73,6 @@ input_file: prqlc/prqlc/tests/integration/queries/distinct_on.prql
genre_id DESC,
media_type_id





--- generic
+++ postgres
@@ -1,25 +1,21 @@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ source: prqlc/prqlc/tests/integration/queries.rs
expression: "# mssql:test\nfrom a=albums\ntake 10\njoin tracks (==album_id)\ngroup {a.album_id, a.title} (aggregate price = (sum tracks.unit_price | math.round 2))\nsort album_id\n"
input_file: prqlc/prqlc/tests/integration/queries/group_all.prql
---




--- generic
+++ glaredb
@@ -3,19 +3,22 @@
Expand Down Expand Up @@ -63,7 +59,6 @@ input_file: prqlc/prqlc/tests/integration/queries/group_all.prql
GROUP BY
table_0.album_id,


--- generic
+++ postgres
@@ -3,19 +3,22 @@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ source: prqlc/prqlc/tests/integration/queries.rs
expression: "# mssql:test\nfrom tracks\nderive d = album_id + 1\ngroup d (\n aggregate {\n n1 = (track_id | sum),\n }\n)\nsort d\ntake 10\nselect { d1 = d, n1 }\n"
input_file: prqlc/prqlc/tests/integration/queries/group_sort.prql
---





--- generic
+++ mssql
@@ -8,21 +8,21 @@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ source: prqlc/prqlc/tests/integration/queries.rs
expression: "# mssql:test\n# sqlite:skip (see https://github.com/rusqlite/rusqlite/issues/1211)\nfrom invoices\ntake 5\nselect {\n total_original = (total | math.round 2),\n total_x = (math.pi - total | math.round 2 | math.abs),\n total_floor = (math.floor total),\n total_ceil = (math.ceil total),\n total_log10 = (math.log10 total | math.round 3),\n total_log2 = (math.log 2 total | math.round 3),\n total_sqrt = (math.sqrt total | math.round 3),\n total_ln = (math.ln total | math.exp | math.round 2),\n total_cos = (math.cos total | math.acos | math.round 2),\n total_sin = (math.sin total | math.asin | math.round 2),\n total_tan = (math.tan total | math.atan | math.round 2),\n total_deg = (total | math.degrees | math.radians | math.round 2),\n total_square = (total | math.pow 2 | math.round 2),\n total_square_op = ((total ** 2) | math.round 2),\n}\n"
input_file: prqlc/prqlc/tests/integration/queries/math_module.prql
---




--- generic
+++ glaredb
@@ -1,19 +1,19 @@
Expand Down Expand Up @@ -76,7 +72,6 @@ input_file: prqlc/prqlc/tests/integration/queries/math_module.prql
+FETCH FIRST
+ 5 ROWS ONLY


--- generic
+++ postgres
@@ -1,19 +1,19 @@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ source: prqlc/prqlc/tests/integration/queries.rs
expression: "# sqlite:skip (Only works on Sqlite implementations which have the extension\n# installed\n# https://stackoverflow.com/questions/24037982/how-to-use-regexp-in-sqlite)\n\nfrom tracks\n\nfilter (name ~= \"Love\")\nfilter ((milliseconds / 1000 / 60) | in 3..4)\nsort track_id\ntake 1..15\nselect {name, composer}\n"
input_file: prqlc/prqlc/tests/integration/queries/pipelines.prql
---

--- generic
+++ clickhouse
@@ -1,20 +1,20 @@
Expand Down Expand Up @@ -56,7 +55,6 @@ input_file: prqlc/prqlc/tests/integration/queries/pipelines.prql
FROM
table_0


--- generic
+++ glaredb
@@ -1,20 +1,20 @@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ source: prqlc/prqlc/tests/integration/queries.rs
expression: "# sqlite:skip\n# postgres:skip\n# mysql:skip\nfrom (read_csv \"data_file_root/media_types.csv\")\nappend (read_json \"data_file_root/media_types.json\")\nsort media_type_id\n"
input_file: prqlc/prqlc/tests/integration/queries/read_csv.prql
---

--- generic
+++ clickhouse
@@ -1,24 +1,24 @@
Expand Down Expand Up @@ -64,7 +63,6 @@ input_file: prqlc/prqlc/tests/integration/queries/read_csv.prql
ORDER BY
media_type_id


--- generic
+++ glaredb
@@ -1,15 +1,15 @@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ source: prqlc/prqlc/tests/integration/queries.rs
expression: "# mssql:test\nlet distinct = rel -> (from t = _param.rel | group {t.*} (take 1))\n\nfrom_text format:json '{ \"columns\": [\"a\"], \"data\": [[1], [2], [2], [3]] }'\ndistinct\nremove (from_text format:json '{ \"columns\": [\"a\"], \"data\": [[1], [2]] }')\nsort a\n"
input_file: prqlc/prqlc/tests/integration/queries/set_ops_remove.prql
---





--- generic
+++ mssql
@@ -21,21 +21,20 @@
Expand All @@ -33,9 +28,6 @@ input_file: prqlc/prqlc/tests/integration/queries/set_ops_remove.prql
table_2
ORDER BY




--- generic
+++ sqlite
@@ -21,21 +21,20 @@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ source: prqlc/prqlc/tests/integration/queries.rs
expression: "from albums\nselect { AA=album_id, artist_id }\nsort AA\nfilter AA >= 25\njoin artists (==artist_id)\n"
input_file: prqlc/prqlc/tests/integration/queries/sort_2.prql
---

--- generic
+++ clickhouse
@@ -1,25 +1,25 @@
Expand Down Expand Up @@ -38,9 +37,6 @@ input_file: prqlc/prqlc/tests/integration/queries/sort_2.prql
- table_0."AA"
+ table_0.`AA`




--- generic
+++ mysql
@@ -1,25 +1,25 @@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ source: prqlc/prqlc/tests/integration/queries.rs
expression: "from [{track_id=0, album_id=1, genre_id=2}]\nselect { AA=track_id, album_id, genre_id }\nsort AA\njoin side:left [{album_id=1, album_title=\"Songs\"}] (==album_id)\nselect { AA, AT = album_title ?? \"unknown\", genre_id }\nfilter AA < 25\njoin side:left [{genre_id=1, genre_title=\"Rock\"}] (==genre_id)\nselect { AA, AT, GT = genre_title ?? \"unknown\" }\n"
input_file: prqlc/prqlc/tests/integration/queries/sort_3.prql
---

--- generic
+++ clickhouse
@@ -1,52 +1,52 @@
Expand Down Expand Up @@ -70,9 +69,6 @@ input_file: prqlc/prqlc/tests/integration/queries/sort_3.prql
- table_3."AA"
+ table_3.`AA`




--- generic
+++ mysql
@@ -1,52 +1,52 @@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ source: prqlc/prqlc/tests/integration/queries.rs
expression: "# glaredb:skip (May be a bag of String type conversion for Postgres Client)\n# mssql:test\nfrom tracks\nsort milliseconds\nselect display = case [\n composer != null => composer,\n genre_id < 17 => 'no composer',\n true => f'unknown composer'\n]\ntake 10\n"
input_file: prqlc/prqlc/tests/integration/queries/switch.prql
---




--- generic
+++ mssql
@@ -2,20 +2,20 @@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ source: prqlc/prqlc/tests/integration/queries.rs
expression: "# mssql:test\nfrom tracks\nsort {+track_id}\ntake 3..5\n"
input_file: prqlc/prqlc/tests/integration/queries/take.prql
---





--- generic
+++ mssql
@@ -1,8 +1,8 @@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ source: prqlc/prqlc/tests/integration/queries.rs
expression: "# mssql:test\n# glaredb:skip — TODO: started raising an error on 2024-05-20; see `window.prql`\n# for more details\nfrom albums\nselect {\n title,\n title_and_spaces = f\" {title} \",\n low = (title | text.lower),\n up = (title | text.upper),\n ltrimmed = (title | text.ltrim),\n rtrimmed = (title | text.rtrim),\n trimmed = (title | text.trim),\n len = (title | text.length),\n subs = (title | text.extract 2 5),\n replace = (title | text.replace \"al\" \"PIKA\"),\n}\nsort {title}\nfilter (title | text.starts_with \"Black\") || (title | text.contains \"Sabbath\") || (title | text.ends_with \"os\")\n"
input_file: prqlc/prqlc/tests/integration/queries/text_module.prql
---

--- generic
+++ clickhouse
@@ -2,33 +2,33 @@
Expand Down Expand Up @@ -68,7 +67,6 @@ input_file: prqlc/prqlc/tests/integration/queries/text_module.prql
low,
up,


--- generic
+++ mssql
@@ -1,20 +1,20 @@
Expand Down
Loading