From a2611c60d5e9844c3f60a20e4d5f1962a0b296b4 Mon Sep 17 00:00:00 2001 From: Jelenkee Date: Sat, 18 Mar 2023 10:13:51 +0100 Subject: [PATCH 01/29] -added docker compose -added test skeleton --- .../integration-vendors/docker-compose.yml | 41 +++++ .../tests/integration-vendors/main.rs | 159 ++++++++++++++++++ 2 files changed, 200 insertions(+) create mode 100644 prql-compiler/tests/integration-vendors/docker-compose.yml create mode 100644 prql-compiler/tests/integration-vendors/main.rs diff --git a/prql-compiler/tests/integration-vendors/docker-compose.yml b/prql-compiler/tests/integration-vendors/docker-compose.yml new file mode 100644 index 000000000000..cb1d3354f26f --- /dev/null +++ b/prql-compiler/tests/integration-vendors/docker-compose.yml @@ -0,0 +1,41 @@ +version: '3' + +services: + postgres: + image: 'postgres:15-alpine' + ports: + - '5432:5432' + environment: + POSTGRES_DB: dummy + POSTGRES_USER: root + POSTGRES_PASSWORD: root + mysql: + image: 'mysql:8' + ports: + - '3306:3306' + environment: + MYSQL_DATABASE: dummy + MYSQL_ROOT_PASSWORD: root + db2: + image: 'icr.io/db2_community/db2' + ports: + - '50000:50000' + environment: + LICENSE: accept + DBNAME: dummy + DB2INSTANCE: db2 + DB2INST1_PASSWORD: root + BLU: false + TO_CREATE_SAMPLEDB: false + REPODB: false + IS_OSXFS: false + mssql: + image: 'mcr.microsoft.com/mssql/server:2022-latest' + ports: + - '1433:1433' + environment: + ACCEPT_EULA: Y + MSSQL_PID: Developer + MSSQL_SA_PASSWORD: Wordpass123## + + diff --git a/prql-compiler/tests/integration-vendors/main.rs b/prql-compiler/tests/integration-vendors/main.rs new file mode 100644 index 000000000000..0acc5f1be208 --- /dev/null +++ b/prql-compiler/tests/integration-vendors/main.rs @@ -0,0 +1,159 @@ +#[cfg(test)] +mod tests { + use std::time::SystemTime; + + use chrono::{DateTime, Utc}; + use insta::{assert_snapshot, glob}; + use pg_bigdecimal::PgNumeric; + use postgres::NoTls; + use postgres::types::{Type}; + + use prql_compiler::{sql::Dialect}; + + type Row = Vec; + + const TEST_CASES: Vec<(&str, Vec)> = vec![]; + + #[test] + fn test_vendor() { + let mut pg = PostgresConnection(postgres::Client::connect("host=localhost user=root password=root dbname=dummy", NoTls).unwrap()); + let mut duck = DuckDBConnection(duckdb::Connection::open_in_memory().unwrap()); + let mut sqlite = SQLiteConnection(rusqlite::Connection::open_in_memory().unwrap()); + let mut connections: Vec<&mut dyn DBConnection> = vec![]; + connections.push(&mut pg); + connections.push(&mut duck); + connections.push(&mut sqlite); + + for con in connections { + let e = con.run_query("select 1=1 bo,1+1 i2,200000004400+1 i4,'tte' te,0.1+0.2 f;"); + println!("{:?}", e); + } + panic!("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ {:?}", 6); + } + + trait DBConnection { + fn run_query(&mut self, sql: &str) -> Vec; + + fn get_dialect(&self) -> Dialect; + } + + struct DuckDBConnection(duckdb::Connection); + + struct SQLiteConnection(rusqlite::Connection); + + struct PostgresConnection(postgres::Client); + + impl DBConnection for DuckDBConnection { + fn run_query(&mut self, sql: &str) -> Vec { + let mut statement = self.0.prepare(sql).unwrap(); + let mut rows = statement.query([]).unwrap(); + let mut vec = vec![]; + while let Ok(Some(row)) = rows.next() { + let mut columns = vec![]; + for i in 0.. { + let v_ref = match row.get_ref(i) { + Ok(v) => { v } + Err(_) => { break; } + }; + let value = match v_ref { + duckdb::types::ValueRef::Null => { "".to_string() } + duckdb::types::ValueRef::Boolean(v) => { v.to_string() } + duckdb::types::ValueRef::TinyInt(v) => { v.to_string() } + duckdb::types::ValueRef::SmallInt(v) => { v.to_string() } + duckdb::types::ValueRef::Int(v) => { v.to_string() } + duckdb::types::ValueRef::BigInt(v) => { v.to_string() } + duckdb::types::ValueRef::HugeInt(v) => { v.to_string() } + duckdb::types::ValueRef::UTinyInt(v) => { v.to_string() } + duckdb::types::ValueRef::USmallInt(v) => { v.to_string() } + duckdb::types::ValueRef::UInt(v) => { v.to_string() } + duckdb::types::ValueRef::UBigInt(v) => { v.to_string() } + duckdb::types::ValueRef::Float(v) => { v.to_string() } + duckdb::types::ValueRef::Double(v) => { v.to_string() } + duckdb::types::ValueRef::Decimal(v) => { v.to_string() } + duckdb::types::ValueRef::Timestamp(u, v) => { format!("{} {:?}", v, u) } + duckdb::types::ValueRef::Text(v) => { String::from_utf8(v.to_vec()).unwrap() } + duckdb::types::ValueRef::Blob(v) => { String::from_utf8(v.to_vec()).unwrap() } + duckdb::types::ValueRef::Date32(v) => { v.to_string() } + duckdb::types::ValueRef::Time64(u, v) => { format!("{} {:?}", v, u) } + }; + columns.push(value); + } + vec.push(columns) + } + vec + } + + fn get_dialect(&self) -> Dialect { + Dialect::DuckDb + } + + } + + impl DBConnection for SQLiteConnection { + fn run_query(&mut self, sql: &str) -> Vec { + let mut statement = self.0.prepare(sql).unwrap(); + let mut rows = statement.query([]).unwrap(); + let mut vec = vec![]; + while let Ok(Some(row)) = rows.next() { + let mut columns = vec![]; + for i in 0.. { + let v_ref = match row.get_ref(i) { + Ok(v) => { v } + Err(_) => { break; } + }; + let value = match v_ref { + rusqlite::types::ValueRef::Null => { "".to_string() } + rusqlite::types::ValueRef::Integer(v) => { v.to_string() } + rusqlite::types::ValueRef::Real(v) => { v.to_string() } + rusqlite::types::ValueRef::Text(v) => { String::from_utf8(v.to_vec()).unwrap() } + rusqlite::types::ValueRef::Blob(v) => { String::from_utf8(v.to_vec()).unwrap() } + }; + columns.push(value); + } + vec.push(columns); + } + vec + } + + fn get_dialect(&self) -> Dialect { + Dialect::SQLite + } + + } + + impl DBConnection for PostgresConnection { + fn run_query(&mut self, sql: &str) -> Vec { + let rows = self.0.query(sql, &[]).unwrap(); + let mut vec = vec![]; + for row in rows.into_iter() { + let mut columns = vec![]; + for i in 0..row.len() { + let col = &(*row.columns())[i]; + let value = match col.type_() { + &Type::BOOL => (row.get::(i)).to_string(), + &Type::INT4 => (row.get::(i)).to_string(), + &Type::INT8 => (row.get::(i)).to_string(), + &Type::TEXT | &Type::VARCHAR => row.get::(i), + &Type::JSON | &Type::JSONB => row.get::(i), + &Type::FLOAT4 => (row.get::(i)).to_string(), + &Type::FLOAT8 => (row.get::(i)).to_string(), + &Type::NUMERIC => row.get::(i).n.unwrap().to_string(), + &Type::TIMESTAMPTZ | &Type::TIMESTAMP => { + let time = row.get::(i); + let date_time: DateTime = time.into(); + date_time.to_rfc3339() + } + t => unimplemented!("postgres type {t}"), + }; + columns.push(value); + } + vec.push(columns); + } + vec + } + + fn get_dialect(&self) -> Dialect { + Dialect::PostgreSql + } + } +} \ No newline at end of file From a60b8350172c586392098ca32719cb1872edbe18 Mon Sep 17 00:00:00 2001 From: Jelenkee Date: Sat, 18 Mar 2023 10:23:24 +0100 Subject: [PATCH 02/29] -added dependencies --- Cargo.lock | 29 +++++++++++++++++++++++++++-- prql-compiler/Cargo.toml | 1 + 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 41adf708b529..0a5cb5fe5604 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -292,6 +292,17 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]] +name = "bigdecimal" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6aaf33151a6429fe9211d1b276eafdf70cdff28b071e76c0b0e1503221ea3744" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -1935,6 +1946,19 @@ dependencies = [ "sha2", ] +[[package]] +name = "pg_bigdecimal" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9855a94c74528af62c0ea236577af5e601263c1c404a6ac939b07c97c8e0216" +dependencies = [ + "bigdecimal", + "byteorder", + "bytes", + "num", + "postgres", +] + [[package]] name = "phf" version = "0.11.1" @@ -2134,6 +2158,7 @@ dependencies = [ "lazy_static", "log", "once_cell", + "pg_bigdecimal", "postgres", "pretty_assertions", "regex", @@ -2478,9 +2503,9 @@ dependencies = [ [[package]] name = "rust_decimal" -version = "1.28.1" +version = "1.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13cf35f7140155d02ba4ec3294373d513a3c7baa8364c162b030e33c61520a8" +checksum = "2b1b21b8760b0ef8ae5b43d40913ff711a2053cb7ff892a34facff7a6365375a" dependencies = [ "arrayvec", "borsh", diff --git a/prql-compiler/Cargo.toml b/prql-compiler/Cargo.toml index 697851c12f97..81a0d2211a02 100644 --- a/prql-compiler/Cargo.toml +++ b/prql-compiler/Cargo.toml @@ -47,6 +47,7 @@ criterion = "0.4.0" postgres = "0.19.3" pretty_assertions = "1.3.0" rusqlite = {version = "0.28.0", features = ["bundled", "csvtab"]} +pg_bigdecimal = "0.1" # Re-enable on windows when duckdb supports it # https://github.com/wangfenjin/duckdb-rs/issues/62 From 131f98bf0edef2ec41d734d306e0191df12a8648 Mon Sep 17 00:00:00 2001 From: Jelenkee Date: Sat, 18 Mar 2023 20:22:24 +0100 Subject: [PATCH 03/29] -added real test cases --- Cargo.lock | 559 +++++++++++++++++- prql-compiler/Cargo.toml | 1 + .../tests/integration-vendors/main.rs | 176 ++++-- .../tests/integration-vendors/setup.sql | 52 ++ 4 files changed, 742 insertions(+), 46 deletions(-) create mode 100644 prql-compiler/tests/integration-vendors/setup.sql diff --git a/Cargo.lock b/Cargo.lock index 0a5cb5fe5604..66bb991a136d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -303,12 +303,43 @@ dependencies = [ "num-traits", ] +[[package]] +name = "bindgen" +version = "0.59.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "peeking_take_while", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", +] + [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + [[package]] name = "block-buffer" version = "0.10.3" @@ -375,6 +406,12 @@ dependencies = [ "serde", ] +[[package]] +name = "bufstream" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40e38929add23cdf8a366df9b0e088953150724bcbe5fc330b0d8eb3b328eec8" + [[package]] name = "bumpalo" version = "3.12.0" @@ -435,6 +472,15 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -451,7 +497,7 @@ dependencies = [ "js-sys", "num-integer", "num-traits", - "time", + "time 0.1.45", "wasm-bindgen", "winapi", ] @@ -493,6 +539,17 @@ dependencies = [ "half 1.8.2", ] +[[package]] +name = "clang-sys" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ed9a53e5d4d9c573ae844bfac6872b159cb1d1585a83b29e7a64b7eef7332a" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "clap" version = "3.2.23" @@ -572,6 +629,15 @@ dependencies = [ "windows-sys 0.42.0", ] +[[package]] +name = "cmake" +version = "0.1.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db34956e100b30725f2eb215f90d4871051239535632f84fea3bc92722c66b7c" +dependencies = [ + "cc", +] + [[package]] name = "codespan-reporting" version = "0.11.1" @@ -681,6 +747,16 @@ dependencies = [ "tiny-keccak", ] +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.3" @@ -696,6 +772,15 @@ dependencies = [ "libc", ] +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + [[package]] name = "criterion" version = "0.4.0" @@ -732,6 +817,20 @@ dependencies = [ "itertools", ] +[[package]] +name = "crossbeam" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2801af0d36612ae591caa9568261fddce32ce6e08a7275ea334a06a4ad021a2c" +dependencies = [ + "cfg-if", + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-epoch", + "crossbeam-queue", + "crossbeam-utils", +] + [[package]] name = "crossbeam-channel" version = "0.5.6" @@ -766,6 +865,16 @@ dependencies = [ "scopeguard", ] +[[package]] +name = "crossbeam-queue" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + [[package]] name = "crossbeam-utils" version = "0.8.14" @@ -866,6 +975,17 @@ dependencies = [ "syn", ] +[[package]] +name = "derive_utils" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7590f99468735a318c254ca9158d0c065aa9b5312896b5a043b5e39bc96f5fa2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "diff" version = "0.1.13" @@ -1003,12 +1123,38 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "flate2" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" +dependencies = [ + "crc32fast", + "libz-sys", + "miniz_oxide", +] + [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.1.0" @@ -1018,6 +1164,70 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "frunk" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89c703bf50009f383a0873845357cc400a95fc535f836feddfe015d7df6e1e0" +dependencies = [ + "frunk_core", + "frunk_derives", + "frunk_proc_macros", +] + +[[package]] +name = "frunk_core" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a446d01a558301dca28ef43222864a9fa2bd9a2e71370f769d5d5d5ec9f3537" + +[[package]] +name = "frunk_derives" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b83164912bb4c97cfe0772913c7af7387ee2e00cb6d4636fb65a35b3d0c8f173" +dependencies = [ + "frunk_proc_macro_helpers", + "quote", + "syn", +] + +[[package]] +name = "frunk_proc_macro_helpers" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "015425591bbeb0f5b8a75593340f1789af428e9f887a4f1e36c0c471f067ef50" +dependencies = [ + "frunk_core", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "frunk_proc_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea01524f285deab48affffb342b97f186e657b119c3f1821ac531780e0fbfae0" +dependencies = [ + "frunk_core", + "frunk_proc_macros_impl", + "proc-macro-hack", +] + +[[package]] +name = "frunk_proc_macros_impl" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a802d974cc18ee7fe1a7868fc9ce31086294fd96ba62f8da64ecb44e92a2653" +dependencies = [ + "frunk_core", + "frunk_proc_macro_helpers", + "proc-macro-hack", + "quote", + "syn", +] + [[package]] name = "fsevent-sys" version = "4.1.0" @@ -1027,6 +1237,12 @@ dependencies = [ "libc", ] +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + [[package]] name = "futures-channel" version = "0.3.26" @@ -1117,6 +1333,12 @@ version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "globset" version = "0.4.10" @@ -1333,6 +1555,17 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "io-enum" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4b0d47a958cb166282b4dc4840a35783e861c2b39080af846e6481ebe145eee" +dependencies = [ + "derive_utils", + "quote", + "syn", +] + [[package]] name = "io-lifetimes" version = "1.0.5" @@ -1434,6 +1667,21 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "lexical" +version = "6.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7aefb36fd43fef7003334742cbf77b243fcd36418a1d1bdd480d613a67968f6" +dependencies = [ + "lexical-core", +] + [[package]] name = "lexical-core" version = "0.8.5" @@ -1515,6 +1763,16 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "libloading" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +dependencies = [ + "cfg-if", + "winapi", +] + [[package]] name = "libm" version = "0.2.6" @@ -1532,6 +1790,17 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "libz-sys" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + [[package]] name = "link-cplusplus" version = "1.0.8" @@ -1572,6 +1841,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "lru" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6e8aaa3f231bb4bd57b84b2d5dc3ae7f350265df8aa96492e0bc394a1571909" +dependencies = [ + "hashbrown 0.12.3", +] + [[package]] name = "malloc_buf" version = "0.0.6" @@ -1697,6 +1975,96 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "mysql" +version = "23.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f11339ca5c251941805d51362a07823605a80586ced92914ab7de84fba813f" +dependencies = [ + "bufstream", + "bytes", + "crossbeam", + "flate2", + "io-enum", + "libc", + "lru", + "mysql_common", + "named_pipe", + "native-tls", + "once_cell", + "pem", + "percent-encoding", + "serde", + "serde_json", + "socket2", + "twox-hash", + "url", +] + +[[package]] +name = "mysql_common" +version = "0.29.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9006c95034ccf7b903d955f210469119f6c3477fc9c9e7a7845ce38a3e665c2a" +dependencies = [ + "base64", + "bigdecimal", + "bindgen", + "bitflags", + "bitvec", + "byteorder", + "bytes", + "cc", + "cmake", + "crc32fast", + "flate2", + "frunk", + "lazy_static", + "lexical", + "num-bigint", + "num-traits", + "rand", + "regex", + "rust_decimal", + "saturating", + "serde", + "serde_json", + "sha1", + "sha2", + "smallvec", + "subprocess", + "thiserror", + "time 0.3.20", + "uuid", +] + +[[package]] +name = "named_pipe" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad9c443cce91fc3e12f017290db75dde490d685cdaaf508d7159d7cf41f0eb2b" +dependencies = [ + "winapi", +] + +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "nom" version = "7.1.3" @@ -1852,6 +2220,51 @@ dependencies = [ "winapi", ] +[[package]] +name = "openssl" +version = "0.10.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd2523381e46256e40930512c7fd25562b9eae4812cb52078f155e87217c9d1e" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "176be2629957c157240f68f61f2d0053ad3a4ecfdd9ebf1e6521d18d9635cf67" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "os_str_bytes" version = "6.4.1" @@ -1896,6 +2309,21 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + +[[package]] +name = "pem" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" +dependencies = [ + "base64", +] + [[package]] name = "percent-encoding" version = "2.2.0" @@ -2157,6 +2585,7 @@ dependencies = [ "itertools", "lazy_static", "log", + "mysql", "once_cell", "pg_bigdecimal", "postgres", @@ -2359,6 +2788,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + [[package]] name = "rand" version = "0.8.5" @@ -2525,6 +2960,12 @@ version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustix" version = "0.36.8" @@ -2593,6 +3034,21 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "saturating" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ece8e78b2f38ec51c51f5d475df0a7187ba5111b2a28bdc761ee05b075d40a71" + +[[package]] +name = "schannel" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" +dependencies = [ + "windows-sys 0.42.0", +] + [[package]] name = "scoped-tls" version = "1.0.1" @@ -2617,6 +3073,29 @@ version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" +[[package]] +name = "security-framework" +version = "2.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "1.0.16" @@ -2670,6 +3149,17 @@ dependencies = [ "unsafe-libyaml", ] +[[package]] +name = "sha1" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sha2" version = "0.10.6" @@ -2811,6 +3301,16 @@ dependencies = [ "syn", ] +[[package]] +name = "subprocess" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c2e86926081dda636c546d8c5e641661049d7562a68f5488be4a1f7f66f6086" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "subtle" version = "2.4.1" @@ -2828,6 +3328,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + [[package]] name = "target-lexicon" version = "0.12.6" @@ -2914,6 +3420,31 @@ dependencies = [ "winapi", ] +[[package]] +name = "time" +version = "0.3.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" +dependencies = [ + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" + +[[package]] +name = "time-macros" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" +dependencies = [ + "time-core", +] + [[package]] name = "tiny-keccak" version = "2.0.2" @@ -3075,6 +3606,17 @@ dependencies = [ "windows", ] +[[package]] +name = "twox-hash" +version = "1.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" +dependencies = [ + "cfg-if", + "rand", + "static_assertions", +] + [[package]] name = "typenum" version = "1.16.0" @@ -3161,6 +3703,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "uuid" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1674845326ee10d37ca60470760d4288a6f80f304007d92e5c53bab78c9cfd79" + [[package]] name = "valuable" version = "0.1.0" @@ -3429,6 +3977,15 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + [[package]] name = "yaml-rust" version = "0.4.5" diff --git a/prql-compiler/Cargo.toml b/prql-compiler/Cargo.toml index 81a0d2211a02..6b50a9d3f420 100644 --- a/prql-compiler/Cargo.toml +++ b/prql-compiler/Cargo.toml @@ -45,6 +45,7 @@ insta = {version = "1.28", features = ["colors", "glob", "yaml"]} chrono = {version = "0.4", features = [], default-features = false} criterion = "0.4.0" postgres = "0.19.3" +mysql = "23" pretty_assertions = "1.3.0" rusqlite = {version = "0.28.0", features = ["bundled", "csvtab"]} pg_bigdecimal = "0.1" diff --git a/prql-compiler/tests/integration-vendors/main.rs b/prql-compiler/tests/integration-vendors/main.rs index 0acc5f1be208..a0105fa0228e 100644 --- a/prql-compiler/tests/integration-vendors/main.rs +++ b/prql-compiler/tests/integration-vendors/main.rs @@ -3,32 +3,74 @@ mod tests { use std::time::SystemTime; use chrono::{DateTime, Utc}; - use insta::{assert_snapshot, glob}; + use mysql::prelude::Queryable; + use mysql::Value; use pg_bigdecimal::PgNumeric; + use postgres::types::Type; use postgres::NoTls; - use postgres::types::{Type}; - use prql_compiler::{sql::Dialect}; + use prql_compiler::sql::Dialect; + use prql_compiler::Options; + use prql_compiler::Target::Sql; type Row = Vec; - const TEST_CASES: Vec<(&str, Vec)> = vec![]; - #[test] fn test_vendor() { - let mut pg = PostgresConnection(postgres::Client::connect("host=localhost user=root password=root dbname=dummy", NoTls).unwrap()); + let test_cases: Vec<(&str, Vec)> = vec![( + "from c=customers + join ca=cars [ca.customer==c.id] + filter ca.name=='Bugatti' + select c.name", + vec![vec!["Tony Stark".to_string()]], + )]; + let mut duck = DuckDBConnection(duckdb::Connection::open_in_memory().unwrap()); let mut sqlite = SQLiteConnection(rusqlite::Connection::open_in_memory().unwrap()); - let mut connections: Vec<&mut dyn DBConnection> = vec![]; - connections.push(&mut pg); - connections.push(&mut duck); - connections.push(&mut sqlite); + let mut pg = PostgresConnection( + postgres::Client::connect("host=localhost user=root password=root dbname=dummy", NoTls) + .unwrap() + ); + let mut my = + MysqlConnection(mysql::Pool::new("mysql://root:root@localhost:3306/dummy").unwrap()); + let connections: Vec<&mut dyn DBConnection> = + vec![&mut duck, &mut sqlite, &mut pg, &mut my]; for con in connections { - let e = con.run_query("select 1=1 bo,1+1 i2,200000004400+1 i4,'tte' te,0.1+0.2 f;"); - println!("{:?}", e); + let setup = include_str!("setup.sql"); + setup + .split(";") + .map(|s| s.trim()) + .filter(|s| !s.is_empty()) + .for_each(|s| { + con.run_query(s); + }); + + for (prql, expected_rows) in test_cases.iter() { + let options = Options::default().with_target(Sql(Some(con.get_dialect()))); + let sql = prql_compiler::compile(prql, &options).unwrap(); + let mut actual_rows = con.run_query(sql.as_str()); + replace_booleans(&mut actual_rows); + assert_eq!( + *expected_rows, + actual_rows, + "Rows do not match for {}", + con.get_dialect() + ); + } + } + } + + fn replace_booleans(rows: &mut Vec) { + for row in rows { + for col in row { + if col == &"true" { + *col = "1".to_string(); + } else if col == &"false" { + *col = "0".to_string(); + } + } } - panic!("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ {:?}", 6); } trait DBConnection { @@ -43,6 +85,8 @@ mod tests { struct PostgresConnection(postgres::Client); + struct MysqlConnection(mysql::Pool); + impl DBConnection for DuckDBConnection { fn run_query(&mut self, sql: &str) -> Vec { let mut statement = self.0.prepare(sql).unwrap(); @@ -52,29 +96,31 @@ mod tests { let mut columns = vec![]; for i in 0.. { let v_ref = match row.get_ref(i) { - Ok(v) => { v } - Err(_) => { break; } + Ok(v) => v, + Err(_) => { + break; + } }; let value = match v_ref { - duckdb::types::ValueRef::Null => { "".to_string() } - duckdb::types::ValueRef::Boolean(v) => { v.to_string() } - duckdb::types::ValueRef::TinyInt(v) => { v.to_string() } - duckdb::types::ValueRef::SmallInt(v) => { v.to_string() } - duckdb::types::ValueRef::Int(v) => { v.to_string() } - duckdb::types::ValueRef::BigInt(v) => { v.to_string() } - duckdb::types::ValueRef::HugeInt(v) => { v.to_string() } - duckdb::types::ValueRef::UTinyInt(v) => { v.to_string() } - duckdb::types::ValueRef::USmallInt(v) => { v.to_string() } - duckdb::types::ValueRef::UInt(v) => { v.to_string() } - duckdb::types::ValueRef::UBigInt(v) => { v.to_string() } - duckdb::types::ValueRef::Float(v) => { v.to_string() } - duckdb::types::ValueRef::Double(v) => { v.to_string() } - duckdb::types::ValueRef::Decimal(v) => { v.to_string() } - duckdb::types::ValueRef::Timestamp(u, v) => { format!("{} {:?}", v, u) } - duckdb::types::ValueRef::Text(v) => { String::from_utf8(v.to_vec()).unwrap() } - duckdb::types::ValueRef::Blob(v) => { String::from_utf8(v.to_vec()).unwrap() } - duckdb::types::ValueRef::Date32(v) => { v.to_string() } - duckdb::types::ValueRef::Time64(u, v) => { format!("{} {:?}", v, u) } + duckdb::types::ValueRef::Null => "".to_string(), + duckdb::types::ValueRef::Boolean(v) => v.to_string(), + duckdb::types::ValueRef::TinyInt(v) => v.to_string(), + duckdb::types::ValueRef::SmallInt(v) => v.to_string(), + duckdb::types::ValueRef::Int(v) => v.to_string(), + duckdb::types::ValueRef::BigInt(v) => v.to_string(), + duckdb::types::ValueRef::HugeInt(v) => v.to_string(), + duckdb::types::ValueRef::UTinyInt(v) => v.to_string(), + duckdb::types::ValueRef::USmallInt(v) => v.to_string(), + duckdb::types::ValueRef::UInt(v) => v.to_string(), + duckdb::types::ValueRef::UBigInt(v) => v.to_string(), + duckdb::types::ValueRef::Float(v) => v.to_string(), + duckdb::types::ValueRef::Double(v) => v.to_string(), + duckdb::types::ValueRef::Decimal(v) => v.to_string(), + duckdb::types::ValueRef::Timestamp(u, v) => format!("{} {:?}", v, u), + duckdb::types::ValueRef::Text(v) => String::from_utf8(v.to_vec()).unwrap(), + duckdb::types::ValueRef::Blob(_) => "BLOB".to_string(), + duckdb::types::ValueRef::Date32(v) => v.to_string(), + duckdb::types::ValueRef::Time64(u, v) => format!("{} {:?}", v, u), }; columns.push(value); } @@ -86,7 +132,6 @@ mod tests { fn get_dialect(&self) -> Dialect { Dialect::DuckDb } - } impl DBConnection for SQLiteConnection { @@ -98,15 +143,19 @@ mod tests { let mut columns = vec![]; for i in 0.. { let v_ref = match row.get_ref(i) { - Ok(v) => { v } - Err(_) => { break; } + Ok(v) => v, + Err(_) => { + break; + } }; let value = match v_ref { - rusqlite::types::ValueRef::Null => { "".to_string() } - rusqlite::types::ValueRef::Integer(v) => { v.to_string() } - rusqlite::types::ValueRef::Real(v) => { v.to_string() } - rusqlite::types::ValueRef::Text(v) => { String::from_utf8(v.to_vec()).unwrap() } - rusqlite::types::ValueRef::Blob(v) => { String::from_utf8(v.to_vec()).unwrap() } + rusqlite::types::ValueRef::Null => "".to_string(), + rusqlite::types::ValueRef::Integer(v) => v.to_string(), + rusqlite::types::ValueRef::Real(v) => v.to_string(), + rusqlite::types::ValueRef::Text(v) => { + String::from_utf8(v.to_vec()).unwrap() + } + rusqlite::types::ValueRef::Blob(_) => "BLOB".to_string(), }; columns.push(value); } @@ -118,7 +167,6 @@ mod tests { fn get_dialect(&self) -> Dialect { Dialect::SQLite } - } impl DBConnection for PostgresConnection { @@ -133,8 +181,14 @@ mod tests { &Type::BOOL => (row.get::(i)).to_string(), &Type::INT4 => (row.get::(i)).to_string(), &Type::INT8 => (row.get::(i)).to_string(), - &Type::TEXT | &Type::VARCHAR => row.get::(i), - &Type::JSON | &Type::JSONB => row.get::(i), + &Type::TEXT => { + match row.try_get::(i) { + Ok(v) => v, + // handle null + Err(_) => "".to_string(), + } + } + &Type::VARCHAR | &Type::JSON | &Type::JSONB => row.get::(i), &Type::FLOAT4 => (row.get::(i)).to_string(), &Type::FLOAT8 => (row.get::(i)).to_string(), &Type::NUMERIC => row.get::(i).n.unwrap().to_string(), @@ -156,4 +210,36 @@ mod tests { Dialect::PostgreSql } } + + impl DBConnection for MysqlConnection { + fn run_query(&mut self, sql: &str) -> Vec { + let mut conn = self.0.get_conn().unwrap(); + let rows: Vec = conn.query(sql).unwrap(); + let mut vec = vec![]; + for row in rows.into_iter() { + let mut columns = vec![]; + for v in row.unwrap() { + let value = match v { + Value::NULL => "".to_string(), + Value::Bytes(v) => + String::from_utf8(v).unwrap_or("BLOB".to_string()), + + Value::Int(v) => v.to_string(), + Value::UInt(v) => v.to_string(), + Value::Float(v) => v.to_string(), + Value::Double(v) => v.to_string(), + Value::Date(_, _, _, _, _, _, _) => todo!(), + Value::Time(_, _, _, _, _, _) => todo!() + }; + columns.push(value); + } + vec.push(columns); + } + vec + } + + fn get_dialect(&self) -> Dialect { + Dialect::MySql + } + } } \ No newline at end of file diff --git a/prql-compiler/tests/integration-vendors/setup.sql b/prql-compiler/tests/integration-vendors/setup.sql new file mode 100644 index 000000000000..53583a84af47 --- /dev/null +++ b/prql-compiler/tests/integration-vendors/setup.sql @@ -0,0 +1,52 @@ +DROP TABLE IF EXISTS cars; + + +DROP TABLE IF EXISTS customers; + + +CREATE TABLE customers +( + id integer NOT NULL, + name varchar(255) NOT NULL, + rich boolean NOT NULL, + PRIMARY KEY (id) +); + + +CREATE TABLE cars +( + id integer NOT NULL, + customer integer NOT NULL, + name varchar(255), + PRIMARY KEY (id), + CONSTRAINT c + FOREIGN KEY (customer) + REFERENCES customers (id) +); + + +INSERT INTO customers +( + id, + name, + rich +) +VALUES +(0, 'Tony Stark', TRUE), +(1, 'Bruce Wayne', TRUE), +(2, 'Wade Wilson', FALSE); + + +INSERT INTO cars +( + id, + customer, + name +) +VALUES +(0, 1, 'Mercedes'), +(1, 1, 'Porsche'), +(2, 0, 'Bugatti'), +(3, 0, 'Ferrari'), +(4, 0, 'Lamborghini'), +(5, 2, 'Toyota'); \ No newline at end of file From e183c69fe195cb9b773e81febd19490eee8bc72b Mon Sep 17 00:00:00 2001 From: Jelenkee Date: Sat, 18 Mar 2023 22:54:39 +0100 Subject: [PATCH 04/29] -added mssql --- Cargo.lock | 306 +++++++++++++++++- prql-compiler/Cargo.toml | 3 + .../tests/integration-vendors/main.rs | 111 ++++++- 3 files changed, 389 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 66bb991a136d..2d97544cd908 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,7 +23,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom", + "getrandom 0.2.8", "once_cell", "version_check", ] @@ -36,7 +36,7 @@ checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if", "const-random", - "getrandom", + "getrandom 0.2.8", "once_cell", "version_check", ] @@ -243,6 +243,18 @@ dependencies = [ "regex-syntax", ] +[[package]] +name = "async-native-tls" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d57d4cec3c647232e1094dc013546c0b33ce785d8aeb251e1f20dfaf8a9a13fe" +dependencies = [ + "futures-util", + "native-tls", + "thiserror", + "url", +] + [[package]] name = "async-trait" version = "0.1.64" @@ -254,6 +266,19 @@ dependencies = [ "syn", ] +[[package]] +name = "asynchronous-codec" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06a0daa378f5fd10634e44b0a29b2a87b890657658e072a30d6f26e57ddee182" +dependencies = [ + "bytes", + "futures-sink", + "futures-util", + "memchr", + "pin-project-lite", +] + [[package]] name = "atty" version = "0.2.14" @@ -703,6 +728,15 @@ dependencies = [ "prql-compiler", ] +[[package]] +name = "connection-string" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97faeec45f49581c458f8bf81992c5e3ec17d82cda99f59d3cea14eff62698d" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "console" version = "0.15.5" @@ -741,7 +775,7 @@ version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d7d6ab3c3a2282db210df5f02c4dab6e0a7057af0fb7ebd4070f30fe05c0ddb" dependencies = [ - "getrandom", + "getrandom 0.2.8", "once_cell", "proc-macro-hack", "tiny-keccak", @@ -1034,6 +1068,70 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +[[package]] +name = "encoding" +version = "0.2.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec" +dependencies = [ + "encoding-index-japanese", + "encoding-index-korean", + "encoding-index-simpchinese", + "encoding-index-singlebyte", + "encoding-index-tradchinese", +] + +[[package]] +name = "encoding-index-japanese" +version = "1.20141219.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04e8b2ff42e9a05335dbf8b5c6f7567e5591d0d916ccef4e0b1710d32a0d0c91" +dependencies = [ + "encoding_index_tests", +] + +[[package]] +name = "encoding-index-korean" +version = "1.20141219.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dc33fb8e6bcba213fe2f14275f0963fd16f0a02c878e3095ecfdf5bee529d81" +dependencies = [ + "encoding_index_tests", +] + +[[package]] +name = "encoding-index-simpchinese" +version = "1.20141219.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d87a7194909b9118fc707194baa434a4e3b0fb6a5a757c73c3adb07aa25031f7" +dependencies = [ + "encoding_index_tests", +] + +[[package]] +name = "encoding-index-singlebyte" +version = "1.20141219.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a" +dependencies = [ + "encoding_index_tests", +] + +[[package]] +name = "encoding-index-tradchinese" +version = "1.20141219.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18" +dependencies = [ + "encoding_index_tests", +] + +[[package]] +name = "encoding_index_tests" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" + [[package]] name = "enum-as-inner" version = "0.5.1" @@ -1046,6 +1144,26 @@ dependencies = [ "syn", ] +[[package]] +name = "enumflags2" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e75d4cd21b95383444831539909fbb14b9dc3fdceb2a6f5d36577329a1f55ccb" +dependencies = [ + "enumflags2_derive", +] + +[[package]] +name = "enumflags2_derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58dc3c5e468259f19f2d46304a6b28f1c3d034442e14b322d2b850e36f6d5ae" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "env_logger" version = "0.10.0" @@ -1259,6 +1377,12 @@ version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" +[[package]] +name = "futures-io" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89d422fa3cbe3b40dca574ab087abb5bc98258ea57eea3fd6f1fa7162c778b91" + [[package]] name = "futures-macro" version = "0.3.26" @@ -1289,9 +1413,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1" dependencies = [ "futures-core", + "futures-io", "futures-macro", "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", "slab", @@ -1316,6 +1442,17 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + [[package]] name = "getrandom" version = "0.2.8" @@ -1868,6 +2005,12 @@ dependencies = [ "digest", ] +[[package]] +name = "md5" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e6bcd6433cff03a4bfc3d9834d504467db1f1cf6d0ea765d37d330249ed629d" + [[package]] name = "mdbook" version = "0.4.27" @@ -2023,7 +2166,7 @@ dependencies = [ "lexical", "num-bigint", "num-traits", - "rand", + "rand 0.8.5", "regex", "rust_decimal", "saturating", @@ -2478,7 +2621,7 @@ dependencies = [ "hmac", "md-5", "memchr", - "rand", + "rand 0.8.5", "sha2", "stringprep", ] @@ -2500,6 +2643,12 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "pretty-hex" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6fa0831dd7cc608c38a5e323422a0077678fa5744aa2be4ad91c4ece8eec8d5" + [[package]] name = "pretty_assertions" version = "1.3.0" @@ -2599,6 +2748,9 @@ dependencies = [ "sqlparser", "strum", "strum_macros", + "tiberius", + "tokio", + "tokio-util", ] [[package]] @@ -2794,6 +2946,19 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", +] + [[package]] name = "rand" version = "0.8.5" @@ -2801,8 +2966,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha", - "rand_core", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", ] [[package]] @@ -2812,7 +2987,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", ] [[package]] @@ -2821,7 +3005,16 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.8", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", ] [[package]] @@ -2948,7 +3141,7 @@ dependencies = [ "byteorder", "bytes", "num-traits", - "rand", + "rand 0.8.5", "rkyv", "serde", "serde_json", @@ -3186,6 +3379,15 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + [[package]] name = "similar" version = "2.2.1" @@ -3409,6 +3611,34 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tiberius" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf8ecd8428f31011260ede6027930f452f45d4e3c4e9e7bf9b0231398772e9ce" +dependencies = [ + "async-native-tls", + "async-trait", + "asynchronous-codec", + "bigdecimal", + "byteorder", + "bytes", + "connection-string", + "encoding", + "enumflags2", + "futures-util", + "num-traits", + "once_cell", + "pin-project-lite", + "pretty-hex", + "thiserror", + "tokio", + "tokio-util", + "tracing", + "uuid", + "winauth", +] + [[package]] name = "time" version = "0.1.45" @@ -3481,18 +3711,33 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.25.0" +version = "1.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" +checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" dependencies = [ "autocfg", "bytes", "libc", "memchr", "mio", + "num_cpus", + "parking_lot", "pin-project-lite", + "signal-hook-registry", "socket2", - "windows-sys 0.42.0", + "tokio-macros", + "windows-sys 0.45.0", +] + +[[package]] +name = "tokio-macros" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -3527,6 +3772,7 @@ checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" dependencies = [ "bytes", "futures-core", + "futures-io", "futures-sink", "pin-project-lite", "tokio", @@ -3555,10 +3801,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", + "log", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "tracing-core" version = "0.1.30" @@ -3613,7 +3872,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", - "rand", + "rand 0.8.5", "static_assertions", ] @@ -3744,6 +4003,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + [[package]] name = "wasi" version = "0.10.0+wasi-snapshot-preview1" @@ -3887,6 +4152,19 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "winauth" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f820cd208ce9c6b050812dc2d724ba98c6c1e9db5ce9b3f58d925ae5723a5e6" +dependencies = [ + "bitflags", + "byteorder", + "md5", + "rand 0.7.3", + "winapi", +] + [[package]] name = "windows" version = "0.44.0" diff --git a/prql-compiler/Cargo.toml b/prql-compiler/Cargo.toml index 6b50a9d3f420..e8fbe0db435c 100644 --- a/prql-compiler/Cargo.toml +++ b/prql-compiler/Cargo.toml @@ -46,6 +46,9 @@ chrono = {version = "0.4", features = [], default-features = false} criterion = "0.4.0" postgres = "0.19.3" mysql = "23" +tiberius = {version = "0.12", features = ["sql-browser-tokio", "bigdecimal"]} +tokio = {version = "1", features = ["full"]} +tokio-util = { version = "0.7", features = ["compat"] } pretty_assertions = "1.3.0" rusqlite = {version = "0.28.0", features = ["bundled", "csvtab"]} pg_bigdecimal = "0.1" diff --git a/prql-compiler/tests/integration-vendors/main.rs b/prql-compiler/tests/integration-vendors/main.rs index a0105fa0228e..62ebc22f4457 100644 --- a/prql-compiler/tests/integration-vendors/main.rs +++ b/prql-compiler/tests/integration-vendors/main.rs @@ -1,6 +1,6 @@ #[cfg(test)] mod tests { - use std::time::SystemTime; + use std::time::{Duration, SystemTime}; use chrono::{DateTime, Utc}; use mysql::prelude::Queryable; @@ -8,6 +8,11 @@ mod tests { use pg_bigdecimal::PgNumeric; use postgres::types::Type; use postgres::NoTls; + use tiberius::numeric::BigDecimal; + use tiberius::*; + use tokio::net::TcpStream; + use tokio::runtime::Runtime; + use tokio_util::compat::{Compat, TokioAsyncWriteCompatExt}; use prql_compiler::sql::Dialect; use prql_compiler::Options; @@ -29,12 +34,32 @@ mod tests { let mut sqlite = SQLiteConnection(rusqlite::Connection::open_in_memory().unwrap()); let mut pg = PostgresConnection( postgres::Client::connect("host=localhost user=root password=root dbname=dummy", NoTls) - .unwrap() + .unwrap(), ); let mut my = MysqlConnection(mysql::Pool::new("mysql://root:root@localhost:3306/dummy").unwrap()); + let rt = tokio::runtime::Runtime::new().unwrap(); + let mut ms = { + let mut config = Config::new(); + config.host("127.0.0.1"); + config.port(1433); + config.trust_cert(); + config.authentication(AuthMethod::sql_server("sa", "Wordpass123##")); + + let client = rt.block_on(get_client(config.clone())); + + async fn get_client(config: Config) -> Client> { + let tcp = TcpStream::connect(config.get_addr()).await.unwrap(); + tcp.set_nodelay(true).unwrap(); + tiberius::Client::connect(config, tcp.compat_write()) + .await + .unwrap() + } + MssqlConnection(client) + }; + let connections: Vec<&mut dyn DBConnection> = - vec![&mut duck, &mut sqlite, &mut pg, &mut my]; + vec![&mut duck, &mut sqlite, &mut pg, &mut my, &mut ms]; for con in connections { let setup = include_str!("setup.sql"); @@ -43,13 +68,20 @@ mod tests { .map(|s| s.trim()) .filter(|s| !s.is_empty()) .for_each(|s| { - con.run_query(s); + let sql = match con.get_dialect() { + Dialect::MsSql => s + .replace(" boolean ", " bit ") + .replace("TRUE", "1") + .replace("FALSE", "0"), + _ => s.to_string(), + }; + con.run_query(sql.as_str(), Some(&rt)); }); for (prql, expected_rows) in test_cases.iter() { let options = Options::default().with_target(Sql(Some(con.get_dialect()))); let sql = prql_compiler::compile(prql, &options).unwrap(); - let mut actual_rows = con.run_query(sql.as_str()); + let mut actual_rows = con.run_query(sql.as_str(), Some(&rt)); replace_booleans(&mut actual_rows); assert_eq!( *expected_rows, @@ -74,7 +106,7 @@ mod tests { } trait DBConnection { - fn run_query(&mut self, sql: &str) -> Vec; + fn run_query(&mut self, sql: &str, rt: Option<&Runtime>) -> Vec; fn get_dialect(&self) -> Dialect; } @@ -87,8 +119,10 @@ mod tests { struct MysqlConnection(mysql::Pool); + struct MssqlConnection(tiberius::Client>); + impl DBConnection for DuckDBConnection { - fn run_query(&mut self, sql: &str) -> Vec { + fn run_query(&mut self, sql: &str, rt: Option<&Runtime>) -> Vec { let mut statement = self.0.prepare(sql).unwrap(); let mut rows = statement.query([]).unwrap(); let mut vec = vec![]; @@ -135,7 +169,7 @@ mod tests { } impl DBConnection for SQLiteConnection { - fn run_query(&mut self, sql: &str) -> Vec { + fn run_query(&mut self, sql: &str, rt: Option<&Runtime>) -> Vec { let mut statement = self.0.prepare(sql).unwrap(); let mut rows = statement.query([]).unwrap(); let mut vec = vec![]; @@ -170,7 +204,7 @@ mod tests { } impl DBConnection for PostgresConnection { - fn run_query(&mut self, sql: &str) -> Vec { + fn run_query(&mut self, sql: &str, rt: Option<&Runtime>) -> Vec { let rows = self.0.query(sql, &[]).unwrap(); let mut vec = vec![]; for row in rows.into_iter() { @@ -197,7 +231,7 @@ mod tests { let date_time: DateTime = time.into(); date_time.to_rfc3339() } - t => unimplemented!("postgres type {t}"), + typ => unimplemented!("postgres type {:?}", typ), }; columns.push(value); } @@ -212,7 +246,7 @@ mod tests { } impl DBConnection for MysqlConnection { - fn run_query(&mut self, sql: &str) -> Vec { + fn run_query(&mut self, sql: &str, rt: Option<&Runtime>) -> Vec { let mut conn = self.0.get_conn().unwrap(); let rows: Vec = conn.query(sql).unwrap(); let mut vec = vec![]; @@ -221,15 +255,12 @@ mod tests { for v in row.unwrap() { let value = match v { Value::NULL => "".to_string(), - Value::Bytes(v) => - String::from_utf8(v).unwrap_or("BLOB".to_string()), - + Value::Bytes(v) => String::from_utf8(v).unwrap_or("BLOB".to_string()), Value::Int(v) => v.to_string(), Value::UInt(v) => v.to_string(), Value::Float(v) => v.to_string(), Value::Double(v) => v.to_string(), - Value::Date(_, _, _, _, _, _, _) => todo!(), - Value::Time(_, _, _, _, _, _) => todo!() + typ => unimplemented!("mysql type {:?}", typ), }; columns.push(value); } @@ -242,4 +273,50 @@ mod tests { Dialect::MySql } } -} \ No newline at end of file + + impl DBConnection for MssqlConnection { + fn run_query(&mut self, sql: &str, rt: Option<&Runtime>) -> Vec { + let runtime = rt.unwrap(); + runtime.block_on(self.query(sql)) + } + + fn get_dialect(&self) -> Dialect { + Dialect::MsSql + } + } + + impl MssqlConnection { + async fn query(&mut self, sql: &str) -> Vec { + let mut stream = self.0.query(sql, &[]).await.unwrap(); + let mut vec = vec![]; + let cols_option = (&mut stream).columns().await.unwrap(); + if cols_option.is_none() { + return vec![]; + } + let cols = cols_option.unwrap().to_vec(); + for row in stream.into_first_result().await.unwrap() { + let mut columns = vec![]; + for i in 0..row.len() { + let col = &cols[i]; + let value = match col.column_type() { + ColumnType::Null => "".to_string(), + ColumnType::Bit => String::from(row.get::<&str, usize>(i).unwrap()), + ColumnType::Intn => row + .get::(i) + .map(|i| i.to_string()) + .unwrap_or("".to_string()), + ColumnType::Numericn => { + row.get::(i).unwrap().to_string() + } + ColumnType::BigVarChar => String::from(row.get::<&str, usize>(i).unwrap()), + typ => unimplemented!("mssql type {:?}", typ), + }; + columns.push(value); + } + vec.push(columns); + } + + vec + } + } +} From 202414666487b9aa77001a77bb9aae18970c9f5e Mon Sep 17 00:00:00 2001 From: Jelenkee Date: Sun, 19 Mar 2023 15:22:29 +0100 Subject: [PATCH 05/29] refactoring --- .../tests/integration-vendors/connection.rs | 228 ++++++++++++ .../tests/integration-vendors/main.rs | 340 ++++-------------- .../tests/integration-vendors/testcases.txt | 32 ++ 3 files changed, 334 insertions(+), 266 deletions(-) create mode 100644 prql-compiler/tests/integration-vendors/connection.rs create mode 100644 prql-compiler/tests/integration-vendors/testcases.txt diff --git a/prql-compiler/tests/integration-vendors/connection.rs b/prql-compiler/tests/integration-vendors/connection.rs new file mode 100644 index 000000000000..8c27485967ec --- /dev/null +++ b/prql-compiler/tests/integration-vendors/connection.rs @@ -0,0 +1,228 @@ +use std::time::SystemTime; + +use chrono::{DateTime, Utc}; +use mysql::prelude::Queryable; +use mysql::Value; +use pg_bigdecimal::PgNumeric; +use postgres::types::Type; +use tiberius::*; +use tiberius::numeric::BigDecimal; +use tokio::net::TcpStream; +use tokio::runtime::Runtime; +use tokio_util::compat::Compat; + +use prql_compiler::sql::Dialect; + +pub type Row = Vec; + +pub struct DuckDBConnection(pub duckdb::Connection); + +pub struct SQLiteConnection(pub rusqlite::Connection); + +pub struct PostgresConnection(pub postgres::Client); + +pub struct MysqlConnection(pub mysql::Pool); + +pub struct MssqlConnection(pub tiberius::Client>); + +pub trait DBConnection { + fn run_query(&mut self, sql: &str, runtime: &Runtime) -> Vec; + + fn get_dialect(&self) -> Dialect; +} + +impl DBConnection for DuckDBConnection { + fn run_query(&mut self, sql: &str, _runtime: &Runtime) -> Vec { + let mut statement = self.0.prepare(sql).unwrap(); + let mut rows = statement.query([]).unwrap(); + let mut vec = vec![]; + while let Ok(Some(row)) = rows.next() { + let mut columns = vec![]; + // row.len() always gives 1. hence this workaround + for i in 0.. { + let v_ref = match row.get_ref(i) { + Ok(v) => v, + Err(_) => { + break; + } + }; + let value = match v_ref { + duckdb::types::ValueRef::Null => "".to_string(), + duckdb::types::ValueRef::Boolean(v) => v.to_string(), + duckdb::types::ValueRef::TinyInt(v) => v.to_string(), + duckdb::types::ValueRef::SmallInt(v) => v.to_string(), + duckdb::types::ValueRef::Int(v) => v.to_string(), + duckdb::types::ValueRef::BigInt(v) => v.to_string(), + duckdb::types::ValueRef::HugeInt(v) => v.to_string(), + duckdb::types::ValueRef::UTinyInt(v) => v.to_string(), + duckdb::types::ValueRef::USmallInt(v) => v.to_string(), + duckdb::types::ValueRef::UInt(v) => v.to_string(), + duckdb::types::ValueRef::UBigInt(v) => v.to_string(), + duckdb::types::ValueRef::Float(v) => v.to_string(), + duckdb::types::ValueRef::Double(v) => v.to_string(), + duckdb::types::ValueRef::Decimal(v) => v.to_string(), + duckdb::types::ValueRef::Timestamp(u, v) => format!("{} {:?}", v, u), + duckdb::types::ValueRef::Text(v) => String::from_utf8(v.to_vec()).unwrap(), + duckdb::types::ValueRef::Blob(_) => "BLOB".to_string(), + duckdb::types::ValueRef::Date32(v) => v.to_string(), + duckdb::types::ValueRef::Time64(u, v) => format!("{} {:?}", v, u), + }; + columns.push(value); + } + vec.push(columns) + } + vec + } + + fn get_dialect(&self) -> Dialect { + Dialect::DuckDb + } +} + +impl DBConnection for SQLiteConnection { + fn run_query(&mut self, sql: &str, _runtime: &Runtime) -> Vec { + let mut statement = self.0.prepare(sql).unwrap(); + let mut rows = statement.query([]).unwrap(); + let mut vec = vec![]; + while let Ok(Some(row)) = rows.next() { + let mut columns = vec![]; + // row.len() always gives 1. hence this workaround + for i in 0.. { + let v_ref = match row.get_ref(i) { + Ok(v) => v, + Err(_) => { + break; + } + }; + let value = match v_ref { + rusqlite::types::ValueRef::Null => "".to_string(), + rusqlite::types::ValueRef::Integer(v) => v.to_string(), + rusqlite::types::ValueRef::Real(v) => v.to_string(), + rusqlite::types::ValueRef::Text(v) => String::from_utf8(v.to_vec()).unwrap(), + rusqlite::types::ValueRef::Blob(_) => "BLOB".to_string(), + }; + columns.push(value); + } + vec.push(columns); + } + vec + } + + fn get_dialect(&self) -> Dialect { + Dialect::SQLite + } +} + +impl DBConnection for PostgresConnection { + fn run_query(&mut self, sql: &str, _runtime: &Runtime) -> Vec { + let rows = self.0.query(sql, &[]).unwrap(); + let mut vec = vec![]; + for row in rows.into_iter() { + let mut columns = vec![]; + for i in 0..row.len() { + let col = &(*row.columns())[i]; + let value = match col.type_() { + &Type::BOOL => (row.get::(i)).to_string(), + &Type::INT4 => (row.get::(i)).to_string(), + &Type::INT8 => (row.get::(i)).to_string(), + &Type::TEXT => { + match row.try_get::(i) { + Ok(v) => v, + // handle null + Err(_) => "".to_string(), + } + } + &Type::VARCHAR | &Type::JSON | &Type::JSONB => row.get::(i), + &Type::FLOAT4 => (row.get::(i)).to_string(), + &Type::FLOAT8 => (row.get::(i)).to_string(), + &Type::NUMERIC => row.get::(i).n.unwrap().to_string(), + &Type::TIMESTAMPTZ | &Type::TIMESTAMP => { + let time = row.get::(i); + let date_time: DateTime = time.into(); + date_time.to_rfc3339() + } + typ => unimplemented!("postgres type {:?}", typ), + }; + columns.push(value); + } + vec.push(columns); + } + vec + } + + fn get_dialect(&self) -> Dialect { + Dialect::PostgreSql + } +} + +impl DBConnection for MysqlConnection { + fn run_query(&mut self, sql: &str, _runtime: &Runtime) -> Vec { + let mut conn = self.0.get_conn().unwrap(); + let rows: Vec = conn.query(sql).unwrap(); + let mut vec = vec![]; + for row in rows.into_iter() { + let mut columns = vec![]; + for v in row.unwrap() { + let value = match v { + Value::NULL => "".to_string(), + Value::Bytes(v) => String::from_utf8(v).unwrap_or("BLOB".to_string()), + Value::Int(v) => v.to_string(), + Value::UInt(v) => v.to_string(), + Value::Float(v) => v.to_string(), + Value::Double(v) => v.to_string(), + typ => unimplemented!("mysql type {:?}", typ), + }; + columns.push(value); + } + vec.push(columns); + } + vec + } + + fn get_dialect(&self) -> Dialect { + Dialect::MySql + } +} + +impl DBConnection for MssqlConnection { + fn run_query(&mut self, sql: &str, runtime: &Runtime) -> Vec { + runtime.block_on(self.query(sql)) + } + + fn get_dialect(&self) -> Dialect { + Dialect::MsSql + } +} + +impl MssqlConnection { + async fn query(&mut self, sql: &str) -> Vec { + let mut stream = self.0.query(sql, &[]).await.unwrap(); + let mut vec = vec![]; + let cols_option = (&mut stream).columns().await.unwrap(); + if cols_option.is_none() { + return vec![]; + } + let cols = cols_option.unwrap().to_vec(); + for row in stream.into_first_result().await.unwrap() { + let mut columns = vec![]; + for i in 0..row.len() { + let col = &cols[i]; + let value = match col.column_type() { + ColumnType::Null => "".to_string(), + ColumnType::Bit => String::from(row.get::<&str, usize>(i).unwrap()), + ColumnType::Intn => row + .get::(i) + .map(|i| i.to_string()) + .unwrap_or("".to_string()), + ColumnType::Numericn => row.get::(i).unwrap().to_string(), + ColumnType::BigVarChar => String::from(row.get::<&str, usize>(i).unwrap()), + typ => unimplemented!("mssql type {:?}", typ), + }; + columns.push(value); + } + vec.push(columns); + } + + vec + } +} diff --git a/prql-compiler/tests/integration-vendors/main.rs b/prql-compiler/tests/integration-vendors/main.rs index 62ebc22f4457..08e23f93c2c3 100644 --- a/prql-compiler/tests/integration-vendors/main.rs +++ b/prql-compiler/tests/integration-vendors/main.rs @@ -1,35 +1,22 @@ +mod connection; + #[cfg(test)] mod tests { - use std::time::{Duration, SystemTime}; - - use chrono::{DateTime, Utc}; - use mysql::prelude::Queryable; - use mysql::Value; - use pg_bigdecimal::PgNumeric; - use postgres::types::Type; use postgres::NoTls; - use tiberius::numeric::BigDecimal; - use tiberius::*; + use tiberius::{AuthMethod, Client, Config}; use tokio::net::TcpStream; use tokio::runtime::Runtime; use tokio_util::compat::{Compat, TokioAsyncWriteCompatExt}; - use prql_compiler::sql::Dialect; use prql_compiler::Options; + use prql_compiler::sql::Dialect; use prql_compiler::Target::Sql; - type Row = Vec; + use crate::connection::*; #[test] fn test_vendor() { - let test_cases: Vec<(&str, Vec)> = vec![( - "from c=customers - join ca=cars [ca.customer==c.id] - filter ca.name=='Bugatti' - select c.name", - vec![vec!["Tony Stark".to_string()]], - )]; - + let runtime = Runtime::new().unwrap(); let mut duck = DuckDBConnection(duckdb::Connection::open_in_memory().unwrap()); let mut sqlite = SQLiteConnection(rusqlite::Connection::open_in_memory().unwrap()); let mut pg = PostgresConnection( @@ -38,7 +25,6 @@ mod tests { ); let mut my = MysqlConnection(mysql::Pool::new("mysql://root:root@localhost:3306/dummy").unwrap()); - let rt = tokio::runtime::Runtime::new().unwrap(); let mut ms = { let mut config = Config::new(); config.host("127.0.0.1"); @@ -46,14 +32,12 @@ mod tests { config.trust_cert(); config.authentication(AuthMethod::sql_server("sa", "Wordpass123##")); - let client = rt.block_on(get_client(config.clone())); + let client = runtime.block_on(get_client(config.clone())); async fn get_client(config: Config) -> Client> { let tcp = TcpStream::connect(config.get_addr()).await.unwrap(); tcp.set_nodelay(true).unwrap(); - tiberius::Client::connect(config, tcp.compat_write()) - .await - .unwrap() + Client::connect(config, tcp.compat_write()).await.unwrap() } MssqlConnection(client) }; @@ -62,37 +46,76 @@ mod tests { vec![&mut duck, &mut sqlite, &mut pg, &mut my, &mut ms]; for con in connections { - let setup = include_str!("setup.sql"); - setup - .split(";") - .map(|s| s.trim()) - .filter(|s| !s.is_empty()) - .for_each(|s| { - let sql = match con.get_dialect() { - Dialect::MsSql => s - .replace(" boolean ", " bit ") - .replace("TRUE", "1") - .replace("FALSE", "0"), - _ => s.to_string(), - }; - con.run_query(sql.as_str(), Some(&rt)); - }); + run_tests_for_connection(con, &runtime); + } + } - for (prql, expected_rows) in test_cases.iter() { - let options = Options::default().with_target(Sql(Some(con.get_dialect()))); - let sql = prql_compiler::compile(prql, &options).unwrap(); - let mut actual_rows = con.run_query(sql.as_str(), Some(&rt)); - replace_booleans(&mut actual_rows); - assert_eq!( - *expected_rows, - actual_rows, - "Rows do not match for {}", - con.get_dialect() - ); - } + fn run_tests_for_connection(con: &mut dyn DBConnection, runtime: &Runtime) { + let setup = include_str!("setup.sql"); + setup + .split(";") + .map(|s| s.trim()) + .filter(|s| !s.is_empty()) + .for_each(|s| { + let sql = match con.get_dialect() { + Dialect::MsSql => s + .replace(" boolean ", " bit ") + .replace("TRUE", "1") + .replace("FALSE", "0"), + _ => s.to_string(), + }; + con.run_query(sql.as_str(), runtime); + }); + + for (prql, expected_rows) in get_test_cases() { + let options = Options::default().with_target(Sql(Some(con.get_dialect()))); + let sql = prql_compiler::compile(prql.as_str(), &options).unwrap(); + let mut actual_rows = con.run_query(sql.as_str(), runtime); + replace_booleans(&mut actual_rows); + println!("{} {:?}", &con.get_dialect(), &actual_rows); + assert_eq!( + *expected_rows, + actual_rows, + "Rows do not match for {}", + con.get_dialect() + ); } } + fn get_test_cases() -> Vec<(String, Vec)> { + let test_file = include_str!("testcases.txt"); + let tests = test_file + .split("###") + .map(|s| s.trim()) + .filter(|s| !s.is_empty()) + .collect::>(); + + tests + .iter() + .map(|test| { + let tests = test + .split("---") + .map(|s| s.trim()) + .filter(|s| !s.is_empty()) + .collect::>(); + assert_eq!(tests.len(), 2, "Test is missing ---"); + let rows = tests[1] + .lines() + .map(|l| { + l.split(",") + .map(|s| s.trim()) + .filter(|s| !s.is_empty()) + .map(|s| s.to_string()) + .collect::() + }) + .collect::>(); + + (tests[0].to_string(), rows) + }) + .collect() + } + + // some sql dialects use 1 and 0 instead of true and false fn replace_booleans(rows: &mut Vec) { for row in rows { for col in row { @@ -104,219 +127,4 @@ mod tests { } } } - - trait DBConnection { - fn run_query(&mut self, sql: &str, rt: Option<&Runtime>) -> Vec; - - fn get_dialect(&self) -> Dialect; - } - - struct DuckDBConnection(duckdb::Connection); - - struct SQLiteConnection(rusqlite::Connection); - - struct PostgresConnection(postgres::Client); - - struct MysqlConnection(mysql::Pool); - - struct MssqlConnection(tiberius::Client>); - - impl DBConnection for DuckDBConnection { - fn run_query(&mut self, sql: &str, rt: Option<&Runtime>) -> Vec { - let mut statement = self.0.prepare(sql).unwrap(); - let mut rows = statement.query([]).unwrap(); - let mut vec = vec![]; - while let Ok(Some(row)) = rows.next() { - let mut columns = vec![]; - for i in 0.. { - let v_ref = match row.get_ref(i) { - Ok(v) => v, - Err(_) => { - break; - } - }; - let value = match v_ref { - duckdb::types::ValueRef::Null => "".to_string(), - duckdb::types::ValueRef::Boolean(v) => v.to_string(), - duckdb::types::ValueRef::TinyInt(v) => v.to_string(), - duckdb::types::ValueRef::SmallInt(v) => v.to_string(), - duckdb::types::ValueRef::Int(v) => v.to_string(), - duckdb::types::ValueRef::BigInt(v) => v.to_string(), - duckdb::types::ValueRef::HugeInt(v) => v.to_string(), - duckdb::types::ValueRef::UTinyInt(v) => v.to_string(), - duckdb::types::ValueRef::USmallInt(v) => v.to_string(), - duckdb::types::ValueRef::UInt(v) => v.to_string(), - duckdb::types::ValueRef::UBigInt(v) => v.to_string(), - duckdb::types::ValueRef::Float(v) => v.to_string(), - duckdb::types::ValueRef::Double(v) => v.to_string(), - duckdb::types::ValueRef::Decimal(v) => v.to_string(), - duckdb::types::ValueRef::Timestamp(u, v) => format!("{} {:?}", v, u), - duckdb::types::ValueRef::Text(v) => String::from_utf8(v.to_vec()).unwrap(), - duckdb::types::ValueRef::Blob(_) => "BLOB".to_string(), - duckdb::types::ValueRef::Date32(v) => v.to_string(), - duckdb::types::ValueRef::Time64(u, v) => format!("{} {:?}", v, u), - }; - columns.push(value); - } - vec.push(columns) - } - vec - } - - fn get_dialect(&self) -> Dialect { - Dialect::DuckDb - } - } - - impl DBConnection for SQLiteConnection { - fn run_query(&mut self, sql: &str, rt: Option<&Runtime>) -> Vec { - let mut statement = self.0.prepare(sql).unwrap(); - let mut rows = statement.query([]).unwrap(); - let mut vec = vec![]; - while let Ok(Some(row)) = rows.next() { - let mut columns = vec![]; - for i in 0.. { - let v_ref = match row.get_ref(i) { - Ok(v) => v, - Err(_) => { - break; - } - }; - let value = match v_ref { - rusqlite::types::ValueRef::Null => "".to_string(), - rusqlite::types::ValueRef::Integer(v) => v.to_string(), - rusqlite::types::ValueRef::Real(v) => v.to_string(), - rusqlite::types::ValueRef::Text(v) => { - String::from_utf8(v.to_vec()).unwrap() - } - rusqlite::types::ValueRef::Blob(_) => "BLOB".to_string(), - }; - columns.push(value); - } - vec.push(columns); - } - vec - } - - fn get_dialect(&self) -> Dialect { - Dialect::SQLite - } - } - - impl DBConnection for PostgresConnection { - fn run_query(&mut self, sql: &str, rt: Option<&Runtime>) -> Vec { - let rows = self.0.query(sql, &[]).unwrap(); - let mut vec = vec![]; - for row in rows.into_iter() { - let mut columns = vec![]; - for i in 0..row.len() { - let col = &(*row.columns())[i]; - let value = match col.type_() { - &Type::BOOL => (row.get::(i)).to_string(), - &Type::INT4 => (row.get::(i)).to_string(), - &Type::INT8 => (row.get::(i)).to_string(), - &Type::TEXT => { - match row.try_get::(i) { - Ok(v) => v, - // handle null - Err(_) => "".to_string(), - } - } - &Type::VARCHAR | &Type::JSON | &Type::JSONB => row.get::(i), - &Type::FLOAT4 => (row.get::(i)).to_string(), - &Type::FLOAT8 => (row.get::(i)).to_string(), - &Type::NUMERIC => row.get::(i).n.unwrap().to_string(), - &Type::TIMESTAMPTZ | &Type::TIMESTAMP => { - let time = row.get::(i); - let date_time: DateTime = time.into(); - date_time.to_rfc3339() - } - typ => unimplemented!("postgres type {:?}", typ), - }; - columns.push(value); - } - vec.push(columns); - } - vec - } - - fn get_dialect(&self) -> Dialect { - Dialect::PostgreSql - } - } - - impl DBConnection for MysqlConnection { - fn run_query(&mut self, sql: &str, rt: Option<&Runtime>) -> Vec { - let mut conn = self.0.get_conn().unwrap(); - let rows: Vec = conn.query(sql).unwrap(); - let mut vec = vec![]; - for row in rows.into_iter() { - let mut columns = vec![]; - for v in row.unwrap() { - let value = match v { - Value::NULL => "".to_string(), - Value::Bytes(v) => String::from_utf8(v).unwrap_or("BLOB".to_string()), - Value::Int(v) => v.to_string(), - Value::UInt(v) => v.to_string(), - Value::Float(v) => v.to_string(), - Value::Double(v) => v.to_string(), - typ => unimplemented!("mysql type {:?}", typ), - }; - columns.push(value); - } - vec.push(columns); - } - vec - } - - fn get_dialect(&self) -> Dialect { - Dialect::MySql - } - } - - impl DBConnection for MssqlConnection { - fn run_query(&mut self, sql: &str, rt: Option<&Runtime>) -> Vec { - let runtime = rt.unwrap(); - runtime.block_on(self.query(sql)) - } - - fn get_dialect(&self) -> Dialect { - Dialect::MsSql - } - } - - impl MssqlConnection { - async fn query(&mut self, sql: &str) -> Vec { - let mut stream = self.0.query(sql, &[]).await.unwrap(); - let mut vec = vec![]; - let cols_option = (&mut stream).columns().await.unwrap(); - if cols_option.is_none() { - return vec![]; - } - let cols = cols_option.unwrap().to_vec(); - for row in stream.into_first_result().await.unwrap() { - let mut columns = vec![]; - for i in 0..row.len() { - let col = &cols[i]; - let value = match col.column_type() { - ColumnType::Null => "".to_string(), - ColumnType::Bit => String::from(row.get::<&str, usize>(i).unwrap()), - ColumnType::Intn => row - .get::(i) - .map(|i| i.to_string()) - .unwrap_or("".to_string()), - ColumnType::Numericn => { - row.get::(i).unwrap().to_string() - } - ColumnType::BigVarChar => String::from(row.get::<&str, usize>(i).unwrap()), - typ => unimplemented!("mssql type {:?}", typ), - }; - columns.push(value); - } - vec.push(columns); - } - - vec - } - } } diff --git a/prql-compiler/tests/integration-vendors/testcases.txt b/prql-compiler/tests/integration-vendors/testcases.txt new file mode 100644 index 000000000000..4667ccb15e29 --- /dev/null +++ b/prql-compiler/tests/integration-vendors/testcases.txt @@ -0,0 +1,32 @@ +from c=customers +join ca=cars [ca.customer==c.id] +filter ca.name=='Bugatti' +select c.name +--- +Tony Stark + +### + +from cars +filter (id | in 4..5) +sort [-name] +select name +--- +Toyota +Lamborghini + +### + +from customers +join cars [cars.customer==customers.id] +group [customers.name]( + aggregate [ + c = count, + ] +) +sort c +--- +Wade Wilson,1 +Bruce Wayne,2 +Tony Stark,3 + From 3063a484046995e4917de45c9a49e24b1152ac0d Mon Sep 17 00:00:00 2001 From: Jelenkee Date: Tue, 21 Mar 2023 21:31:23 +0100 Subject: [PATCH 06/29] -added go-task --- Taskfile.yml | 5 +++++ .../tests/integration-vendors/main.rs | 20 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Taskfile.yml b/Taskfile.yml index 32eff3beb996..98df06f5895a 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -196,6 +196,11 @@ tasks: # We build the book too, because that acts as a test - cd web/book && mdbook build + test-integration: + desc: Test generated SQL for different vendors + cmds: + - cargo test test_vendors -- --ignored + test-rust-fast: desc: Test prql-compiler's unit tests. summary: | diff --git a/prql-compiler/tests/integration-vendors/main.rs b/prql-compiler/tests/integration-vendors/main.rs index 08e23f93c2c3..18bb41a85365 100644 --- a/prql-compiler/tests/integration-vendors/main.rs +++ b/prql-compiler/tests/integration-vendors/main.rs @@ -14,8 +14,14 @@ mod tests { use crate::connection::*; + #[ignore] #[test] - fn test_vendor() { + fn test_vendors() { + [5432, 3306, 1433, 50000].iter().for_each(|port| { + if !is_port_open(*port) { + panic!("No database is listening on port {}", port); + } + }); let runtime = Runtime::new().unwrap(); let mut duck = DuckDBConnection(duckdb::Connection::open_in_memory().unwrap()); let mut sqlite = SQLiteConnection(rusqlite::Connection::open_in_memory().unwrap()); @@ -127,4 +133,16 @@ mod tests { } } } + + fn is_port_open(port: u16) -> bool { + match std::net::TcpStream::connect(("127.0.0.1", port)) { + Ok(stream) => { + stream.shutdown(std::net::Shutdown::Both).unwrap_or(()); + true + } + Err(_) => { + false + } + } + } } From 454b51f6796a498c59885cdd1d613feecde51fd5 Mon Sep 17 00:00:00 2001 From: Jelenkee Date: Tue, 21 Mar 2023 22:31:38 +0100 Subject: [PATCH 07/29] -more testcases --- .../tests/integration-vendors/connection.rs | 2 +- .../integration-vendors/docker-compose.yml | 26 +++---- .../tests/integration-vendors/main.rs | 2 + .../tests/integration-vendors/setup.sql | 47 +++++++------ .../tests/integration-vendors/testcases.txt | 67 +++++++++++++++++-- 5 files changed, 106 insertions(+), 38 deletions(-) diff --git a/prql-compiler/tests/integration-vendors/connection.rs b/prql-compiler/tests/integration-vendors/connection.rs index 8c27485967ec..ae409574888e 100644 --- a/prql-compiler/tests/integration-vendors/connection.rs +++ b/prql-compiler/tests/integration-vendors/connection.rs @@ -210,7 +210,7 @@ impl MssqlConnection { let value = match col.column_type() { ColumnType::Null => "".to_string(), ColumnType::Bit => String::from(row.get::<&str, usize>(i).unwrap()), - ColumnType::Intn => row + ColumnType::Intn | ColumnType::Int4 => row .get::(i) .map(|i| i.to_string()) .unwrap_or("".to_string()), diff --git a/prql-compiler/tests/integration-vendors/docker-compose.yml b/prql-compiler/tests/integration-vendors/docker-compose.yml index cb1d3354f26f..ab26a5bbf9f7 100644 --- a/prql-compiler/tests/integration-vendors/docker-compose.yml +++ b/prql-compiler/tests/integration-vendors/docker-compose.yml @@ -16,19 +16,19 @@ services: environment: MYSQL_DATABASE: dummy MYSQL_ROOT_PASSWORD: root - db2: - image: 'icr.io/db2_community/db2' - ports: - - '50000:50000' - environment: - LICENSE: accept - DBNAME: dummy - DB2INSTANCE: db2 - DB2INST1_PASSWORD: root - BLU: false - TO_CREATE_SAMPLEDB: false - REPODB: false - IS_OSXFS: false +# db2: +# image: 'icr.io/db2_community/db2' +# ports: +# - '50000:50000' +# environment: +# LICENSE: accept +# DBNAME: dummy +# DB2INSTANCE: db2 +# DB2INST1_PASSWORD: root +# BLU: false +# TO_CREATE_SAMPLEDB: false +# REPODB: false +# IS_OSXFS: false mssql: image: 'mcr.microsoft.com/mssql/server:2022-latest' ports: diff --git a/prql-compiler/tests/integration-vendors/main.rs b/prql-compiler/tests/integration-vendors/main.rs index 18bb41a85365..226a64063681 100644 --- a/prql-compiler/tests/integration-vendors/main.rs +++ b/prql-compiler/tests/integration-vendors/main.rs @@ -68,6 +68,8 @@ mod tests { .replace(" boolean ", " bit ") .replace("TRUE", "1") .replace("FALSE", "0"), + Dialect::MySql => s + .replace("\"", "`"), _ => s.to_string(), }; con.run_query(sql.as_str(), runtime); diff --git a/prql-compiler/tests/integration-vendors/setup.sql b/prql-compiler/tests/integration-vendors/setup.sql index 53583a84af47..091362e0c0e4 100644 --- a/prql-compiler/tests/integration-vendors/setup.sql +++ b/prql-compiler/tests/integration-vendors/setup.sql @@ -1,10 +1,8 @@ DROP TABLE IF EXISTS cars; +DROP TABLE IF EXISTS people; +DROP TABLE IF EXISTS "Upper"; - -DROP TABLE IF EXISTS customers; - - -CREATE TABLE customers +CREATE TABLE people ( id integer NOT NULL, name varchar(255) NOT NULL, @@ -12,20 +10,24 @@ CREATE TABLE customers PRIMARY KEY (id) ); - CREATE TABLE cars ( id integer NOT NULL, - customer integer NOT NULL, + person integer NOT NULL, name varchar(255), + price integer NOT NULL, PRIMARY KEY (id), CONSTRAINT c - FOREIGN KEY (customer) - REFERENCES customers (id) + FOREIGN KEY (person) + REFERENCES people (id) ); +CREATE TABLE "Upper" +( + id integer NOT NULL +); -INSERT INTO customers +INSERT INTO people ( id, name, @@ -36,17 +38,24 @@ VALUES (1, 'Bruce Wayne', TRUE), (2, 'Wade Wilson', FALSE); - INSERT INTO cars ( id, - customer, - name + person, + name, + price +) +VALUES +(0, 1, 'Mercedes', 60000), +(1, 1, 'Porsche', 90000), +(2, 0, 'Bugatti', 400000), +(3, 0, 'Ferrari', 500000), +(4, 0, 'Lamborghini', 200000), +(5, 2, 'Toyota', 10000); + +INSERT INTO "Upper" +( + id ) VALUES -(0, 1, 'Mercedes'), -(1, 1, 'Porsche'), -(2, 0, 'Bugatti'), -(3, 0, 'Ferrari'), -(4, 0, 'Lamborghini'), -(5, 2, 'Toyota'); \ No newline at end of file +(999); \ No newline at end of file diff --git a/prql-compiler/tests/integration-vendors/testcases.txt b/prql-compiler/tests/integration-vendors/testcases.txt index 4667ccb15e29..9bcd913e8794 100644 --- a/prql-compiler/tests/integration-vendors/testcases.txt +++ b/prql-compiler/tests/integration-vendors/testcases.txt @@ -1,5 +1,5 @@ -from c=customers -join ca=cars [ca.customer==c.id] +from c=people +join ca=cars [ca.person==c.id] filter ca.name=='Bugatti' select c.name --- @@ -17,9 +17,9 @@ Lamborghini ### -from customers -join cars [cars.customer==customers.id] -group [customers.name]( +from people +join cars [cars.person==people.id] +group [people.name]( aggregate [ c = count, ] @@ -30,3 +30,60 @@ Wade Wilson,1 Bruce Wayne,2 Tony Stark,3 +### + +from cars +select [person] +group cars.* (take 1) +sort cars.person +--- +0 +1 +2 + +### + +let car_count = ( + from cars + aggregate a = count +) + +from car_count +filter a > 0 +select a +--- +6 + +### + +from people +join cars [cars.person==people.id] +group [people.id, people.name] (aggregate price = (sum cars.price)) +select ![people.id] +sort people.name +--- +Bruce Wayne,150000 +Tony Stark,1100000 +Wade Wilson,10000 + +### + +from cars +sort price +select p = case [ + price == null => 'priceless', + price < 40000 => 'cheap', + true => 'expensive' +] +take 3 +--- +cheap,10000 +expensive,60000 +expensive,90000 + +### + +from Upper +select id +--- +999 From 384e95cc20a7ac1324ffcba7fcf4fd40ca587e12 Mon Sep 17 00:00:00 2001 From: Jelenkee Date: Tue, 21 Mar 2023 23:35:05 +0100 Subject: [PATCH 08/29] -added github workflow --- .github/workflows/integration-test.yaml | 28 +++++++++++++++++++ .github/workflows/test-all.yaml | 3 ++ .../tests/integration-vendors/main.rs | 4 ++- 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/integration-test.yaml diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml new file mode 100644 index 000000000000..adc99f75f23e --- /dev/null +++ b/.github/workflows/integration-test.yaml @@ -0,0 +1,28 @@ +name: integration-test + +on: + pull_request: + paths: + - "prql-compiler/**" + - ".github/workflows/integration-test.yaml" + workflow_call: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-integration + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Run docker compose + run: docker-compose up -d + working-directory: ./prql-compiler/tests/integration-vendors + - name: Wait for database + uses: ifaxity/wait-on-action + with: + resource: "tcp:5432 tcp:3306 tcp:1433" + - run: cargo test test_vendors -- --ignored + diff --git a/.github/workflows/test-all.yaml b/.github/workflows/test-all.yaml index c1ced1f612dd..c223d7a47626 100644 --- a/.github/workflows/test-all.yaml +++ b/.github/workflows/test-all.yaml @@ -68,6 +68,9 @@ jobs: test-taskfile: uses: ./.github/workflows/test-taskfile.yaml + integration-test: + uses: ./.github/workflows/integration-test.yaml + measure-code-cov: # Currently disabled due to https://github.com/actions-rs/tarpaulin/issues/21 if: false diff --git a/prql-compiler/tests/integration-vendors/main.rs b/prql-compiler/tests/integration-vendors/main.rs index 226a64063681..8bf7f45641bd 100644 --- a/prql-compiler/tests/integration-vendors/main.rs +++ b/prql-compiler/tests/integration-vendors/main.rs @@ -17,7 +17,7 @@ mod tests { #[ignore] #[test] fn test_vendors() { - [5432, 3306, 1433, 50000].iter().for_each(|port| { + [5432, 3306, 1433/*, 50000*/].iter().for_each(|port| { if !is_port_open(*port) { panic!("No database is listening on port {}", port); } @@ -90,6 +90,7 @@ mod tests { } } + // parse test cases from file fn get_test_cases() -> Vec<(String, Vec)> { let test_file = include_str!("testcases.txt"); let tests = test_file @@ -107,6 +108,7 @@ mod tests { .filter(|s| !s.is_empty()) .collect::>(); assert_eq!(tests.len(), 2, "Test is missing ---"); + let rows = tests[1] .lines() .map(|l| { From 7a962a67a848a98117ba49a2924c9b3e30416500 Mon Sep 17 00:00:00 2001 From: Jelenkee Date: Wed, 22 Mar 2023 17:50:42 +0100 Subject: [PATCH 09/29] -fixed formatting --- Cargo.lock | 940 +++++++++++++++++- .../tests/integration-vendors/connection.rs | 11 +- .../tests/integration-vendors/main.rs | 19 +- 3 files changed, 928 insertions(+), 42 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0a5d9e44a404..acab1717e206 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,7 +23,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom", + "getrandom 0.2.8", "once_cell", "version_check", ] @@ -36,7 +36,7 @@ checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if", "const-random", - "getrandom", + "getrandom 0.2.8", "once_cell", "version_check", ] @@ -245,6 +245,18 @@ dependencies = [ "regex-syntax", ] +[[package]] +name = "async-native-tls" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d57d4cec3c647232e1094dc013546c0b33ce785d8aeb251e1f20dfaf8a9a13fe" +dependencies = [ + "futures-util", + "native-tls", + "thiserror", + "url", +] + [[package]] name = "async-trait" version = "0.1.67" @@ -256,6 +268,19 @@ dependencies = [ "syn 2.0.2", ] +[[package]] +name = "asynchronous-codec" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06a0daa378f5fd10634e44b0a29b2a87b890657658e072a30d6f26e57ddee182" +dependencies = [ + "bytes", + "futures-sink", + "futures-util", + "memchr", + "pin-project-lite", +] + [[package]] name = "atty" version = "0.2.14" @@ -294,12 +319,54 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]] +name = "bigdecimal" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6aaf33151a6429fe9211d1b276eafdf70cdff28b071e76c0b0e1503221ea3744" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "bindgen" +version = "0.59.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "peeking_take_while", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", +] + [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + [[package]] name = "block-buffer" version = "0.10.4" @@ -366,6 +433,12 @@ dependencies = [ "serde", ] +[[package]] +name = "bufstream" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40e38929add23cdf8a366df9b0e088953150724bcbe5fc330b0d8eb3b328eec8" + [[package]] name = "bumpalo" version = "3.12.0" @@ -427,6 +500,15 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -443,7 +525,7 @@ dependencies = [ "js-sys", "num-integer", "num-traits", - "time", + "time 0.1.45", "wasm-bindgen", "winapi", ] @@ -485,6 +567,17 @@ dependencies = [ "half 1.8.2", ] +[[package]] +name = "clang-sys" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ed9a53e5d4d9c573ae844bfac6872b159cb1d1585a83b29e7a64b7eef7332a" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "clap" version = "3.2.23" @@ -564,6 +657,15 @@ dependencies = [ "windows-sys 0.42.0", ] +[[package]] +name = "cmake" +version = "0.1.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db34956e100b30725f2eb215f90d4871051239535632f84fea3bc92722c66b7c" +dependencies = [ + "cc", +] + [[package]] name = "codespan-reporting" version = "0.11.1" @@ -666,6 +768,15 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "connection-string" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97faeec45f49581c458f8bf81992c5e3ec17d82cda99f59d3cea14eff62698d" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "console" version = "0.15.5" @@ -704,12 +815,22 @@ version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d7d6ab3c3a2282db210df5f02c4dab6e0a7057af0fb7ebd4070f30fe05c0ddb" dependencies = [ - "getrandom", + "getrandom 0.2.8", "once_cell", "proc-macro-hack", "tiny-keccak", ] +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.3" @@ -725,6 +846,15 @@ dependencies = [ "libc", ] +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + [[package]] name = "criterion" version = "0.4.0" @@ -761,6 +891,20 @@ dependencies = [ "itertools", ] +[[package]] +name = "crossbeam" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2801af0d36612ae591caa9568261fddce32ce6e08a7275ea334a06a4ad021a2c" +dependencies = [ + "cfg-if", + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-epoch", + "crossbeam-queue", + "crossbeam-utils", +] + [[package]] name = "crossbeam-channel" version = "0.5.7" @@ -795,6 +939,16 @@ dependencies = [ "scopeguard", ] +[[package]] +name = "crossbeam-queue" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + [[package]] name = "crossbeam-utils" version = "0.8.15" @@ -895,6 +1049,17 @@ dependencies = [ "syn 2.0.2", ] +[[package]] +name = "derive_utils" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7590f99468735a318c254ca9158d0c065aa9b5312896b5a043b5e39bc96f5fa2" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "diff" version = "0.1.13" @@ -943,6 +1108,70 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +[[package]] +name = "encoding" +version = "0.2.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec" +dependencies = [ + "encoding-index-japanese", + "encoding-index-korean", + "encoding-index-simpchinese", + "encoding-index-singlebyte", + "encoding-index-tradchinese", +] + +[[package]] +name = "encoding-index-japanese" +version = "1.20141219.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04e8b2ff42e9a05335dbf8b5c6f7567e5591d0d916ccef4e0b1710d32a0d0c91" +dependencies = [ + "encoding_index_tests", +] + +[[package]] +name = "encoding-index-korean" +version = "1.20141219.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dc33fb8e6bcba213fe2f14275f0963fd16f0a02c878e3095ecfdf5bee529d81" +dependencies = [ + "encoding_index_tests", +] + +[[package]] +name = "encoding-index-simpchinese" +version = "1.20141219.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d87a7194909b9118fc707194baa434a4e3b0fb6a5a757c73c3adb07aa25031f7" +dependencies = [ + "encoding_index_tests", +] + +[[package]] +name = "encoding-index-singlebyte" +version = "1.20141219.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a" +dependencies = [ + "encoding_index_tests", +] + +[[package]] +name = "encoding-index-tradchinese" +version = "1.20141219.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18" +dependencies = [ + "encoding_index_tests", +] + +[[package]] +name = "encoding_index_tests" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" + [[package]] name = "enum-as-inner" version = "0.5.1" @@ -955,6 +1184,26 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "enumflags2" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e75d4cd21b95383444831539909fbb14b9dc3fdceb2a6f5d36577329a1f55ccb" +dependencies = [ + "enumflags2_derive", +] + +[[package]] +name = "enumflags2_derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58dc3c5e468259f19f2d46304a6b28f1c3d034442e14b322d2b850e36f6d5ae" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "env_logger" version = "0.10.0" @@ -1032,12 +1281,111 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "flate2" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" +dependencies = [ + "crc32fast", + "libz-sys", + "miniz_oxide", +] + [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "frunk" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89c703bf50009f383a0873845357cc400a95fc535f836feddfe015d7df6e1e0" +dependencies = [ + "frunk_core", + "frunk_derives", + "frunk_proc_macros", +] + +[[package]] +name = "frunk_core" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a446d01a558301dca28ef43222864a9fa2bd9a2e71370f769d5d5d5ec9f3537" + +[[package]] +name = "frunk_derives" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b83164912bb4c97cfe0772913c7af7387ee2e00cb6d4636fb65a35b3d0c8f173" +dependencies = [ + "frunk_proc_macro_helpers", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "frunk_proc_macro_helpers" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "015425591bbeb0f5b8a75593340f1789af428e9f887a4f1e36c0c471f067ef50" +dependencies = [ + "frunk_core", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "frunk_proc_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea01524f285deab48affffb342b97f186e657b119c3f1821ac531780e0fbfae0" +dependencies = [ + "frunk_core", + "frunk_proc_macros_impl", + "proc-macro-hack", +] + +[[package]] +name = "frunk_proc_macros_impl" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a802d974cc18ee7fe1a7868fc9ce31086294fd96ba62f8da64ecb44e92a2653" +dependencies = [ + "frunk_core", + "frunk_proc_macro_helpers", + "proc-macro-hack", + "quote", + "syn 1.0.109", +] + [[package]] name = "fsevent-sys" version = "4.1.0" @@ -1047,6 +1395,12 @@ dependencies = [ "libc", ] +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + [[package]] name = "futures-channel" version = "0.3.27" @@ -1063,6 +1417,12 @@ version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd" +[[package]] +name = "futures-io" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89d422fa3cbe3b40dca574ab087abb5bc98258ea57eea3fd6f1fa7162c778b91" + [[package]] name = "futures-macro" version = "0.3.27" @@ -1093,9 +1453,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab" dependencies = [ "futures-core", + "futures-io", "futures-macro", "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", "slab", @@ -1120,6 +1482,17 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + [[package]] name = "getrandom" version = "0.2.8" @@ -1137,6 +1510,12 @@ version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "globset" version = "0.4.10" @@ -1276,6 +1655,16 @@ dependencies = [ "cxx-build", ] +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "indenter" version = "0.3.3" @@ -1343,6 +1732,17 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "io-enum" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4b0d47a958cb166282b4dc4840a35783e861c2b39080af846e6481ebe145eee" +dependencies = [ + "derive_utils", + "quote", + "syn 1.0.109", +] + [[package]] name = "io-lifetimes" version = "1.0.8" @@ -1445,6 +1845,21 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "lexical" +version = "6.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7aefb36fd43fef7003334742cbf77b243fcd36418a1d1bdd480d613a67968f6" +dependencies = [ + "lexical-core", +] + [[package]] name = "lexical-core" version = "0.8.5" @@ -1526,6 +1941,16 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "libloading" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +dependencies = [ + "cfg-if", + "winapi", +] + [[package]] name = "libm" version = "0.2.6" @@ -1543,6 +1968,17 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "libz-sys" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + [[package]] name = "link-cplusplus" version = "1.0.8" @@ -1583,6 +2019,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "lru" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6e8aaa3f231bb4bd57b84b2d5dc3ae7f350265df8aa96492e0bc394a1571909" +dependencies = [ + "hashbrown 0.12.3", +] + [[package]] name = "md-5" version = "0.10.5" @@ -1592,6 +2037,12 @@ dependencies = [ "digest", ] +[[package]] +name = "md5" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e6bcd6433cff03a4bfc3d9834d504467db1f1cf6d0ea765d37d330249ed629d" + [[package]] name = "mdbook" version = "0.4.28" @@ -1664,30 +2115,120 @@ dependencies = [ ] [[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - -[[package]] -name = "miniz_oxide" -version = "0.6.2" +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" +dependencies = [ + "libc", + "log", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys 0.45.0", +] + +[[package]] +name = "mysql" +version = "23.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f11339ca5c251941805d51362a07823605a80586ced92914ab7de84fba813f" +dependencies = [ + "bufstream", + "bytes", + "crossbeam", + "flate2", + "io-enum", + "libc", + "lru", + "mysql_common", + "named_pipe", + "native-tls", + "once_cell", + "pem", + "percent-encoding", + "serde", + "serde_json", + "socket2", + "twox-hash", + "url", +] + +[[package]] +name = "mysql_common" +version = "0.29.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9006c95034ccf7b903d955f210469119f6c3477fc9c9e7a7845ce38a3e665c2a" +dependencies = [ + "base64", + "bigdecimal", + "bindgen", + "bitflags", + "bitvec", + "byteorder", + "bytes", + "cc", + "cmake", + "crc32fast", + "flate2", + "frunk", + "lazy_static", + "lexical", + "num-bigint", + "num-traits", + "rand 0.8.5", + "regex", + "rust_decimal", + "saturating", + "serde", + "serde_json", + "sha1", + "sha2", + "smallvec", + "subprocess", + "thiserror", + "time 0.3.20", + "uuid", +] + +[[package]] +name = "named_pipe" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +checksum = "ad9c443cce91fc3e12f017290db75dde490d685cdaaf508d7159d7cf41f0eb2b" dependencies = [ - "adler", + "winapi", ] [[package]] -name = "mio" -version = "0.8.6" +name = "native-tls" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" dependencies = [ + "lazy_static", "libc", "log", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.45.0", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", ] [[package]] @@ -1836,6 +2377,51 @@ dependencies = [ "winapi", ] +[[package]] +name = "openssl" +version = "0.10.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8b277f87dacc05a6b709965d1cbafac4649d6ce9f3ce9ceb88508b5666dfec9" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a95792af3c4e0153c3914df2261bedd30a98476f94dc892b67dfe1d89d433a04" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "os_str_bytes" version = "6.4.1" @@ -1880,6 +2466,21 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + +[[package]] +name = "pem" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" +dependencies = [ + "base64", +] + [[package]] name = "percent-encoding" version = "2.2.0" @@ -1930,6 +2531,19 @@ dependencies = [ "sha2", ] +[[package]] +name = "pg_bigdecimal" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9855a94c74528af62c0ea236577af5e601263c1c404a6ac939b07c97c8e0216" +dependencies = [ + "bigdecimal", + "byteorder", + "bytes", + "num", + "postgres", +] + [[package]] name = "phf" version = "0.11.1" @@ -2021,7 +2635,7 @@ dependencies = [ "hmac", "md-5", "memchr", - "rand", + "rand 0.8.5", "sha2", "stringprep", ] @@ -2043,6 +2657,12 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "pretty-hex" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6fa0831dd7cc608c38a5e323422a0077678fa5744aa2be4ad91c4ece8eec8d5" + [[package]] name = "pretty_assertions" version = "1.3.0" @@ -2128,7 +2748,9 @@ dependencies = [ "itertools", "lazy_static", "log", + "mysql", "once_cell", + "pg_bigdecimal", "postgres", "pretty_assertions", "regex", @@ -2141,6 +2763,9 @@ dependencies = [ "sqlparser", "strum", "strum_macros", + "tiberius", + "tokio", + "tokio-util", ] [[package]] @@ -2332,6 +2957,25 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", +] + [[package]] name = "rand" version = "0.8.5" @@ -2339,8 +2983,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha", - "rand_core", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", ] [[package]] @@ -2350,7 +3004,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", ] [[package]] @@ -2359,7 +3022,16 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.8", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", ] [[package]] @@ -2477,7 +3149,7 @@ dependencies = [ "byteorder", "bytes", "num-traits", - "rand", + "rand 0.8.5", "rkyv", "serde", "serde_json", @@ -2489,6 +3161,12 @@ version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustix" version = "0.36.10" @@ -2557,6 +3235,21 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "saturating" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ece8e78b2f38ec51c51f5d475df0a7187ba5111b2a28bdc761ee05b075d40a71" + +[[package]] +name = "schannel" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" +dependencies = [ + "windows-sys 0.42.0", +] + [[package]] name = "scoped-tls" version = "1.0.1" @@ -2581,6 +3274,29 @@ version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" +[[package]] +name = "security-framework" +version = "2.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "1.0.17" @@ -2634,6 +3350,17 @@ dependencies = [ "unsafe-libyaml", ] +[[package]] +name = "sha1" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sha2" version = "0.10.6" @@ -2660,6 +3387,15 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + [[package]] name = "simdutf8" version = "0.1.4" @@ -2781,6 +3517,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "subprocess" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c2e86926081dda636c546d8c5e641661049d7562a68f5488be4a1f7f66f6086" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "subtle" version = "2.4.1" @@ -2809,6 +3555,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + [[package]] name = "target-lexicon" version = "0.12.6" @@ -2883,6 +3635,34 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tiberius" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf8ecd8428f31011260ede6027930f452f45d4e3c4e9e7bf9b0231398772e9ce" +dependencies = [ + "async-native-tls", + "async-trait", + "asynchronous-codec", + "bigdecimal", + "byteorder", + "bytes", + "connection-string", + "encoding", + "enumflags2", + "futures-util", + "num-traits", + "once_cell", + "pin-project-lite", + "pretty-hex", + "thiserror", + "tokio", + "tokio-util", + "tracing", + "uuid", + "winauth", +] + [[package]] name = "time" version = "0.1.45" @@ -2894,6 +3674,31 @@ dependencies = [ "winapi", ] +[[package]] +name = "time" +version = "0.3.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" +dependencies = [ + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" + +[[package]] +name = "time-macros" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" +dependencies = [ + "time-core", +] + [[package]] name = "tiny-keccak" version = "2.0.2" @@ -2939,11 +3744,26 @@ dependencies = [ "libc", "memchr", "mio", + "num_cpus", + "parking_lot", "pin-project-lite", + "signal-hook-registry", "socket2", + "tokio-macros", "windows-sys 0.45.0", ] +[[package]] +name = "tokio-macros" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "tokio-postgres" version = "0.7.7" @@ -2976,6 +3796,7 @@ checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" dependencies = [ "bytes", "futures-core", + "futures-io", "futures-sink", "pin-project-lite", "tokio", @@ -3004,10 +3825,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", + "log", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "tracing-core" version = "0.1.30" @@ -3039,6 +3873,17 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "twox-hash" +version = "1.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" +dependencies = [ + "cfg-if", + "rand 0.8.5", + "static_assertions", +] + [[package]] name = "typenum" version = "1.16.0" @@ -3114,6 +3959,23 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad2024452afd3874bf539695e04af6732ba06517424dbf958fdb16a01f3bef6c" +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "uuid" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1674845326ee10d37ca60470760d4288a6f80f304007d92e5c53bab78c9cfd79" + [[package]] name = "valuable" version = "0.1.0" @@ -3148,6 +4010,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + [[package]] name = "wasi" version = "0.10.0+wasi-snapshot-preview1" @@ -3291,6 +4159,19 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "winauth" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f820cd208ce9c6b050812dc2d724ba98c6c1e9db5ce9b3f58d925ae5723a5e6" +dependencies = [ + "bitflags", + "byteorder", + "md5", + "rand 0.7.3", + "winapi", +] + [[package]] name = "windows-sys" version = "0.42.0" @@ -3372,6 +4253,15 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + [[package]] name = "yaml-rust" version = "0.4.5" diff --git a/prql-compiler/tests/integration-vendors/connection.rs b/prql-compiler/tests/integration-vendors/connection.rs index ae409574888e..1373e03590be 100644 --- a/prql-compiler/tests/integration-vendors/connection.rs +++ b/prql-compiler/tests/integration-vendors/connection.rs @@ -5,8 +5,8 @@ use mysql::prelude::Queryable; use mysql::Value; use pg_bigdecimal::PgNumeric; use postgres::types::Type; -use tiberius::*; use tiberius::numeric::BigDecimal; +use tiberius::*; use tokio::net::TcpStream; use tokio::runtime::Runtime; use tokio_util::compat::Compat; @@ -165,7 +165,7 @@ impl DBConnection for MysqlConnection { for v in row.unwrap() { let value = match v { Value::NULL => "".to_string(), - Value::Bytes(v) => String::from_utf8(v).unwrap_or("BLOB".to_string()), + Value::Bytes(v) => String::from_utf8(v).unwrap_or_else(|_| "BLOB".to_string()), Value::Int(v) => v.to_string(), Value::UInt(v) => v.to_string(), Value::Float(v) => v.to_string(), @@ -198,22 +198,21 @@ impl MssqlConnection { async fn query(&mut self, sql: &str) -> Vec { let mut stream = self.0.query(sql, &[]).await.unwrap(); let mut vec = vec![]; - let cols_option = (&mut stream).columns().await.unwrap(); + let cols_option = stream.columns().await.unwrap(); if cols_option.is_none() { return vec![]; } let cols = cols_option.unwrap().to_vec(); for row in stream.into_first_result().await.unwrap() { let mut columns = vec![]; - for i in 0..row.len() { - let col = &cols[i]; + for (i, col) in cols.iter().enumerate() { let value = match col.column_type() { ColumnType::Null => "".to_string(), ColumnType::Bit => String::from(row.get::<&str, usize>(i).unwrap()), ColumnType::Intn | ColumnType::Int4 => row .get::(i) .map(|i| i.to_string()) - .unwrap_or("".to_string()), + .unwrap_or_else(|| "".to_string()), ColumnType::Numericn => row.get::(i).unwrap().to_string(), ColumnType::BigVarChar => String::from(row.get::<&str, usize>(i).unwrap()), typ => unimplemented!("mssql type {:?}", typ), diff --git a/prql-compiler/tests/integration-vendors/main.rs b/prql-compiler/tests/integration-vendors/main.rs index 8bf7f45641bd..3ddb74485b2e 100644 --- a/prql-compiler/tests/integration-vendors/main.rs +++ b/prql-compiler/tests/integration-vendors/main.rs @@ -8,8 +8,8 @@ mod tests { use tokio::runtime::Runtime; use tokio_util::compat::{Compat, TokioAsyncWriteCompatExt}; - use prql_compiler::Options; use prql_compiler::sql::Dialect; + use prql_compiler::Options; use prql_compiler::Target::Sql; use crate::connection::*; @@ -17,7 +17,7 @@ mod tests { #[ignore] #[test] fn test_vendors() { - [5432, 3306, 1433/*, 50000*/].iter().for_each(|port| { + [5432, 3306, 1433 /*, 50000*/].iter().for_each(|port| { if !is_port_open(*port) { panic!("No database is listening on port {}", port); } @@ -59,7 +59,7 @@ mod tests { fn run_tests_for_connection(con: &mut dyn DBConnection, runtime: &Runtime) { let setup = include_str!("setup.sql"); setup - .split(";") + .split(';') .map(|s| s.trim()) .filter(|s| !s.is_empty()) .for_each(|s| { @@ -68,8 +68,7 @@ mod tests { .replace(" boolean ", " bit ") .replace("TRUE", "1") .replace("FALSE", "0"), - Dialect::MySql => s - .replace("\"", "`"), + Dialect::MySql => s.replace('"', "`"), _ => s.to_string(), }; con.run_query(sql.as_str(), runtime); @@ -112,7 +111,7 @@ mod tests { let rows = tests[1] .lines() .map(|l| { - l.split(",") + l.split(',') .map(|s| s.trim()) .filter(|s| !s.is_empty()) .map(|s| s.to_string()) @@ -129,9 +128,9 @@ mod tests { fn replace_booleans(rows: &mut Vec) { for row in rows { for col in row { - if col == &"true" { + if col == "true" { *col = "1".to_string(); - } else if col == &"false" { + } else if col == "false" { *col = "0".to_string(); } } @@ -144,9 +143,7 @@ mod tests { stream.shutdown(std::net::Shutdown::Both).unwrap_or(()); true } - Err(_) => { - false - } + Err(_) => false, } } } From cf70d1674e0cc148f8955a7b9a837eb74899251b Mon Sep 17 00:00:00 2001 From: Jelenkee Date: Wed, 22 Mar 2023 18:31:01 +0100 Subject: [PATCH 10/29] -fixed linting --- .github/workflows/integration-test.yaml | 1 - .../integration-vendors/docker-compose.yml | 42 +++++++++---------- .../tests/integration-vendors/setup.sql | 2 +- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index adc99f75f23e..bc7557e7a4ec 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -25,4 +25,3 @@ jobs: with: resource: "tcp:5432 tcp:3306 tcp:1433" - run: cargo test test_vendors -- --ignored - diff --git a/prql-compiler/tests/integration-vendors/docker-compose.yml b/prql-compiler/tests/integration-vendors/docker-compose.yml index ab26a5bbf9f7..79adceaa96ca 100644 --- a/prql-compiler/tests/integration-vendors/docker-compose.yml +++ b/prql-compiler/tests/integration-vendors/docker-compose.yml @@ -1,41 +1,39 @@ -version: '3' +version: "3" services: postgres: - image: 'postgres:15-alpine' + image: "postgres:15-alpine" ports: - - '5432:5432' + - "5432:5432" environment: POSTGRES_DB: dummy POSTGRES_USER: root POSTGRES_PASSWORD: root mysql: - image: 'mysql:8' + image: "mysql:8" ports: - - '3306:3306' + - "3306:3306" environment: MYSQL_DATABASE: dummy MYSQL_ROOT_PASSWORD: root -# db2: -# image: 'icr.io/db2_community/db2' -# ports: -# - '50000:50000' -# environment: -# LICENSE: accept -# DBNAME: dummy -# DB2INSTANCE: db2 -# DB2INST1_PASSWORD: root -# BLU: false -# TO_CREATE_SAMPLEDB: false -# REPODB: false -# IS_OSXFS: false + # db2: + # image: 'icr.io/db2_community/db2' + # ports: + # - '50000:50000' + # environment: + # LICENSE: accept + # DBNAME: dummy + # DB2INSTANCE: db2 + # DB2INST1_PASSWORD: root + # BLU: false + # TO_CREATE_SAMPLEDB: false + # REPODB: false + # IS_OSXFS: false mssql: - image: 'mcr.microsoft.com/mssql/server:2022-latest' + image: "mcr.microsoft.com/mssql/server:2022-latest" ports: - - '1433:1433' + - "1433:1433" environment: ACCEPT_EULA: Y MSSQL_PID: Developer MSSQL_SA_PASSWORD: Wordpass123## - - diff --git a/prql-compiler/tests/integration-vendors/setup.sql b/prql-compiler/tests/integration-vendors/setup.sql index 091362e0c0e4..7c17dab75079 100644 --- a/prql-compiler/tests/integration-vendors/setup.sql +++ b/prql-compiler/tests/integration-vendors/setup.sql @@ -58,4 +58,4 @@ INSERT INTO "Upper" id ) VALUES -(999); \ No newline at end of file +(999); From 2f221ee3c2cd25d4fa29fcd3927c36782da1fd59 Mon Sep 17 00:00:00 2001 From: Jelenkee Date: Wed, 22 Mar 2023 19:05:12 +0100 Subject: [PATCH 11/29] -fixed workflow yaml --- .github/workflows/integration-test.yaml | 3 ++- prql-compiler/tests/integration-vendors/main.rs | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index bc7557e7a4ec..964f53892677 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -21,7 +21,8 @@ jobs: run: docker-compose up -d working-directory: ./prql-compiler/tests/integration-vendors - name: Wait for database - uses: ifaxity/wait-on-action + uses: ifaxity/wait-on-action@1 with: resource: "tcp:5432 tcp:3306 tcp:1433" + timeout: 60000 - run: cargo test test_vendors -- --ignored diff --git a/prql-compiler/tests/integration-vendors/main.rs b/prql-compiler/tests/integration-vendors/main.rs index 3ddb74485b2e..a3c8d1680e1e 100644 --- a/prql-compiler/tests/integration-vendors/main.rs +++ b/prql-compiler/tests/integration-vendors/main.rs @@ -1,3 +1,5 @@ +#![cfg(not(any(target_family = "windows", target_family = "wasm")))] + mod connection; #[cfg(test)] From f347697b4cfc06ef9dbfa049eea686773cf22d4d Mon Sep 17 00:00:00 2001 From: Jelenkee Date: Wed, 22 Mar 2023 19:06:53 +0100 Subject: [PATCH 12/29] -fixed workflow yaml again --- .github/workflows/integration-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index 964f53892677..9350bd7054bf 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -21,7 +21,7 @@ jobs: run: docker-compose up -d working-directory: ./prql-compiler/tests/integration-vendors - name: Wait for database - uses: ifaxity/wait-on-action@1 + uses: ifaxity/wait-on-action@v1 with: resource: "tcp:5432 tcp:3306 tcp:1433" timeout: 60000 From 3fbb495ce42929d00ddca1b18dba78ac5f871a45 Mon Sep 17 00:00:00 2001 From: Jelenkee Date: Fri, 24 Mar 2023 18:49:59 +0100 Subject: [PATCH 13/29] -added more testcases --- .../tests/integration-vendors/testcases.txt | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/prql-compiler/tests/integration-vendors/testcases.txt b/prql-compiler/tests/integration-vendors/testcases.txt index 9bcd913e8794..6a3ec7085d9d 100644 --- a/prql-compiler/tests/integration-vendors/testcases.txt +++ b/prql-compiler/tests/integration-vendors/testcases.txt @@ -87,3 +87,41 @@ from Upper select id --- 999 + +### + +func distinct rel -> (from t = _param.rel | group [t.*] (take 1)) + +from_text format:json '{ "columns": ["a"], "data": [[1], [2], [2], [3]] }' +distinct +remove (from_text format:json '{ "columns": ["a"], "data": [[1], [2]] }') +--- +3 + +### + +from cars +sort price +select price +take 2..4 +--- +60000 +90000 +200000 + +### + +from_text format:json '[{"n": 1 }]' +select n = n - 2 +loop ( + filter n<4 + select n = n+1 +) +select n = n * 2 +--- +-2 +0 +2 +4 +6 +8 From 7264d69d20b605de7d6e1b0fe7d12bbe60c05aab Mon Sep 17 00:00:00 2001 From: Jelenkee <59470612+Jelenkee@users.noreply.github.com> Date: Sat, 25 Mar 2023 10:25:52 +0100 Subject: [PATCH 14/29] Apply suggestions from code review Co-authored-by: eitsupi <50911393+eitsupi@users.noreply.github.com> --- .github/workflows/integration-test.yaml | 2 +- .../tests/integration-vendors/docker-compose.yml | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index 9350bd7054bf..c258afb57839 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -18,7 +18,7 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - name: Run docker compose - run: docker-compose up -d + run: docker compose up -d working-directory: ./prql-compiler/tests/integration-vendors - name: Wait for database uses: ifaxity/wait-on-action@v1 diff --git a/prql-compiler/tests/integration-vendors/docker-compose.yml b/prql-compiler/tests/integration-vendors/docker-compose.yml index 79adceaa96ca..005a0a6c493b 100644 --- a/prql-compiler/tests/integration-vendors/docker-compose.yml +++ b/prql-compiler/tests/integration-vendors/docker-compose.yml @@ -1,8 +1,6 @@ -version: "3" - services: postgres: - image: "postgres:15-alpine" + image: "postgres:alpine" ports: - "5432:5432" environment: @@ -10,7 +8,7 @@ services: POSTGRES_USER: root POSTGRES_PASSWORD: root mysql: - image: "mysql:8" + image: "mysql:debian" ports: - "3306:3306" environment: @@ -30,7 +28,7 @@ services: # REPODB: false # IS_OSXFS: false mssql: - image: "mcr.microsoft.com/mssql/server:2022-latest" + image: "mcr.microsoft.com/mssql/server:latest" ports: - "1433:1433" environment: From cc4a623b9d9cf4b29cc1aeef58093ba4c436056f Mon Sep 17 00:00:00 2001 From: Jelenkee Date: Sat, 25 Mar 2023 12:23:30 +0100 Subject: [PATCH 15/29] -refactored test workflow --- .github/workflows/integration-test.yaml | 28 ------------------- .github/workflows/test-all.yaml | 3 -- .github/workflows/test-rust.yaml | 8 ++++++ Taskfile.yml | 5 ---- .../connection.rs | 0 .../docker-compose.yml | 0 .../main.rs | 26 +++++++++++++---- .../setup.sql | 0 .../testcases.txt | 0 9 files changed, 28 insertions(+), 42 deletions(-) delete mode 100644 .github/workflows/integration-test.yaml rename prql-compiler/tests/{integration-vendors => integration-rdbms}/connection.rs (100%) rename prql-compiler/tests/{integration-vendors => integration-rdbms}/docker-compose.yml (100%) rename prql-compiler/tests/{integration-vendors => integration-rdbms}/main.rs (87%) rename prql-compiler/tests/{integration-vendors => integration-rdbms}/setup.sql (100%) rename prql-compiler/tests/{integration-vendors => integration-rdbms}/testcases.txt (100%) diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml deleted file mode 100644 index c258afb57839..000000000000 --- a/.github/workflows/integration-test.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: integration-test - -on: - pull_request: - paths: - - "prql-compiler/**" - - ".github/workflows/integration-test.yaml" - workflow_call: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-integration - cancel-in-progress: true - -jobs: - test: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - name: Run docker compose - run: docker compose up -d - working-directory: ./prql-compiler/tests/integration-vendors - - name: Wait for database - uses: ifaxity/wait-on-action@v1 - with: - resource: "tcp:5432 tcp:3306 tcp:1433" - timeout: 60000 - - run: cargo test test_vendors -- --ignored diff --git a/.github/workflows/test-all.yaml b/.github/workflows/test-all.yaml index 8d103017a418..b10b56e006d5 100644 --- a/.github/workflows/test-all.yaml +++ b/.github/workflows/test-all.yaml @@ -68,9 +68,6 @@ jobs: test-taskfile: uses: ./.github/workflows/test-taskfile.yaml - integration-test: - uses: ./.github/workflows/integration-test.yaml - measure-code-cov: # Currently disabled due to https://github.com/actions-rs/tarpaulin/issues/21 if: false diff --git a/.github/workflows/test-rust.yaml b/.github/workflows/test-rust.yaml index 2fdd27850a57..631b1f81b85a 100644 --- a/.github/workflows/test-rust.yaml +++ b/.github/workflows/test-rust.yaml @@ -54,6 +54,14 @@ jobs: with: command: test args: ${{ inputs.target_option }} --no-run --locked + - name: Run docker compose + run: docker compose up -d + working-directory: ./prql-compiler/tests/integration-rdbms + - name: Wait for database + uses: ifaxity/wait-on-action@v1 + with: + resource: "tcp:5432 tcp:3306 tcp:1433" + timeout: 60000 # Only check unreferenced snapshots on the default target tests on ubuntu # # (Maybe there's a nicer approach where we can parameterize one step diff --git a/Taskfile.yml b/Taskfile.yml index 3e53d0e9e10a..7fcc9866ab2e 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -200,11 +200,6 @@ tasks: # We build the book too, because that acts as a test - cd web/book && mdbook build - test-integration: - desc: Test generated SQL for different vendors - cmds: - - cargo test test_vendors -- --ignored - test-rust-fast: desc: Test prql-compiler's unit tests. summary: | diff --git a/prql-compiler/tests/integration-vendors/connection.rs b/prql-compiler/tests/integration-rdbms/connection.rs similarity index 100% rename from prql-compiler/tests/integration-vendors/connection.rs rename to prql-compiler/tests/integration-rdbms/connection.rs diff --git a/prql-compiler/tests/integration-vendors/docker-compose.yml b/prql-compiler/tests/integration-rdbms/docker-compose.yml similarity index 100% rename from prql-compiler/tests/integration-vendors/docker-compose.yml rename to prql-compiler/tests/integration-rdbms/docker-compose.yml diff --git a/prql-compiler/tests/integration-vendors/main.rs b/prql-compiler/tests/integration-rdbms/main.rs similarity index 87% rename from prql-compiler/tests/integration-vendors/main.rs rename to prql-compiler/tests/integration-rdbms/main.rs index a3c8d1680e1e..db15f11c1735 100644 --- a/prql-compiler/tests/integration-vendors/main.rs +++ b/prql-compiler/tests/integration-rdbms/main.rs @@ -4,6 +4,9 @@ mod connection; #[cfg(test)] mod tests { + use std::env; + + use insta::assert_display_snapshot; use postgres::NoTls; use tiberius::{AuthMethod, Client, Config}; use tokio::net::TcpStream; @@ -16,14 +19,24 @@ mod tests { use crate::connection::*; - #[ignore] #[test] - fn test_vendors() { - [5432, 3306, 1433 /*, 50000*/].iter().for_each(|port| { - if !is_port_open(*port) { - panic!("No database is listening on port {}", port); + fn test_rdbms() { + for port in [5432u16, 3306, 1433 /*, 50000*/] { + // test is skipped locally when DB is not listening + // in CI it fails + if !is_port_open(port) { + match env::var("CI") { + Ok(v) if &v == "true" => { + // CI + panic!("No database is listening on port {}", port); + } + Ok(_) | Err(_) => { + // locally + return; + } + } } - }); + } let runtime = Runtime::new().unwrap(); let mut duck = DuckDBConnection(duckdb::Connection::open_in_memory().unwrap()); let mut sqlite = SQLiteConnection(rusqlite::Connection::open_in_memory().unwrap()); @@ -88,6 +101,7 @@ mod tests { "Rows do not match for {}", con.get_dialect() ); + assert_display_snapshot!(format!("{:?}", actual_rows), con.get_dialect().to_string()); } } diff --git a/prql-compiler/tests/integration-vendors/setup.sql b/prql-compiler/tests/integration-rdbms/setup.sql similarity index 100% rename from prql-compiler/tests/integration-vendors/setup.sql rename to prql-compiler/tests/integration-rdbms/setup.sql diff --git a/prql-compiler/tests/integration-vendors/testcases.txt b/prql-compiler/tests/integration-rdbms/testcases.txt similarity index 100% rename from prql-compiler/tests/integration-vendors/testcases.txt rename to prql-compiler/tests/integration-rdbms/testcases.txt From b35f92eebaf5973f9f16c6098fde456a60e17912 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Sat, 25 Mar 2023 15:16:52 -0700 Subject: [PATCH 16/29] Fix order of args to `assert_display_snapshot` Sorry for the incorrect suggestion prior! --- prql-compiler/tests/integration-rdbms/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/prql-compiler/tests/integration-rdbms/main.rs b/prql-compiler/tests/integration-rdbms/main.rs index db15f11c1735..c7eb57ede4a4 100644 --- a/prql-compiler/tests/integration-rdbms/main.rs +++ b/prql-compiler/tests/integration-rdbms/main.rs @@ -101,7 +101,8 @@ mod tests { "Rows do not match for {}", con.get_dialect() ); - assert_display_snapshot!(format!("{:?}", actual_rows), con.get_dialect().to_string()); + + assert_display_snapshot!(con.get_dialect().to_string(), format!("{:?}", actual_rows)); } } From f7ef223e40ed4f452737dee02f81db3d5bcd761d Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Sat, 25 Mar 2023 15:18:15 -0700 Subject: [PATCH 17/29] Specify platform for mysql image --- prql-compiler/tests/integration-rdbms/docker-compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/prql-compiler/tests/integration-rdbms/docker-compose.yml b/prql-compiler/tests/integration-rdbms/docker-compose.yml index 005a0a6c493b..e2d09d165cd7 100644 --- a/prql-compiler/tests/integration-rdbms/docker-compose.yml +++ b/prql-compiler/tests/integration-rdbms/docker-compose.yml @@ -8,6 +8,8 @@ services: POSTGRES_USER: root POSTGRES_PASSWORD: root mysql: + # No arm64 image available; remove when one does become available + platform: linux/amd64 image: "mysql:debian" ports: - "3306:3306" From ba803d79748cb51189fbc0e7581692b21c475c92 Mon Sep 17 00:00:00 2001 From: Jelenkee Date: Sun, 26 Mar 2023 19:29:10 +0200 Subject: [PATCH 18/29] -added csv import --- Cargo.lock | 2 + prql-compiler/Cargo.toml | 3 +- .../tests/integration-rdbms/conf/my.cnf | 2 + .../tests/integration-rdbms/connection.rs | 101 +++++++++++++++++- .../integration-rdbms/docker-compose.yml | 8 ++ prql-compiler/tests/integration-rdbms/main.rs | 14 ++- .../tests/integration/data/chinook/schema.sql | 32 ++++-- 7 files changed, 142 insertions(+), 20 deletions(-) create mode 100644 prql-compiler/tests/integration-rdbms/conf/my.cnf diff --git a/Cargo.lock b/Cargo.lock index ec0b58454e61..c34374006c2d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3656,6 +3656,7 @@ dependencies = [ "pin-project-lite", "pretty-hex", "thiserror", + "time 0.3.20", "tokio", "tokio-util", "tracing", @@ -3680,6 +3681,7 @@ version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" dependencies = [ + "serde", "time-core", "time-macros", ] diff --git a/prql-compiler/Cargo.toml b/prql-compiler/Cargo.toml index 99c7b19b2fb6..18aebf8bd139 100644 --- a/prql-compiler/Cargo.toml +++ b/prql-compiler/Cargo.toml @@ -49,12 +49,13 @@ chrono = {version = "0.4", features = [], default-features = false} criterion = "0.4.0" postgres = "0.19.3" mysql = "23" -tiberius = {version = "0.12", features = ["sql-browser-tokio", "bigdecimal"]} +tiberius = {version = "0.12", features = ["sql-browser-tokio", "bigdecimal", "time"]} tokio = {version = "1", features = ["full"]} tokio-util = { version = "0.7", features = ["compat"] } pretty_assertions = "1.3.0" rusqlite = {version = "0.28.0", features = ["bundled", "csvtab"]} pg_bigdecimal = "0.1" +csv = "1.2" # Re-enable on windows when duckdb supports it # https://github.com/wangfenjin/duckdb-rs/issues/62 diff --git a/prql-compiler/tests/integration-rdbms/conf/my.cnf b/prql-compiler/tests/integration-rdbms/conf/my.cnf new file mode 100644 index 000000000000..e53a503aca3c --- /dev/null +++ b/prql-compiler/tests/integration-rdbms/conf/my.cnf @@ -0,0 +1,2 @@ +[mysqld] +secure-file-priv= /tmp/chinook/ \ No newline at end of file diff --git a/prql-compiler/tests/integration-rdbms/connection.rs b/prql-compiler/tests/integration-rdbms/connection.rs index 1373e03590be..e27e29044886 100644 --- a/prql-compiler/tests/integration-rdbms/connection.rs +++ b/prql-compiler/tests/integration-rdbms/connection.rs @@ -1,12 +1,18 @@ +use std::env::{current_dir, join_paths}; +use std::fs::read_to_string; +use std::path::Path; use std::time::SystemTime; -use chrono::{DateTime, Utc}; +use chrono::{DateTime, TimeZone, Utc}; +use itertools::Itertools; use mysql::prelude::Queryable; use mysql::Value; use pg_bigdecimal::PgNumeric; use postgres::types::Type; use tiberius::numeric::BigDecimal; +use tiberius::time::time::PrimitiveDateTime; use tiberius::*; +use time::DateTime2; use tokio::net::TcpStream; use tokio::runtime::Runtime; use tokio_util::compat::Compat; @@ -28,6 +34,8 @@ pub struct MssqlConnection(pub tiberius::Client>); pub trait DBConnection { fn run_query(&mut self, sql: &str, runtime: &Runtime) -> Vec; + fn import_csv(&mut self, csv_name: &str, runtime: &Runtime); + fn get_dialect(&self) -> Dialect; } @@ -74,6 +82,24 @@ impl DBConnection for DuckDBConnection { vec } + fn import_csv(&mut self, csv_name: &str, runtime: &Runtime) { + let mut path = current_dir().unwrap(); + for p in [ + "tests", + "integration", + "data", + "chinook", + format!("{csv_name}.csv").as_str(), + ] { + path.push(p); + } + let path = path.display().to_string().replace("\"", ""); + self.run_query( + &format!("COPY {csv_name} FROM '{path}' (AUTO_DETECT TRUE);"), + runtime, + ); + } + fn get_dialect(&self) -> Dialect { Dialect::DuckDb } @@ -108,6 +134,48 @@ impl DBConnection for SQLiteConnection { vec } + fn import_csv(&mut self, csv_name: &str, runtime: &Runtime) { + let mut path = current_dir().unwrap(); + for p in [ + "tests", + "integration", + "data", + "chinook", + format!("{csv_name}.csv").as_str(), + ] { + path.push(p); + } + let content = read_to_string(path.clone()).unwrap(); + let mut reader = csv::ReaderBuilder::new() + .has_headers(true) + .from_path(path) + .unwrap(); + let headers = reader + .headers() + .unwrap() + .iter() + .map(|s| s.to_string()) + .collect::>(); + for result in reader.records() { + let r = result.unwrap(); + let q = format!( + "INSERT INTO {csv_name} ({}) VALUES ({})", + headers.iter().join(","), + r.iter() + .map(|s| if true || s.contains(" ") { + format!("\"{s}\"") + } else { + s.to_string() + }) + .join(",") + ); + self.run_query(q.as_str(), runtime); + //println!("{:?}", q); + } + //self.run_query(&format!(".mode csv; .import --skip 1 '{path}' {csv_name};"), runtime); + //self.run_query(&format!(".mode csv;"), runtime); + } + fn get_dialect(&self) -> Dialect { Dialect::SQLite } @@ -125,14 +193,13 @@ impl DBConnection for PostgresConnection { &Type::BOOL => (row.get::(i)).to_string(), &Type::INT4 => (row.get::(i)).to_string(), &Type::INT8 => (row.get::(i)).to_string(), - &Type::TEXT => { + &Type::TEXT | &Type::VARCHAR | &Type::JSON | &Type::JSONB => { match row.try_get::(i) { Ok(v) => v, // handle null Err(_) => "".to_string(), } } - &Type::VARCHAR | &Type::JSON | &Type::JSONB => row.get::(i), &Type::FLOAT4 => (row.get::(i)).to_string(), &Type::FLOAT8 => (row.get::(i)).to_string(), &Type::NUMERIC => row.get::(i).n.unwrap().to_string(), @@ -150,6 +217,15 @@ impl DBConnection for PostgresConnection { vec } + fn import_csv(&mut self, csv_name: &str, runtime: &Runtime) { + self.run_query( + &format!( + "COPY {csv_name} FROM '/tmp/chinook/{csv_name}.csv' DELIMITER ',' CSV HEADER;" + ), + runtime, + ); + } + fn get_dialect(&self) -> Dialect { Dialect::PostgreSql } @@ -179,6 +255,10 @@ impl DBConnection for MysqlConnection { vec } + fn import_csv(&mut self, csv_name: &str, runtime: &Runtime) { + self.run_query(&format!("LOAD DATA INFILE '/tmp/chinook/{csv_name}.csv' INTO TABLE {csv_name} FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\n' IGNORE 1 ROWS;"), runtime); + } + fn get_dialect(&self) -> Dialect { Dialect::MySql } @@ -189,6 +269,10 @@ impl DBConnection for MssqlConnection { runtime.block_on(self.query(sql)) } + fn import_csv(&mut self, csv_name: &str, runtime: &Runtime) { + self.run_query(&format!("BULK INSERT {csv_name} FROM '/tmp/chinook/{csv_name}.csv' WITH (FIRSTROW = 2, FIELDTERMINATOR = ',', ROWTERMINATOR = '\n', TABLOCK, FORMAT = 'CSV', CODEPAGE = 'RAW');"), runtime); + } + fn get_dialect(&self) -> Dialect { Dialect::MsSql } @@ -213,8 +297,17 @@ impl MssqlConnection { .get::(i) .map(|i| i.to_string()) .unwrap_or_else(|| "".to_string()), + ColumnType::Floatn => row + .get::(i) + .map(|i| i.to_string()) + .unwrap_or_else(|| "".to_string()), ColumnType::Numericn => row.get::(i).unwrap().to_string(), - ColumnType::BigVarChar => String::from(row.get::<&str, usize>(i).unwrap()), + ColumnType::BigVarChar | ColumnType::NVarchar => { + String::from(row.get::<&str, usize>(i).unwrap_or("")) + } + ColumnType::Datetimen => { + row.get::(i).unwrap().to_string() + } typ => unimplemented!("mssql type {:?}", typ), }; columns.push(value); diff --git a/prql-compiler/tests/integration-rdbms/docker-compose.yml b/prql-compiler/tests/integration-rdbms/docker-compose.yml index e2d09d165cd7..600a26f410a7 100644 --- a/prql-compiler/tests/integration-rdbms/docker-compose.yml +++ b/prql-compiler/tests/integration-rdbms/docker-compose.yml @@ -7,6 +7,8 @@ services: POSTGRES_DB: dummy POSTGRES_USER: root POSTGRES_PASSWORD: root + volumes: &vol + - ../integration/data/chinook:/tmp/chinook mysql: # No arm64 image available; remove when one does become available platform: linux/amd64 @@ -16,6 +18,9 @@ services: environment: MYSQL_DATABASE: dummy MYSQL_ROOT_PASSWORD: root + volumes: + - ./conf:/etc/mysql/conf.d + - ../integration/data/chinook:/tmp/chinook # db2: # image: 'icr.io/db2_community/db2' # ports: @@ -37,3 +42,6 @@ services: ACCEPT_EULA: Y MSSQL_PID: Developer MSSQL_SA_PASSWORD: Wordpass123## + LC_ALL: en_US.UTF-8 + MSSQL_COLLATION: Latin1_General_100_CS_AI_SC_UTF8 + volumes: *vol diff --git a/prql-compiler/tests/integration-rdbms/main.rs b/prql-compiler/tests/integration-rdbms/main.rs index c7eb57ede4a4..e79b5847d36c 100644 --- a/prql-compiler/tests/integration-rdbms/main.rs +++ b/prql-compiler/tests/integration-rdbms/main.rs @@ -69,26 +69,30 @@ mod tests { for con in connections { run_tests_for_connection(con, &runtime); } + panic!("mdsad"); } fn run_tests_for_connection(con: &mut dyn DBConnection, runtime: &Runtime) { let setup = include_str!("setup.sql"); + let setup = include_str!("../integration/data/chinook/schema.sql"); + println!("DD:: {}", con.get_dialect()); setup .split(';') .map(|s| s.trim()) .filter(|s| !s.is_empty()) .for_each(|s| { let sql = match con.get_dialect() { - Dialect::MsSql => s - .replace(" boolean ", " bit ") - .replace("TRUE", "1") - .replace("FALSE", "0"), + Dialect::MsSql => s.replace("TIMESTAMP", "DATETIME"), Dialect::MySql => s.replace('"', "`"), _ => s.to_string(), }; con.run_query(sql.as_str(), runtime); }); - + con.import_csv("invoices", runtime); + let mut rr = con.run_query("select * from invoices;", runtime); + println!("{:?}", rr.first()); + assert_eq!(412, rr.len()); + return; for (prql, expected_rows) in get_test_cases() { let options = Options::default().with_target(Sql(Some(con.get_dialect()))); let sql = prql_compiler::compile(prql.as_str(), &options).unwrap(); diff --git a/prql-compiler/tests/integration/data/chinook/schema.sql b/prql-compiler/tests/integration/data/chinook/schema.sql index 9539b3ccde12..65a7dc219d94 100644 --- a/prql-compiler/tests/integration/data/chinook/schema.sql +++ b/prql-compiler/tests/integration/data/chinook/schema.sql @@ -1,11 +1,23 @@ -CREATE TABLE invoices(invoice_id INTEGER, customer_id INTEGER, invoice_date TIMESTAMP, billing_address VARCHAR, billing_city VARCHAR, billing_state VARCHAR, billing_country VARCHAR, billing_postal_code VARCHAR, total DOUBLE); -CREATE TABLE customers(customer_id INTEGER, first_name VARCHAR, last_name VARCHAR, company VARCHAR, address VARCHAR, city VARCHAR, state VARCHAR, country VARCHAR, postal_code VARCHAR, phone VARCHAR, fax VARCHAR, email VARCHAR, support_rep_id INTEGER); -CREATE TABLE employees(employee_id INTEGER, last_name VARCHAR, first_name VARCHAR, title VARCHAR, reports_to INTEGER, birth_date TIMESTAMP, hire_date TIMESTAMP, address VARCHAR, city VARCHAR, state VARCHAR, country VARCHAR, postal_code VARCHAR, phone VARCHAR, fax VARCHAR, email VARCHAR); -CREATE TABLE tracks(track_id INTEGER, "name" VARCHAR, album_id INTEGER, media_type_id INTEGER, genre_id INTEGER, composer VARCHAR, "milliseconds" INTEGER, bytes INTEGER, unit_price DOUBLE); -CREATE TABLE albums(album_id INTEGER, title VARCHAR, artist_id INTEGER); -CREATE TABLE genres(genre_id INTEGER, "name" VARCHAR); +DROP TABLE IF EXISTS invoices; +DROP TABLE IF EXISTS customers; +DROP TABLE IF EXISTS employees; +DROP TABLE IF EXISTS tracks; +DROP TABLE IF EXISTS albums; +DROP TABLE IF EXISTS genres; +DROP TABLE IF EXISTS playlist_track; +DROP TABLE IF EXISTS playlists; +DROP TABLE IF EXISTS media_types; +DROP TABLE IF EXISTS artists; +DROP TABLE IF EXISTS invoice_items; + +CREATE TABLE invoices(invoice_id INTEGER, customer_id INTEGER, invoice_date TIMESTAMP, billing_address VARCHAR(255), billing_city VARCHAR(255), billing_state VARCHAR(255), billing_country VARCHAR(255), billing_postal_code VARCHAR(255), total REAL); +CREATE TABLE customers(customer_id INTEGER, first_name VARCHAR(255), last_name VARCHAR(255), company VARCHAR(255), address VARCHAR(255), city VARCHAR(255), state VARCHAR(255), country VARCHAR(255), postal_code VARCHAR(255), phone VARCHAR(255), fax VARCHAR(255), email VARCHAR(255), support_rep_id INTEGER); +CREATE TABLE employees(employee_id INTEGER, last_name VARCHAR(255), first_name VARCHAR(255), title VARCHAR(255), reports_to INTEGER, birth_date TIMESTAMP, hire_date TIMESTAMP, address VARCHAR(255), city VARCHAR(255), state VARCHAR(255), country VARCHAR(255), postal_code VARCHAR(255), phone VARCHAR(255), fax VARCHAR(255), email VARCHAR(255)); +CREATE TABLE tracks(track_id INTEGER, "name" VARCHAR(255), album_id INTEGER, media_type_id INTEGER, genre_id INTEGER, composer VARCHAR(255), "milliseconds" INTEGER, bytes INTEGER, unit_price REAL); +CREATE TABLE albums(album_id INTEGER, title VARCHAR(255), artist_id INTEGER); +CREATE TABLE genres(genre_id INTEGER, "name" VARCHAR(255)); CREATE TABLE playlist_track(playlist_id INTEGER, track_id INTEGER); -CREATE TABLE playlists(playlist_id INTEGER, "name" VARCHAR); -CREATE TABLE media_types(media_type_id INTEGER, "name" VARCHAR); -CREATE TABLE artists(artist_id INTEGER, "name" VARCHAR); -CREATE TABLE invoice_items(invoice_line_id INTEGER, invoice_id INTEGER, track_id INTEGER, unit_price DOUBLE, quantity INTEGER); +CREATE TABLE playlists(playlist_id INTEGER, "name" VARCHAR(255)); +CREATE TABLE media_types(media_type_id INTEGER, "name" VARCHAR(255)); +CREATE TABLE artists(artist_id INTEGER, "name" VARCHAR(255)); +CREATE TABLE invoice_items(invoice_line_id INTEGER, invoice_id INTEGER, track_id INTEGER, unit_price REAL, quantity INTEGER); From 28878146ab9866fed309948987c9fc285a8f69d5 Mon Sep 17 00:00:00 2001 From: Jelenkee Date: Tue, 28 Mar 2023 18:31:59 +0200 Subject: [PATCH 19/29] -fixed or skipped all prql files --- .../tests/integration-rdbms/connection.rs | 23 ++- prql-compiler/tests/integration-rdbms/main.rs | 133 +++++++++--------- .../tests/integration-rdbms/setup.sql | 61 -------- ...ion_rdbms__tests__rdbms@distinct.prql.snap | 6 + ...rdbms__tests__rdbms@genre_counts.prql.snap | 6 + ...on_rdbms__tests__rdbms@group_all.prql.snap | 6 + ...bms__tests__rdbms@invoice_totals.prql.snap | 6 + ...gration_rdbms__tests__rdbms@loop.prql.snap | 6 + ...on_rdbms__tests__rdbms@pipelines.prql.snap | 6 + ...bms__tests__rdbms@set_ops_remove.prql.snap | 6 + ...ation_rdbms__tests__rdbms@switch.prql.snap | 6 + .../tests/integration-rdbms/testcases.txt | 127 ----------------- .../integration/data/chinook/employees.csv | 2 +- .../tests/integration/queries/group_all.prql | 5 +- .../integration/queries/invoice_totals.prql | 2 + .../tests/integration/queries/loop.prql | 1 + .../tests/integration/queries/pipelines.prql | 1 + .../integration/queries/set_ops_remove.prql | 1 + .../tests/integration/queries/switch.prql | 3 + ...tegration__tests__test@group_all.prql.snap | 14 +- 20 files changed, 146 insertions(+), 275 deletions(-) delete mode 100644 prql-compiler/tests/integration-rdbms/setup.sql create mode 100644 prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@distinct.prql.snap create mode 100644 prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@genre_counts.prql.snap create mode 100644 prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@group_all.prql.snap create mode 100644 prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@invoice_totals.prql.snap create mode 100644 prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@loop.prql.snap create mode 100644 prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@pipelines.prql.snap create mode 100644 prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@set_ops_remove.prql.snap create mode 100644 prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@switch.prql.snap delete mode 100644 prql-compiler/tests/integration-rdbms/testcases.txt diff --git a/prql-compiler/tests/integration-rdbms/connection.rs b/prql-compiler/tests/integration-rdbms/connection.rs index e27e29044886..7eae3f823928 100644 --- a/prql-compiler/tests/integration-rdbms/connection.rs +++ b/prql-compiler/tests/integration-rdbms/connection.rs @@ -1,9 +1,7 @@ -use std::env::{current_dir, join_paths}; -use std::fs::read_to_string; -use std::path::Path; +use std::env::current_dir; use std::time::SystemTime; -use chrono::{DateTime, TimeZone, Utc}; +use chrono::{DateTime, Utc}; use itertools::Itertools; use mysql::prelude::Queryable; use mysql::Value; @@ -12,7 +10,6 @@ use postgres::types::Type; use tiberius::numeric::BigDecimal; use tiberius::time::time::PrimitiveDateTime; use tiberius::*; -use time::DateTime2; use tokio::net::TcpStream; use tokio::runtime::Runtime; use tokio_util::compat::Compat; @@ -93,7 +90,7 @@ impl DBConnection for DuckDBConnection { ] { path.push(p); } - let path = path.display().to_string().replace("\"", ""); + let path = path.display().to_string().replace('"', ""); self.run_query( &format!("COPY {csv_name} FROM '{path}' (AUTO_DETECT TRUE);"), runtime, @@ -145,7 +142,6 @@ impl DBConnection for SQLiteConnection { ] { path.push(p); } - let content = read_to_string(path.clone()).unwrap(); let mut reader = csv::ReaderBuilder::new() .has_headers(true) .from_path(path) @@ -162,11 +158,7 @@ impl DBConnection for SQLiteConnection { "INSERT INTO {csv_name} ({}) VALUES ({})", headers.iter().join(","), r.iter() - .map(|s| if true || s.contains(" ") { - format!("\"{s}\"") - } else { - s.to_string() - }) + .map(|s| format!("\"{}\"", s.replace('"', "\"\""))) .join(",") ); self.run_query(q.as_str(), runtime); @@ -191,7 +183,10 @@ impl DBConnection for PostgresConnection { let col = &(*row.columns())[i]; let value = match col.type_() { &Type::BOOL => (row.get::(i)).to_string(), - &Type::INT4 => (row.get::(i)).to_string(), + &Type::INT4 => match row.try_get::(i) { + Ok(v) => v.to_string(), + Err(_) => "".to_string(), + }, &Type::INT8 => (row.get::(i)).to_string(), &Type::TEXT | &Type::VARCHAR | &Type::JSON | &Type::JSONB => { match row.try_get::(i) { @@ -298,7 +293,7 @@ impl MssqlConnection { .map(|i| i.to_string()) .unwrap_or_else(|| "".to_string()), ColumnType::Floatn => row - .get::(i) + .get::(i) .map(|i| i.to_string()) .unwrap_or_else(|| "".to_string()), ColumnType::Numericn => row.get::(i).unwrap().to_string(), diff --git a/prql-compiler/tests/integration-rdbms/main.rs b/prql-compiler/tests/integration-rdbms/main.rs index e79b5847d36c..8b7b0d6fdda8 100644 --- a/prql-compiler/tests/integration-rdbms/main.rs +++ b/prql-compiler/tests/integration-rdbms/main.rs @@ -4,9 +4,10 @@ mod connection; #[cfg(test)] mod tests { - use std::env; + use std::collections::BTreeMap; + use std::{env, fs}; - use insta::assert_display_snapshot; + use insta::{assert_snapshot, glob}; use postgres::NoTls; use tiberius::{AuthMethod, Client, Config}; use tokio::net::TcpStream; @@ -30,7 +31,7 @@ mod tests { // CI panic!("No database is listening on port {}", port); } - Ok(_) | Err(_) => { + _ => { // locally return; } @@ -63,19 +64,56 @@ mod tests { MssqlConnection(client) }; - let connections: Vec<&mut dyn DBConnection> = + let mut connections: Vec<&mut dyn DBConnection> = vec![&mut duck, &mut sqlite, &mut pg, &mut my, &mut ms]; - for con in connections { - run_tests_for_connection(con, &runtime); + for con in &mut connections { + setup_connection(*con, &runtime); } - panic!("mdsad"); + + // for each of the queries + glob!("..", "integration/queries/**/*.prql", |path| { + let test_name = path + .file_name() + .and_then(|s| s.to_str()) + .unwrap_or_default(); + + // read + let prql = fs::read_to_string(path).unwrap(); + + if prql.contains("skip_test") { + return; + } + + let mut results = BTreeMap::new(); + for con in &mut connections { + let vendor = con.get_dialect().to_string().to_lowercase(); + if prql.contains(format!("skip_{}", vendor).as_str()) { + continue; + } + results.insert(vendor, run_query(*con, prql.as_str(), &runtime)); + } + + let first_result = match results.iter().next() { + Some(v) => v, + None => return, + }; + for (k, v) in results.iter().skip(1) { + pretty_assertions::assert_eq!( + *first_result.1, + *v, + "{} == {}: {test_name}", + first_result.0, + k + ); + } + + assert_snapshot!(format!("{:?}", first_result.1)); + }); } - fn run_tests_for_connection(con: &mut dyn DBConnection, runtime: &Runtime) { - let setup = include_str!("setup.sql"); + fn setup_connection(con: &mut dyn DBConnection, runtime: &Runtime) { let setup = include_str!("../integration/data/chinook/schema.sql"); - println!("DD:: {}", con.get_dialect()); setup .split(';') .map(|s| s.trim()) @@ -83,66 +121,35 @@ mod tests { .for_each(|s| { let sql = match con.get_dialect() { Dialect::MsSql => s.replace("TIMESTAMP", "DATETIME"), - Dialect::MySql => s.replace('"', "`"), + Dialect::MySql => s.replace('"', "`").replace("TIMESTAMP", "DATETIME"), _ => s.to_string(), }; con.run_query(sql.as_str(), runtime); }); - con.import_csv("invoices", runtime); - let mut rr = con.run_query("select * from invoices;", runtime); - println!("{:?}", rr.first()); - assert_eq!(412, rr.len()); - return; - for (prql, expected_rows) in get_test_cases() { - let options = Options::default().with_target(Sql(Some(con.get_dialect()))); - let sql = prql_compiler::compile(prql.as_str(), &options).unwrap(); - let mut actual_rows = con.run_query(sql.as_str(), runtime); - replace_booleans(&mut actual_rows); - println!("{} {:?}", &con.get_dialect(), &actual_rows); - assert_eq!( - *expected_rows, - actual_rows, - "Rows do not match for {}", - con.get_dialect() - ); - - assert_display_snapshot!(con.get_dialect().to_string(), format!("{:?}", actual_rows)); + let tables = [ + "invoices", + "customers", + "employees", + "tracks", + "albums", + "genres", + "playlist_track", + "playlists", + "media_types", + "artists", + "invoice_items", + ]; + for table in tables { + con.import_csv(table, runtime); } } - // parse test cases from file - fn get_test_cases() -> Vec<(String, Vec)> { - let test_file = include_str!("testcases.txt"); - let tests = test_file - .split("###") - .map(|s| s.trim()) - .filter(|s| !s.is_empty()) - .collect::>(); - - tests - .iter() - .map(|test| { - let tests = test - .split("---") - .map(|s| s.trim()) - .filter(|s| !s.is_empty()) - .collect::>(); - assert_eq!(tests.len(), 2, "Test is missing ---"); - - let rows = tests[1] - .lines() - .map(|l| { - l.split(',') - .map(|s| s.trim()) - .filter(|s| !s.is_empty()) - .map(|s| s.to_string()) - .collect::() - }) - .collect::>(); - - (tests[0].to_string(), rows) - }) - .collect() + fn run_query(con: &mut dyn DBConnection, prql: &str, runtime: &Runtime) -> Vec { + let options = Options::default().with_target(Sql(Some(con.get_dialect()))); + let sql = prql_compiler::compile(prql, &options).unwrap(); + let mut actual_rows = con.run_query(sql.as_str(), runtime); + replace_booleans(&mut actual_rows); + actual_rows } // some sql dialects use 1 and 0 instead of true and false diff --git a/prql-compiler/tests/integration-rdbms/setup.sql b/prql-compiler/tests/integration-rdbms/setup.sql deleted file mode 100644 index 7c17dab75079..000000000000 --- a/prql-compiler/tests/integration-rdbms/setup.sql +++ /dev/null @@ -1,61 +0,0 @@ -DROP TABLE IF EXISTS cars; -DROP TABLE IF EXISTS people; -DROP TABLE IF EXISTS "Upper"; - -CREATE TABLE people -( - id integer NOT NULL, - name varchar(255) NOT NULL, - rich boolean NOT NULL, - PRIMARY KEY (id) -); - -CREATE TABLE cars -( - id integer NOT NULL, - person integer NOT NULL, - name varchar(255), - price integer NOT NULL, - PRIMARY KEY (id), - CONSTRAINT c - FOREIGN KEY (person) - REFERENCES people (id) -); - -CREATE TABLE "Upper" -( - id integer NOT NULL -); - -INSERT INTO people -( - id, - name, - rich -) -VALUES -(0, 'Tony Stark', TRUE), -(1, 'Bruce Wayne', TRUE), -(2, 'Wade Wilson', FALSE); - -INSERT INTO cars -( - id, - person, - name, - price -) -VALUES -(0, 1, 'Mercedes', 60000), -(1, 1, 'Porsche', 90000), -(2, 0, 'Bugatti', 400000), -(3, 0, 'Ferrari', 500000), -(4, 0, 'Lamborghini', 200000), -(5, 2, 'Toyota', 10000); - -INSERT INTO "Upper" -( - id -) -VALUES -(999); diff --git a/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@distinct.prql.snap b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@distinct.prql.snap new file mode 100644 index 000000000000..0ae946546223 --- /dev/null +++ b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@distinct.prql.snap @@ -0,0 +1,6 @@ +--- +source: prql-compiler/tests/integration-rdbms/main.rs +expression: "format!(\"{:?}\", first_result.1)" +input_file: prql-compiler/tests/integration/queries/distinct.prql +--- +[["1", "1"], ["2", "1"], ["3", "1"], ["4", "1"], ["5", "1"], ["6", "1"], ["7", "1"], ["8", "2"], ["9", "3"], ["10", "1"], ["11", "4"], ["12", "5"], ["13", "2"], ["14", "3"], ["15", "3"], ["16", "3"], ["17", "3"], ["18", "4"], ["19", "3"], ["20", "6"], ["21", "7"], ["22", "7"], ["23", "7"], ["24", "7"], ["25", "7"], ["26", "8"], ["27", "8"], ["28", "7"], ["29", "9"], ["30", "1"], ["31", "1"], ["32", "10"], ["33", "7"], ["34", "7"], ["35", "3"], ["36", "1"], ["37", "1"], ["38", "2"], ["39", "4"], ["40", "1"], ["41", "7"], ["42", "4"], ["43", "1"], ["44", "1"], ["45", "7"], ["46", "1"], ["47", "7"], ["48", "2"], ["49", "2"], ["50", "1"], ["51", "2"], ["52", "11"], ["53", "7"], ["54", "1"], ["55", "1"], ["56", "7"], ["57", "7"], ["58", "1"], ["59", "1"], ["60", "1"], ["61", "1"], ["62", "1"], ["63", "1"], ["64", "1"], ["65", "1"], ["66", "1"], ["67", "1"], ["68", "2"], ["69", "7"], ["70", "7"], ["71", "7"], ["72", "6"], ["73", "6"], ["73", "7"], ["74", "4"], ["75", "4"], ["76", "1"], ["77", "4"], ["78", "7"], ["79", "1"], ["80", "1"], ["81", "4"], ["82", "1"], ["83", "12"], ["84", "7"], ["85", "10"], ["86", "7"], ["87", "2"], ["88", "3"], ["89", "4"], ["90", "1"], ["91", "1"], ["92", "3"], ["93", "2"], ["94", "1"], ["95", "3"], ["96", "3"], ["97", "1"], ["98", "13"], ["99", "1"], ["100", "6"], ["101", "13"], ["102", "3"], ["102", "13"], ["103", "1"], ["104", "1"], ["105", "3"], ["106", "3"], ["107", "3"], ["108", "3"], ["109", "1"], ["109", "3"], ["110", "3"], ["111", "3"], ["112", "1"], ["112", "3"], ["113", "1"], ["114", "1"], ["115", "14"], ["116", "1"], ["117", "14"], ["118", "15"], ["119", "4"], ["120", "1"], ["121", "1"], ["122", "7"], ["123", "7"], ["124", "16"], ["125", "3"], ["126", "1"], ["127", "1"], ["128", "1"], ["129", "1"], ["130", "1"], ["131", "1"], ["132", "1"], ["133", "1"], ["134", "1"], ["135", "1"], ["136", "1"], ["137", "1"], ["138", "1"], ["139", "7"], ["140", "7"], ["141", "1"], ["141", "3"], ["141", "8"], ["142", "7"], ["143", "7"], ["144", "1"], ["145", "7"], ["146", "14"], ["147", "1"], ["148", "3"], ["149", "3"], ["150", "3"], ["151", "3"], ["152", "3"], ["153", "3"], ["154", "3"], ["155", "3"], ["156", "3"], ["157", "2"], ["158", "7"], ["159", "7"], ["160", "3"], ["161", "16"], ["162", "3"], ["163", "1"], ["164", "1"], ["165", "1"], ["166", "7"], ["167", "7"], ["168", "7"], ["169", "7"], ["170", "1"], ["171", "1"], ["172", "1"], ["173", "1"], ["174", "3"], ["175", "1"], ["176", "10"], ["177", "1"], ["178", "1"], ["179", "4"], ["180", "1"], ["181", "1"], ["182", "1"], ["183", "1"], ["184", "17"], ["185", "1"], ["186", "1"], ["187", "4"], ["188", "4"], ["189", "1"], ["190", "4"], ["191", "4"], ["192", "1"], ["193", "4"], ["194", "1"], ["195", "1"], ["196", "1"], ["197", "1"], ["198", "1"], ["199", "1"], ["200", "1"], ["201", "4"], ["202", "4"], ["203", "1"], ["204", "2"], ["205", "6"], ["206", "1"], ["207", "3"], ["208", "1"], ["209", "6"], ["210", "6"], ["211", "4"], ["212", "1"], ["213", "1"], ["214", "1"], ["215", "1"], ["216", "1"], ["217", "1"], ["218", "1"], ["219", "4"], ["220", "4"], ["221", "1"], ["222", "7"], ["223", "7"], ["224", "4"], ["225", "4"], ["226", "18"], ["227", "18"], ["227", "19"], ["227", "20"], ["228", "19"], ["228", "21"], ["229", "19"], ["229", "21"], ["230", "19"], ["231", "19"], ["231", "21"], ["232", "1"], ["233", "1"], ["234", "1"], ["235", "1"], ["236", "1"], ["237", "1"], ["238", "1"], ["239", "1"], ["240", "1"], ["241", "8"], ["242", "1"], ["243", "1"], ["244", "1"], ["245", "1"], ["246", "1"], ["247", "7"], ["248", "7"], ["249", "19"], ["250", "19"], ["251", "19"], ["251", "22"], ["252", "1"], ["253", "20"], ["254", "19"], ["255", "9"], ["256", "1"], ["257", "1"], ["258", "17"], ["259", "15"], ["260", "23"], ["261", "19"], ["261", "21"], ["262", "2"], ["263", "16"], ["264", "15"], ["265", "1"], ["266", "7"], ["267", "2"], ["268", "24"], ["269", "23"], ["270", "23"], ["271", "23"], ["272", "24"], ["273", "24"], ["274", "24"], ["275", "24"], ["276", "24"], ["277", "24"], ["278", "24"], ["279", "24"], ["280", "24"], ["281", "24"], ["282", "24"], ["283", "24"], ["284", "24"], ["285", "24"], ["286", "24"], ["287", "24"], ["288", "24"], ["289", "24"], ["290", "24"], ["291", "24"], ["292", "24"], ["293", "24"], ["294", "24"], ["295", "24"], ["296", "24"], ["297", "24"], ["298", "24"], ["299", "24"], ["300", "24"], ["301", "24"], ["302", "24"], ["303", "24"], ["304", "24"], ["305", "24"], ["306", "24"], ["307", "24"], ["308", "24"], ["309", "24"], ["310", "24"], ["311", "24"], ["312", "24"], ["313", "24"], ["314", "24"], ["315", "24"], ["316", "24"], ["317", "25"], ["318", "24"], ["319", "24"], ["320", "24"], ["321", "14"], ["322", "9"], ["323", "23"], ["324", "24"], ["325", "24"], ["326", "24"], ["327", "24"], ["328", "24"], ["329", "24"], ["330", "24"], ["331", "24"], ["332", "24"], ["333", "24"], ["334", "24"], ["335", "24"], ["336", "24"], ["337", "24"], ["338", "24"], ["339", "24"], ["340", "24"], ["341", "24"], ["342", "24"], ["343", "24"], ["344", "24"], ["345", "24"], ["346", "24"], ["347", "10"]] diff --git a/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@genre_counts.prql.snap b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@genre_counts.prql.snap new file mode 100644 index 000000000000..2751f9165721 --- /dev/null +++ b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@genre_counts.prql.snap @@ -0,0 +1,6 @@ +--- +source: prql-compiler/tests/integration-rdbms/main.rs +expression: "format!(\"{:?}\", first_result.1)" +input_file: prql-compiler/tests/integration/queries/genre_counts.prql +--- +[["-25"]] diff --git a/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@group_all.prql.snap b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@group_all.prql.snap new file mode 100644 index 000000000000..adcfc49c15ac --- /dev/null +++ b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@group_all.prql.snap @@ -0,0 +1,6 @@ +--- +source: prql-compiler/tests/integration-rdbms/main.rs +expression: "format!(\"{:?}\", first_result.1)" +input_file: prql-compiler/tests/integration/queries/group_all.prql +--- +[["1", "For Those About To Rock We Salute You", "9.9"], ["2", "Balls to the Wall", "0.99"], ["3", "Restless and Wild", "2.97"], ["4", "Let There Be Rock", "7.92"], ["5", "Big Ones", "14.85"], ["6", "Jagged Little Pill", "12.87"], ["7", "Facelift", "11.88"], ["8", "Warner 25 Anos", "13.86"], ["9", "Plays Metallica By Four Cellos", "7.92"], ["10", "Audioslave", "13.86"]] diff --git a/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@invoice_totals.prql.snap b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@invoice_totals.prql.snap new file mode 100644 index 000000000000..f9bfc736e21c --- /dev/null +++ b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@invoice_totals.prql.snap @@ -0,0 +1,6 @@ +--- +source: prql-compiler/tests/integration-rdbms/main.rs +expression: "format!(\"{:?}\", first_result.1)" +input_file: prql-compiler/tests/integration/queries/invoice_totals.prql +--- +[["2009-01", "2009-01-01", "1", "2", "1.98", "2", ""], ["2009-01", "2009-01-02", "1", "4", "3.96", "6", ""], ["2009-01", "2009-01-03", "1", "6", "5.94", "12", ""], ["2009-01", "2009-01-06", "1", "9", "8.91", "21", ""], ["2009-01", "2009-01-11", "1", "14", "13.86", "35", ""], ["2009-01", "2009-01-19", "1", "1", "0.99", "36", ""], ["2009-02", "2009-02-01", "2", "4", "3.96", "4", ""], ["2009-02", "2009-02-02", "1", "4", "3.96", "8", "2"], ["2009-02", "2009-02-03", "1", "6", "5.94", "14", "4"], ["2009-02", "2009-02-06", "1", "9", "8.91", "23", "6"], ["2009-02", "2009-02-11", "1", "14", "13.86", "37", "9"], ["2009-02", "2009-02-19", "1", "1", "0.99", "38", "14"], ["2009-03", "2009-03-04", "2", "4", "3.96", "4", "1"], ["2009-03", "2009-03-05", "1", "4", "3.96", "8", "4"], ["2009-03", "2009-03-06", "1", "6", "5.94", "14", "4"], ["2009-03", "2009-03-09", "1", "9", "8.91", "23", "6"], ["2009-03", "2009-03-14", "1", "14", "13.86", "37", "9"], ["2009-03", "2009-03-22", "1", "1", "0.99", "38", "14"], ["2009-04", "2009-04-04", "2", "4", "3.96", "4", "1"], ["2009-04", "2009-04-05", "1", "4", "3.96", "8", "4"], ["2009-04", "2009-04-06", "1", "6", "5.94", "14", "4"], ["2009-04", "2009-04-09", "1", "9", "8.91", "23", "6"], ["2009-04", "2009-04-14", "1", "14", "13.86", "37", "9"], ["2009-04", "2009-04-22", "1", "1", "0.99", "38", "14"], ["2009-05", "2009-05-05", "2", "4", "3.96", "4", "1"], ["2009-05", "2009-05-06", "1", "4", "3.96", "8", "4"], ["2009-05", "2009-05-07", "1", "6", "5.94", "14", "4"], ["2009-05", "2009-05-10", "1", "9", "8.91", "23", "6"], ["2009-05", "2009-05-15", "1", "14", "13.86", "37", "9"], ["2009-05", "2009-05-23", "1", "1", "0.99", "38", "14"], ["2009-06", "2009-06-05", "2", "4", "3.96", "4", "1"], ["2009-06", "2009-06-06", "1", "4", "3.96", "8", "4"], ["2009-06", "2009-06-07", "1", "6", "5.94", "14", "4"], ["2009-06", "2009-06-10", "1", "9", "8.91", "23", "6"], ["2009-06", "2009-06-15", "1", "14", "13.86", "37", "9"], ["2009-06", "2009-06-23", "1", "1", "0.99", "38", "14"], ["2009-07", "2009-07-06", "2", "4", "3.96", "4", "1"], ["2009-07", "2009-07-07", "1", "4", "3.96", "8", "4"], ["2009-07", "2009-07-08", "1", "6", "5.94", "14", "4"], ["2009-07", "2009-07-11", "1", "9", "8.91", "23", "6"], ["2009-07", "2009-07-16", "1", "14", "13.86", "37", "9"], ["2009-07", "2009-07-24", "1", "1", "0.99", "38", "14"], ["2009-08", "2009-08-06", "2", "4", "3.96", "4", "1"], ["2009-08", "2009-08-07", "1", "4", "3.96", "8", "4"], ["2009-08", "2009-08-08", "1", "6", "5.94", "14", "4"], ["2009-08", "2009-08-11", "1", "9", "8.91", "23", "6"], ["2009-08", "2009-08-16", "1", "14", "13.86", "37", "9"], ["2009-08", "2009-08-24", "1", "1", "0.99", "38", "14"], ["2009-09", "2009-09-06", "2", "4", "3.96", "4", "1"], ["2009-09", "2009-09-07", "1", "4", "3.96", "8", "4"], ["2009-09", "2009-09-08", "1", "6", "5.94", "14", "4"], ["2009-09", "2009-09-11", "1", "9", "8.91", "23", "6"], ["2009-09", "2009-09-16", "1", "14", "13.86", "37", "9"], ["2009-09", "2009-09-24", "1", "1", "0.99", "38", "14"], ["2009-10", "2009-10-07", "2", "4", "3.96", "4", "1"], ["2009-10", "2009-10-08", "1", "4", "3.96", "8", "4"], ["2009-10", "2009-10-09", "1", "6", "5.94", "14", "4"], ["2009-10", "2009-10-12", "1", "9", "8.91", "23", "6"], ["2009-10", "2009-10-17", "1", "14", "13.86", "37", "9"], ["2009-10", "2009-10-25", "1", "1", "0.99", "38", "14"], ["2009-11", "2009-11-07", "2", "4", "3.96", "4", "1"], ["2009-11", "2009-11-08", "1", "4", "3.96", "8", "4"], ["2009-11", "2009-11-09", "1", "6", "5.94", "14", "4"], ["2009-11", "2009-11-12", "1", "9", "8.91", "23", "6"], ["2009-11", "2009-11-17", "1", "14", "13.86", "37", "9"], ["2009-11", "2009-11-25", "1", "1", "0.99", "38", "14"], ["2009-12", "2009-12-08", "2", "4", "3.96", "4", "1"], ["2009-12", "2009-12-09", "1", "4", "3.96", "8", "4"], ["2009-12", "2009-12-10", "1", "6", "5.94", "14", "4"], ["2009-12", "2009-12-13", "1", "9", "8.91", "23", "6"], ["2009-12", "2009-12-18", "1", "14", "13.86", "37", "9"], ["2009-12", "2009-12-26", "1", "1", "0.99", "38", "14"], ["2010-01", "2010-01-08", "2", "4", "3.96", "4", "1"], ["2010-01", "2010-01-09", "1", "4", "3.96", "8", "4"], ["2010-01", "2010-01-10", "1", "6", "6.94", "14", "4"], ["2010-01", "2010-01-13", "1", "9", "17.91", "23", "6"], ["2010-01", "2010-01-18", "1", "14", "18.86", "37", "9"], ["2010-01", "2010-01-26", "1", "1", "0.99", "38", "14"], ["2010-02", "2010-02-08", "2", "4", "3.96", "4", "1"], ["2010-02", "2010-02-09", "1", "4", "3.96", "8", "4"], ["2010-02", "2010-02-10", "1", "6", "5.94", "14", "4"], ["2010-02", "2010-02-13", "1", "9", "8.91", "23", "6"], ["2010-02", "2010-02-18", "1", "14", "21.86", "37", "9"], ["2010-02", "2010-02-26", "1", "1", "1.99", "38", "14"], ["2010-03", "2010-03-11", "2", "4", "7.96", "4", "1"], ["2010-03", "2010-03-12", "1", "4", "3.96", "8", "4"], ["2010-03", "2010-03-13", "1", "6", "5.94", "14", "4"], ["2010-03", "2010-03-16", "1", "9", "9.91", "23", "6"], ["2010-03", "2010-03-21", "1", "14", "15.86", "37", "9"], ["2010-03", "2010-03-29", "1", "1", "0.99", "38", "14"], ["2010-04", "2010-04-11", "2", "4", "3.96", "4", "1"], ["2010-04", "2010-04-12", "1", "4", "3.96", "8", "4"], ["2010-04", "2010-04-13", "1", "6", "5.94", "14", "4"], ["2010-04", "2010-04-16", "1", "9", "8.91", "23", "6"], ["2010-04", "2010-04-21", "1", "14", "13.86", "37", "9"], ["2010-04", "2010-04-29", "1", "1", "0.99", "38", "14"], ["2010-05", "2010-05-12", "2", "4", "3.96", "4", "1"], ["2010-05", "2010-05-13", "1", "4", "3.96", "8", "4"], ["2010-05", "2010-05-14", "1", "6", "5.94", "14", "4"], ["2010-05", "2010-05-17", "1", "9", "8.91", "23", "6"], ["2010-05", "2010-05-22", "1", "14", "13.86", "37", "9"], ["2010-05", "2010-05-30", "1", "1", "0.99", "38", "14"], ["2010-06", "2010-06-12", "2", "4", "3.96", "4", "1"], ["2010-06", "2010-06-13", "1", "4", "3.96", "8", "4"], ["2010-06", "2010-06-14", "1", "6", "5.94", "14", "4"], ["2010-06", "2010-06-17", "1", "9", "8.91", "23", "6"], ["2010-06", "2010-06-22", "1", "14", "13.86", "37", "9"], ["2010-06", "2010-06-30", "1", "1", "0.99", "38", "14"], ["2010-07", "2010-07-13", "2", "4", "3.96", "4", "1"], ["2010-07", "2010-07-14", "1", "4", "3.96", "8", "4"], ["2010-07", "2010-07-15", "1", "6", "5.94", "14", "4"], ["2010-07", "2010-07-18", "1", "9", "8.91", "23", "6"], ["2010-07", "2010-07-23", "1", "14", "13.86", "37", "9"], ["2010-07", "2010-07-31", "1", "1", "0.99", "38", "14"], ["2010-08", "2010-08-13", "2", "4", "3.96", "4", "1"], ["2010-08", "2010-08-14", "1", "4", "3.96", "8", "4"], ["2010-08", "2010-08-15", "1", "6", "5.94", "14", "4"], ["2010-08", "2010-08-18", "1", "9", "8.91", "23", "6"], ["2010-08", "2010-08-23", "1", "14", "13.86", "37", "9"], ["2010-08", "2010-08-31", "1", "1", "0.99", "38", "14"], ["2010-09", "2010-09-13", "2", "4", "3.96", "4", "1"], ["2010-09", "2010-09-14", "1", "4", "3.96", "8", "4"], ["2010-09", "2010-09-15", "1", "6", "5.94", "14", "4"], ["2010-09", "2010-09-18", "1", "9", "8.91", "23", "6"], ["2010-09", "2010-09-23", "1", "14", "13.86", "37", "9"], ["2010-10", "2010-10-01", "1", "1", "0.99", "1", "14"], ["2010-10", "2010-10-14", "2", "4", "3.96", "5", "1"], ["2010-10", "2010-10-15", "1", "4", "3.96", "9", "4"], ["2010-10", "2010-10-16", "1", "6", "5.94", "15", "4"], ["2010-10", "2010-10-19", "1", "9", "8.91", "24", "6"], ["2010-10", "2010-10-24", "1", "14", "13.86", "38", "9"], ["2010-11", "2010-11-01", "1", "1", "0.99", "1", "14"], ["2010-11", "2010-11-14", "2", "4", "3.96", "5", "1"], ["2010-11", "2010-11-15", "1", "4", "3.96", "9", "4"], ["2010-11", "2010-11-16", "1", "6", "5.94", "15", "4"], ["2010-11", "2010-11-19", "1", "9", "8.91", "24", "6"], ["2010-11", "2010-11-24", "1", "14", "13.86", "38", "9"], ["2010-12", "2010-12-02", "1", "1", "0.99", "1", "14"], ["2010-12", "2010-12-15", "2", "4", "3.96", "5", "1"], ["2010-12", "2010-12-16", "1", "4", "3.96", "9", "4"], ["2010-12", "2010-12-17", "1", "6", "5.94", "15", "4"], ["2010-12", "2010-12-20", "1", "9", "8.91", "24", "6"], ["2010-12", "2010-12-25", "1", "14", "13.86", "38", "9"], ["2011-01", "2011-01-02", "1", "1", "0.99", "1", "14"], ["2011-01", "2011-01-15", "2", "4", "3.96", "5", "1"], ["2011-01", "2011-01-16", "1", "4", "3.96", "9", "4"], ["2011-01", "2011-01-17", "1", "6", "5.94", "15", "4"], ["2011-01", "2011-01-20", "1", "9", "8.91", "24", "6"], ["2011-01", "2011-01-25", "1", "14", "13.86", "38", "9"], ["2011-02", "2011-02-02", "1", "1", "0.99", "1", "14"], ["2011-02", "2011-02-15", "2", "4", "3.96", "5", "1"], ["2011-02", "2011-02-16", "1", "4", "3.96", "9", "4"], ["2011-02", "2011-02-17", "1", "6", "5.94", "15", "4"], ["2011-02", "2011-02-20", "1", "9", "8.91", "24", "6"], ["2011-02", "2011-02-25", "1", "14", "13.86", "38", "9"], ["2011-03", "2011-03-05", "1", "1", "0.99", "1", "14"], ["2011-03", "2011-03-18", "2", "4", "3.96", "5", "1"], ["2011-03", "2011-03-19", "1", "4", "3.96", "9", "4"], ["2011-03", "2011-03-20", "1", "6", "5.94", "15", "4"], ["2011-03", "2011-03-23", "1", "9", "8.91", "24", "6"], ["2011-03", "2011-03-28", "1", "14", "13.86", "38", "9"], ["2011-04", "2011-04-05", "1", "1", "0.99", "1", "14"], ["2011-04", "2011-04-18", "2", "4", "3.96", "5", "1"], ["2011-04", "2011-04-19", "1", "4", "3.96", "9", "4"], ["2011-04", "2011-04-20", "1", "6", "5.94", "15", "4"], ["2011-04", "2011-04-23", "1", "9", "14.91", "24", "6"], ["2011-04", "2011-04-28", "1", "14", "21.86", "38", "9"], ["2011-05", "2011-05-06", "1", "1", "0.99", "1", "14"], ["2011-05", "2011-05-19", "2", "4", "3.96", "5", "1"], ["2011-05", "2011-05-20", "1", "4", "3.96", "9", "4"], ["2011-05", "2011-05-21", "1", "6", "5.94", "15", "4"], ["2011-05", "2011-05-24", "1", "9", "8.91", "24", "6"], ["2011-05", "2011-05-29", "1", "14", "18.86", "38", "9"], ["2011-06", "2011-06-06", "1", "1", "1.99", "1", "14"], ["2011-06", "2011-06-19", "2", "4", "6.96", "5", "1"], ["2011-06", "2011-06-20", "1", "4", "7.96", "9", "4"], ["2011-06", "2011-06-21", "1", "6", "8.94", "15", "4"], ["2011-06", "2011-06-24", "1", "9", "8.91", "24", "6"], ["2011-06", "2011-06-29", "1", "14", "15.86", "38", "9"], ["2011-07", "2011-07-07", "1", "1", "0.99", "1", "14"], ["2011-07", "2011-07-20", "2", "4", "3.96", "5", "1"], ["2011-07", "2011-07-21", "1", "4", "3.96", "9", "4"], ["2011-07", "2011-07-22", "1", "6", "5.94", "15", "4"], ["2011-07", "2011-07-25", "1", "9", "8.91", "24", "6"], ["2011-07", "2011-07-30", "1", "14", "13.86", "38", "9"], ["2011-08", "2011-08-07", "1", "1", "0.99", "1", "14"], ["2011-08", "2011-08-20", "2", "4", "3.96", "5", "1"], ["2011-08", "2011-08-21", "1", "4", "3.96", "9", "4"], ["2011-08", "2011-08-22", "1", "6", "5.94", "15", "4"], ["2011-08", "2011-08-25", "1", "9", "8.91", "24", "6"], ["2011-08", "2011-08-30", "1", "14", "13.86", "38", "9"], ["2011-09", "2011-09-07", "1", "1", "0.99", "1", "14"], ["2011-09", "2011-09-20", "2", "4", "3.96", "5", "1"], ["2011-09", "2011-09-21", "1", "4", "3.96", "9", "4"], ["2011-09", "2011-09-22", "1", "6", "5.94", "15", "4"], ["2011-09", "2011-09-25", "1", "9", "8.91", "24", "6"], ["2011-09", "2011-09-30", "1", "14", "13.86", "38", "9"], ["2011-10", "2011-10-08", "1", "1", "0.99", "1", "14"], ["2011-10", "2011-10-21", "2", "4", "3.96", "5", "1"], ["2011-10", "2011-10-22", "1", "4", "3.96", "9", "4"], ["2011-10", "2011-10-23", "1", "6", "5.94", "15", "4"], ["2011-10", "2011-10-26", "1", "9", "8.91", "24", "6"], ["2011-10", "2011-10-31", "1", "14", "13.86", "38", "9"], ["2011-11", "2011-11-08", "1", "1", "0.99", "1", "14"], ["2011-11", "2011-11-21", "2", "4", "3.96", "5", "1"], ["2011-11", "2011-11-22", "1", "4", "3.96", "9", "4"], ["2011-11", "2011-11-23", "1", "6", "5.94", "15", "4"], ["2011-11", "2011-11-26", "1", "9", "8.91", "24", "6"], ["2011-12", "2011-12-01", "1", "14", "13.86", "14", "9"], ["2011-12", "2011-12-09", "1", "1", "0.99", "15", "14"], ["2011-12", "2011-12-22", "2", "4", "3.96", "19", "1"], ["2011-12", "2011-12-23", "1", "4", "3.96", "23", "4"], ["2011-12", "2011-12-24", "1", "6", "5.94", "29", "4"], ["2011-12", "2011-12-27", "1", "9", "8.91", "38", "6"], ["2012-01", "2012-01-01", "1", "14", "13.86", "14", "9"], ["2012-01", "2012-01-09", "1", "1", "0.99", "15", "14"], ["2012-01", "2012-01-22", "2", "4", "3.96", "19", "1"], ["2012-01", "2012-01-23", "1", "4", "3.96", "23", "4"], ["2012-01", "2012-01-24", "1", "6", "5.94", "29", "4"], ["2012-01", "2012-01-27", "1", "9", "8.91", "38", "6"], ["2012-02", "2012-02-01", "1", "14", "13.86", "14", "9"], ["2012-02", "2012-02-09", "1", "1", "0.99", "15", "14"], ["2012-02", "2012-02-22", "2", "4", "3.96", "19", "1"], ["2012-02", "2012-02-23", "1", "4", "3.96", "23", "4"], ["2012-02", "2012-02-24", "1", "6", "5.94", "29", "4"], ["2012-02", "2012-02-27", "1", "9", "8.91", "38", "6"], ["2012-03", "2012-03-03", "1", "14", "13.86", "14", "9"], ["2012-03", "2012-03-11", "1", "1", "0.99", "15", "14"], ["2012-03", "2012-03-24", "2", "4", "3.96", "19", "1"], ["2012-03", "2012-03-25", "1", "4", "3.96", "23", "4"], ["2012-03", "2012-03-26", "1", "6", "5.94", "29", "4"], ["2012-03", "2012-03-29", "1", "9", "8.91", "38", "6"], ["2012-04", "2012-04-03", "1", "14", "13.86", "14", "9"], ["2012-04", "2012-04-11", "1", "1", "0.99", "15", "14"], ["2012-04", "2012-04-24", "2", "4", "3.96", "19", "1"], ["2012-04", "2012-04-25", "1", "4", "3.96", "23", "4"], ["2012-04", "2012-04-26", "1", "6", "5.94", "29", "4"], ["2012-04", "2012-04-29", "1", "9", "8.91", "38", "6"], ["2012-05", "2012-05-04", "1", "14", "13.86", "14", "9"], ["2012-05", "2012-05-12", "1", "1", "0.99", "15", "14"], ["2012-05", "2012-05-25", "2", "4", "3.96", "19", "1"], ["2012-05", "2012-05-26", "1", "4", "3.96", "23", "4"], ["2012-05", "2012-05-27", "1", "6", "5.94", "29", "4"], ["2012-05", "2012-05-30", "1", "9", "8.91", "38", "6"], ["2012-06", "2012-06-04", "1", "14", "13.86", "14", "9"], ["2012-06", "2012-06-12", "1", "1", "0.99", "15", "14"], ["2012-06", "2012-06-25", "2", "4", "3.96", "19", "1"], ["2012-06", "2012-06-26", "1", "4", "3.96", "23", "4"], ["2012-06", "2012-06-27", "1", "6", "5.94", "29", "4"], ["2012-06", "2012-06-30", "1", "9", "8.91", "38", "6"], ["2012-07", "2012-07-05", "1", "14", "13.86", "14", "9"], ["2012-07", "2012-07-13", "1", "1", "0.99", "15", "14"], ["2012-07", "2012-07-26", "2", "4", "3.96", "19", "1"], ["2012-07", "2012-07-27", "1", "4", "3.96", "23", "4"], ["2012-07", "2012-07-28", "1", "6", "5.94", "29", "4"], ["2012-07", "2012-07-31", "1", "9", "10.91", "38", "6"], ["2012-08", "2012-08-05", "1", "14", "23.86", "14", "9"], ["2012-08", "2012-08-13", "1", "1", "0.99", "15", "14"], ["2012-08", "2012-08-26", "2", "4", "3.96", "19", "1"], ["2012-08", "2012-08-27", "1", "4", "3.96", "23", "4"], ["2012-08", "2012-08-28", "1", "6", "5.94", "29", "4"], ["2012-08", "2012-08-31", "1", "9", "8.91", "38", "6"], ["2012-09", "2012-09-05", "1", "14", "16.86", "14", "9"], ["2012-09", "2012-09-13", "1", "1", "1.99", "15", "14"], ["2012-09", "2012-09-26", "2", "4", "7.96", "19", "1"], ["2012-09", "2012-09-27", "1", "4", "7.96", "23", "4"], ["2012-09", "2012-09-28", "1", "6", "11.94", "29", "4"], ["2012-10", "2012-10-01", "1", "9", "10.91", "9", "6"], ["2012-10", "2012-10-06", "1", "14", "16.86", "23", "9"], ["2012-10", "2012-10-14", "1", "1", "0.99", "24", "14"], ["2012-10", "2012-10-27", "2", "4", "3.96", "28", "1"], ["2012-10", "2012-10-28", "1", "4", "3.96", "32", "4"], ["2012-10", "2012-10-29", "1", "6", "5.94", "38", "4"], ["2012-11", "2012-11-01", "1", "9", "8.91", "9", "6"], ["2012-11", "2012-11-06", "1", "14", "13.86", "23", "9"], ["2012-11", "2012-11-14", "1", "1", "0.99", "24", "14"], ["2012-11", "2012-11-27", "2", "4", "3.96", "28", "1"], ["2012-11", "2012-11-28", "1", "4", "3.96", "32", "4"], ["2012-11", "2012-11-29", "1", "6", "5.94", "38", "4"], ["2012-12", "2012-12-02", "1", "9", "8.91", "9", "6"], ["2012-12", "2012-12-07", "1", "14", "13.86", "23", "9"], ["2012-12", "2012-12-15", "1", "1", "0.99", "24", "14"], ["2012-12", "2012-12-28", "2", "4", "3.96", "28", "1"], ["2012-12", "2012-12-29", "1", "4", "3.96", "32", "4"], ["2012-12", "2012-12-30", "1", "6", "5.94", "38", "4"], ["2013-01", "2013-01-02", "1", "9", "8.91", "9", "6"], ["2013-01", "2013-01-07", "1", "14", "13.86", "23", "9"], ["2013-01", "2013-01-15", "1", "1", "0.99", "24", "14"], ["2013-01", "2013-01-28", "2", "4", "3.96", "28", "1"], ["2013-01", "2013-01-29", "1", "4", "3.96", "32", "4"], ["2013-01", "2013-01-30", "1", "6", "5.94", "38", "4"], ["2013-02", "2013-02-02", "1", "9", "8.91", "9", "6"], ["2013-02", "2013-02-07", "1", "14", "13.86", "23", "9"], ["2013-02", "2013-02-15", "1", "1", "0.99", "24", "14"], ["2013-02", "2013-02-28", "2", "4", "3.96", "28", "1"], ["2013-03", "2013-03-01", "1", "4", "3.96", "4", "4"], ["2013-03", "2013-03-02", "1", "6", "5.94", "10", "4"], ["2013-03", "2013-03-05", "1", "9", "8.91", "19", "6"], ["2013-03", "2013-03-10", "1", "14", "13.86", "33", "9"], ["2013-03", "2013-03-18", "1", "1", "0.99", "34", "14"], ["2013-03", "2013-03-31", "2", "4", "3.96", "38", "1"], ["2013-04", "2013-04-01", "1", "4", "3.96", "4", "4"], ["2013-04", "2013-04-02", "1", "6", "5.94", "10", "4"], ["2013-04", "2013-04-05", "1", "9", "8.91", "19", "6"], ["2013-04", "2013-04-10", "1", "14", "13.86", "33", "9"], ["2013-04", "2013-04-18", "1", "1", "0.99", "34", "14"], ["2013-05", "2013-05-01", "2", "4", "3.96", "4", "1"], ["2013-05", "2013-05-02", "1", "4", "3.96", "8", "4"], ["2013-05", "2013-05-03", "1", "6", "5.94", "14", "4"], ["2013-05", "2013-05-06", "1", "9", "8.91", "23", "6"], ["2013-05", "2013-05-11", "1", "14", "13.86", "37", "9"], ["2013-05", "2013-05-19", "1", "1", "0.99", "38", "14"], ["2013-06", "2013-06-01", "2", "4", "3.96", "4", "1"], ["2013-06", "2013-06-02", "1", "4", "3.96", "8", "4"], ["2013-06", "2013-06-03", "1", "6", "5.94", "14", "4"], ["2013-06", "2013-06-06", "1", "9", "8.91", "23", "6"], ["2013-06", "2013-06-11", "1", "14", "13.86", "37", "9"], ["2013-06", "2013-06-19", "1", "1", "0.99", "38", "14"], ["2013-07", "2013-07-02", "2", "4", "3.96", "4", "1"], ["2013-07", "2013-07-03", "1", "4", "3.96", "8", "4"], ["2013-07", "2013-07-04", "1", "6", "5.94", "14", "4"], ["2013-07", "2013-07-07", "1", "9", "8.91", "23", "6"], ["2013-07", "2013-07-12", "1", "14", "13.86", "37", "9"], ["2013-07", "2013-07-20", "1", "1", "0.99", "38", "14"], ["2013-08", "2013-08-02", "2", "4", "3.96", "4", "1"], ["2013-08", "2013-08-03", "1", "4", "3.96", "8", "4"], ["2013-08", "2013-08-04", "1", "6", "5.94", "14", "4"], ["2013-08", "2013-08-07", "1", "9", "8.91", "23", "6"], ["2013-08", "2013-08-12", "1", "14", "13.86", "37", "9"], ["2013-08", "2013-08-20", "1", "1", "0.99", "38", "14"], ["2013-09", "2013-09-02", "2", "4", "3.96", "4", "1"], ["2013-09", "2013-09-03", "1", "4", "3.96", "8", "4"], ["2013-09", "2013-09-04", "1", "6", "5.94", "14", "4"], ["2013-09", "2013-09-07", "1", "9", "8.91", "23", "6"], ["2013-09", "2013-09-12", "1", "14", "13.86", "37", "9"], ["2013-09", "2013-09-20", "1", "1", "0.99", "38", "14"], ["2013-10", "2013-10-03", "2", "4", "3.96", "4", "1"], ["2013-10", "2013-10-04", "1", "4", "3.96", "8", "4"], ["2013-10", "2013-10-05", "1", "6", "5.94", "14", "4"], ["2013-10", "2013-10-08", "1", "9", "8.91", "23", "6"], ["2013-10", "2013-10-13", "1", "14", "13.86", "37", "9"], ["2013-10", "2013-10-21", "1", "1", "0.99", "38", "14"], ["2013-11", "2013-11-03", "2", "4", "3.96", "4", "1"], ["2013-11", "2013-11-04", "1", "4", "3.96", "8", "4"], ["2013-11", "2013-11-05", "1", "6", "5.94", "14", "4"], ["2013-11", "2013-11-08", "1", "9", "8.91", "23", "6"], ["2013-11", "2013-11-13", "1", "14", "25.86", "37", "9"], ["2013-11", "2013-11-21", "1", "1", "0.99", "38", "14"], ["2013-12", "2013-12-04", "2", "4", "3.96", "4", "1"], ["2013-12", "2013-12-05", "1", "4", "3.96", "8", "4"], ["2013-12", "2013-12-06", "1", "6", "5.94", "14", "4"], ["2013-12", "2013-12-09", "1", "9", "8.91", "23", "6"], ["2013-12", "2013-12-14", "1", "14", "13.86", "37", "9"], ["2013-12", "2013-12-22", "1", "1", "1.99", "38", "14"]] diff --git a/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@loop.prql.snap b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@loop.prql.snap new file mode 100644 index 000000000000..58ff5dde5c95 --- /dev/null +++ b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@loop.prql.snap @@ -0,0 +1,6 @@ +--- +source: prql-compiler/tests/integration-rdbms/main.rs +expression: "format!(\"{:?}\", first_result.1)" +input_file: prql-compiler/tests/integration/queries/loop.prql +--- +[["-2"], ["0"], ["2"], ["4"], ["6"], ["8"]] diff --git a/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@pipelines.prql.snap b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@pipelines.prql.snap new file mode 100644 index 000000000000..1399a70119ed --- /dev/null +++ b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@pipelines.prql.snap @@ -0,0 +1,6 @@ +--- +source: prql-compiler/tests/integration-rdbms/main.rs +expression: "format!(\"{:?}\", first_result.1)" +input_file: prql-compiler/tests/integration/queries/pipelines.prql +--- +[["0", "20"], ["0", "21"], ["0", "22"], ["1", "23"], ["1", "24"], ["1", "25"]] diff --git a/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@set_ops_remove.prql.snap b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@set_ops_remove.prql.snap new file mode 100644 index 000000000000..59dd2b6211f1 --- /dev/null +++ b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@set_ops_remove.prql.snap @@ -0,0 +1,6 @@ +--- +source: prql-compiler/tests/integration-rdbms/main.rs +expression: "format!(\"{:?}\", first_result.1)" +input_file: prql-compiler/tests/integration/queries/set_ops_remove.prql +--- +[["3"]] diff --git a/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@switch.prql.snap b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@switch.prql.snap new file mode 100644 index 000000000000..d3a93beee26a --- /dev/null +++ b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@switch.prql.snap @@ -0,0 +1,6 @@ +--- +source: prql-compiler/tests/integration-rdbms/main.rs +expression: "format!(\"{:?}\", first_result.1)" +input_file: prql-compiler/tests/integration/queries/switch.prql +--- +[["Samuel Rosa", "1071"], ["no composer", "4884"], ["no composer", "6373"], ["no composer", "6635"], ["L. Muggerud", "7941"], ["no composer", "11650"], ["L. Muggerud", "21211"], ["unknown composer", "29048"], ["Gilberto Gil", "32287"], ["Chico Science", "33149"]] diff --git a/prql-compiler/tests/integration-rdbms/testcases.txt b/prql-compiler/tests/integration-rdbms/testcases.txt deleted file mode 100644 index 6a3ec7085d9d..000000000000 --- a/prql-compiler/tests/integration-rdbms/testcases.txt +++ /dev/null @@ -1,127 +0,0 @@ -from c=people -join ca=cars [ca.person==c.id] -filter ca.name=='Bugatti' -select c.name ---- -Tony Stark - -### - -from cars -filter (id | in 4..5) -sort [-name] -select name ---- -Toyota -Lamborghini - -### - -from people -join cars [cars.person==people.id] -group [people.name]( - aggregate [ - c = count, - ] -) -sort c ---- -Wade Wilson,1 -Bruce Wayne,2 -Tony Stark,3 - -### - -from cars -select [person] -group cars.* (take 1) -sort cars.person ---- -0 -1 -2 - -### - -let car_count = ( - from cars - aggregate a = count -) - -from car_count -filter a > 0 -select a ---- -6 - -### - -from people -join cars [cars.person==people.id] -group [people.id, people.name] (aggregate price = (sum cars.price)) -select ![people.id] -sort people.name ---- -Bruce Wayne,150000 -Tony Stark,1100000 -Wade Wilson,10000 - -### - -from cars -sort price -select p = case [ - price == null => 'priceless', - price < 40000 => 'cheap', - true => 'expensive' -] -take 3 ---- -cheap,10000 -expensive,60000 -expensive,90000 - -### - -from Upper -select id ---- -999 - -### - -func distinct rel -> (from t = _param.rel | group [t.*] (take 1)) - -from_text format:json '{ "columns": ["a"], "data": [[1], [2], [2], [3]] }' -distinct -remove (from_text format:json '{ "columns": ["a"], "data": [[1], [2]] }') ---- -3 - -### - -from cars -sort price -select price -take 2..4 ---- -60000 -90000 -200000 - -### - -from_text format:json '[{"n": 1 }]' -select n = n - 2 -loop ( - filter n<4 - select n = n+1 -) -select n = n * 2 ---- --2 -0 -2 -4 -6 -8 diff --git a/prql-compiler/tests/integration/data/chinook/employees.csv b/prql-compiler/tests/integration/data/chinook/employees.csv index cb61d44bbcb8..70842000f38a 100644 --- a/prql-compiler/tests/integration/data/chinook/employees.csv +++ b/prql-compiler/tests/integration/data/chinook/employees.csv @@ -1,5 +1,5 @@ employee_id,last_name,first_name,title,reports_to,birth_date,hire_date,address,city,state,country,postal_code,phone,fax,email -1,Adams,Andrew,General Manager,,1962-02-18T00:00:00.000000000,2002-08-14T00:00:00.000000000,11120 Jasper Ave NW,Edmonton,AB,Canada,T5K 2N1,+1 (780) 428-9482,+1 (780) 428-3457,andrew@chinookcorp.com +1,Adams,Andrew,General Manager,6,1962-02-18T00:00:00.000000000,2002-08-14T00:00:00.000000000,11120 Jasper Ave NW,Edmonton,AB,Canada,T5K 2N1,+1 (780) 428-9482,+1 (780) 428-3457,andrew@chinookcorp.com 2,Edwards,Nancy,Sales Manager,1,1958-12-08T00:00:00.000000000,2002-05-01T00:00:00.000000000,825 8 Ave SW,Calgary,AB,Canada,T2P 2T3,+1 (403) 262-3443,+1 (403) 262-3322,nancy@chinookcorp.com 3,Peacock,Jane,Sales Support Agent,2,1973-08-29T00:00:00.000000000,2002-04-01T00:00:00.000000000,1111 6 Ave SW,Calgary,AB,Canada,T2P 5M5,+1 (403) 262-3443,+1 (403) 262-6712,jane@chinookcorp.com 4,Park,Margaret,Sales Support Agent,2,1947-09-19T00:00:00.000000000,2003-05-03T00:00:00.000000000,683 10 Street SW,Calgary,AB,Canada,T2P 5G3,+1 (403) 263-4423,+1 (403) 263-4289,margaret@chinookcorp.com diff --git a/prql-compiler/tests/integration/queries/group_all.prql b/prql-compiler/tests/integration/queries/group_all.prql index a5a73e1c98ae..58d10065569f 100644 --- a/prql-compiler/tests/integration/queries/group_all.prql +++ b/prql-compiler/tests/integration/queries/group_all.prql @@ -1,5 +1,6 @@ +# skip_postgresql (real cannot be rounded) from a=albums -sort album_id take 10 join tracks [==album_id] -group [a.album_id, a.title] (aggregate price = (sum tracks.unit_price)) +group [a.album_id, a.title] (aggregate price = ((sum tracks.unit_price) | round 2)) +sort album_id diff --git a/prql-compiler/tests/integration/queries/invoice_totals.prql b/prql-compiler/tests/integration/queries/invoice_totals.prql index 45a1d4b80281..1206a1b1a2a3 100644 --- a/prql-compiler/tests/integration/queries/invoice_totals.prql +++ b/prql-compiler/tests/integration/queries/invoice_totals.prql @@ -1,3 +1,5 @@ +# skip_mysql +# skip_mssql from i=invoices join ii=invoice_items [==invoice_id] derive [ diff --git a/prql-compiler/tests/integration/queries/loop.prql b/prql-compiler/tests/integration/queries/loop.prql index e83d02e37057..0d6b320a41aa 100644 --- a/prql-compiler/tests/integration/queries/loop.prql +++ b/prql-compiler/tests/integration/queries/loop.prql @@ -1,3 +1,4 @@ +# skip_mssql from_text format:json '[{"n": 1 }]' select n = n - 2 loop ( diff --git a/prql-compiler/tests/integration/queries/pipelines.prql b/prql-compiler/tests/integration/queries/pipelines.prql index 2b3c6c6cf64a..739de3ca513e 100644 --- a/prql-compiler/tests/integration/queries/pipelines.prql +++ b/prql-compiler/tests/integration/queries/pipelines.prql @@ -1,3 +1,4 @@ +# skip_mssql from tracks sort track_id take 20..25 diff --git a/prql-compiler/tests/integration/queries/set_ops_remove.prql b/prql-compiler/tests/integration/queries/set_ops_remove.prql index 9f88bb59e0ef..1138681b4f3d 100644 --- a/prql-compiler/tests/integration/queries/set_ops_remove.prql +++ b/prql-compiler/tests/integration/queries/set_ops_remove.prql @@ -1,3 +1,4 @@ +# skip_mssql func distinct rel -> (from t = _param.rel | group [t.*] (take 1)) from_text format:json '{ "columns": ["a"], "data": [[1], [2], [2], [3]] }' diff --git a/prql-compiler/tests/integration/queries/switch.prql b/prql-compiler/tests/integration/queries/switch.prql index 7214c48fc708..3b0d03b02ab2 100644 --- a/prql-compiler/tests/integration/queries/switch.prql +++ b/prql-compiler/tests/integration/queries/switch.prql @@ -1,3 +1,6 @@ +# skip_mssql +# skip_mysql (mysql imports empty strings in csv as empty strings instead of null) +# skip_sqlite (see above) from tracks sort milliseconds select display = case [ diff --git a/prql-compiler/tests/integration/snapshots/integration__tests__test@group_all.prql.snap b/prql-compiler/tests/integration/snapshots/integration__tests__test@group_all.prql.snap index 1b5c0359f1bb..8d8930d5d4a1 100644 --- a/prql-compiler/tests/integration/snapshots/integration__tests__test@group_all.prql.snap +++ b/prql-compiler/tests/integration/snapshots/integration__tests__test@group_all.prql.snap @@ -6,11 +6,11 @@ input_file: prql-compiler/tests/integration/queries/group_all.prql album_id,title,price 1,For Those About To Rock We Salute You,9.9 2,Balls to the Wall,0.99 -3,Restless and Wild,2.9699999999999998 -4,Let There Be Rock,7.920000000000001 -5,Big Ones,14.850000000000001 -6,Jagged Little Pill,12.870000000000001 +3,Restless and Wild,2.97 +4,Let There Be Rock,7.92 +5,Big Ones,14.85 +6,Jagged Little Pill,12.87 7,Facelift,11.88 -8,Warner 25 Anos,13.860000000000001 -9,Plays Metallica By Four Cellos,7.920000000000001 -10,Audioslave,13.860000000000001 +8,Warner 25 Anos,13.86 +9,Plays Metallica By Four Cellos,7.92 +10,Audioslave,13.86 From 9d512f8261f52469ccb9537e9bf10ebfeb140cd5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 28 Mar 2023 16:43:37 +0000 Subject: [PATCH 20/29] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- prql-compiler/tests/integration-rdbms/conf/my.cnf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prql-compiler/tests/integration-rdbms/conf/my.cnf b/prql-compiler/tests/integration-rdbms/conf/my.cnf index e53a503aca3c..010d65225a43 100644 --- a/prql-compiler/tests/integration-rdbms/conf/my.cnf +++ b/prql-compiler/tests/integration-rdbms/conf/my.cnf @@ -1,2 +1,2 @@ [mysqld] -secure-file-priv= /tmp/chinook/ \ No newline at end of file +secure-file-priv= /tmp/chinook/ From 02b42d14a795ce0d251dd56c8b9de7bcac2eeb0b Mon Sep 17 00:00:00 2001 From: Jelenkee Date: Tue, 28 Mar 2023 19:13:13 +0200 Subject: [PATCH 21/29] -fixed sqlite --- prql-compiler/tests/integration-rdbms/connection.rs | 6 +++++- prql-compiler/tests/integration/queries/switch.prql | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/prql-compiler/tests/integration-rdbms/connection.rs b/prql-compiler/tests/integration-rdbms/connection.rs index 7eae3f823928..394d9c127bb7 100644 --- a/prql-compiler/tests/integration-rdbms/connection.rs +++ b/prql-compiler/tests/integration-rdbms/connection.rs @@ -158,7 +158,11 @@ impl DBConnection for SQLiteConnection { "INSERT INTO {csv_name} ({}) VALUES ({})", headers.iter().join(","), r.iter() - .map(|s| format!("\"{}\"", s.replace('"', "\"\""))) + .map(|s| if s.is_empty() { + "null".to_string() + } else { + format!("\"{}\"", s.replace('"', "\"\"")) + }) .join(",") ); self.run_query(q.as_str(), runtime); diff --git a/prql-compiler/tests/integration/queries/switch.prql b/prql-compiler/tests/integration/queries/switch.prql index 3b0d03b02ab2..8c7930f9004f 100644 --- a/prql-compiler/tests/integration/queries/switch.prql +++ b/prql-compiler/tests/integration/queries/switch.prql @@ -1,6 +1,5 @@ # skip_mssql # skip_mysql (mysql imports empty strings in csv as empty strings instead of null) -# skip_sqlite (see above) from tracks sort milliseconds select display = case [ From 0c1b74f4f06c2f27365b4cd3d13e424ec0157cd1 Mon Sep 17 00:00:00 2001 From: Jelenkee Date: Tue, 28 Mar 2023 23:05:00 +0200 Subject: [PATCH 22/29] =?UTF-8?q?added=20snaps=C2=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../integration_rdbms__tests__rdbms@distinct.prql.snap | 6 ++++++ .../integration_rdbms__tests__rdbms@genre_counts.prql.snap | 6 ++++++ .../integration_rdbms__tests__rdbms@group_all.prql.snap | 6 ++++++ ...integration_rdbms__tests__rdbms@invoice_totals.prql.snap | 6 ++++++ .../integration_rdbms__tests__rdbms@loop.prql.snap | 6 ++++++ .../integration_rdbms__tests__rdbms@pipelines.prql.snap | 6 ++++++ ...integration_rdbms__tests__rdbms@set_ops_remove.prql.snap | 6 ++++++ .../integration_rdbms__tests__rdbms@switch.prql.snap | 6 ++++++ 8 files changed, 48 insertions(+) create mode 100644 prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@distinct.prql.snap create mode 100644 prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@genre_counts.prql.snap create mode 100644 prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@group_all.prql.snap create mode 100644 prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@invoice_totals.prql.snap create mode 100644 prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@loop.prql.snap create mode 100644 prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@pipelines.prql.snap create mode 100644 prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@set_ops_remove.prql.snap create mode 100644 prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@switch.prql.snap diff --git a/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@distinct.prql.snap b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@distinct.prql.snap new file mode 100644 index 000000000000..0ae946546223 --- /dev/null +++ b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@distinct.prql.snap @@ -0,0 +1,6 @@ +--- +source: prql-compiler/tests/integration-rdbms/main.rs +expression: "format!(\"{:?}\", first_result.1)" +input_file: prql-compiler/tests/integration/queries/distinct.prql +--- +[["1", "1"], ["2", "1"], ["3", "1"], ["4", "1"], ["5", "1"], ["6", "1"], ["7", "1"], ["8", "2"], ["9", "3"], ["10", "1"], ["11", "4"], ["12", "5"], ["13", "2"], ["14", "3"], ["15", "3"], ["16", "3"], ["17", "3"], ["18", "4"], ["19", "3"], ["20", "6"], ["21", "7"], ["22", "7"], ["23", "7"], ["24", "7"], ["25", "7"], ["26", "8"], ["27", "8"], ["28", "7"], ["29", "9"], ["30", "1"], ["31", "1"], ["32", "10"], ["33", "7"], ["34", "7"], ["35", "3"], ["36", "1"], ["37", "1"], ["38", "2"], ["39", "4"], ["40", "1"], ["41", "7"], ["42", "4"], ["43", "1"], ["44", "1"], ["45", "7"], ["46", "1"], ["47", "7"], ["48", "2"], ["49", "2"], ["50", "1"], ["51", "2"], ["52", "11"], ["53", "7"], ["54", "1"], ["55", "1"], ["56", "7"], ["57", "7"], ["58", "1"], ["59", "1"], ["60", "1"], ["61", "1"], ["62", "1"], ["63", "1"], ["64", "1"], ["65", "1"], ["66", "1"], ["67", "1"], ["68", "2"], ["69", "7"], ["70", "7"], ["71", "7"], ["72", "6"], ["73", "6"], ["73", "7"], ["74", "4"], ["75", "4"], ["76", "1"], ["77", "4"], ["78", "7"], ["79", "1"], ["80", "1"], ["81", "4"], ["82", "1"], ["83", "12"], ["84", "7"], ["85", "10"], ["86", "7"], ["87", "2"], ["88", "3"], ["89", "4"], ["90", "1"], ["91", "1"], ["92", "3"], ["93", "2"], ["94", "1"], ["95", "3"], ["96", "3"], ["97", "1"], ["98", "13"], ["99", "1"], ["100", "6"], ["101", "13"], ["102", "3"], ["102", "13"], ["103", "1"], ["104", "1"], ["105", "3"], ["106", "3"], ["107", "3"], ["108", "3"], ["109", "1"], ["109", "3"], ["110", "3"], ["111", "3"], ["112", "1"], ["112", "3"], ["113", "1"], ["114", "1"], ["115", "14"], ["116", "1"], ["117", "14"], ["118", "15"], ["119", "4"], ["120", "1"], ["121", "1"], ["122", "7"], ["123", "7"], ["124", "16"], ["125", "3"], ["126", "1"], ["127", "1"], ["128", "1"], ["129", "1"], ["130", "1"], ["131", "1"], ["132", "1"], ["133", "1"], ["134", "1"], ["135", "1"], ["136", "1"], ["137", "1"], ["138", "1"], ["139", "7"], ["140", "7"], ["141", "1"], ["141", "3"], ["141", "8"], ["142", "7"], ["143", "7"], ["144", "1"], ["145", "7"], ["146", "14"], ["147", "1"], ["148", "3"], ["149", "3"], ["150", "3"], ["151", "3"], ["152", "3"], ["153", "3"], ["154", "3"], ["155", "3"], ["156", "3"], ["157", "2"], ["158", "7"], ["159", "7"], ["160", "3"], ["161", "16"], ["162", "3"], ["163", "1"], ["164", "1"], ["165", "1"], ["166", "7"], ["167", "7"], ["168", "7"], ["169", "7"], ["170", "1"], ["171", "1"], ["172", "1"], ["173", "1"], ["174", "3"], ["175", "1"], ["176", "10"], ["177", "1"], ["178", "1"], ["179", "4"], ["180", "1"], ["181", "1"], ["182", "1"], ["183", "1"], ["184", "17"], ["185", "1"], ["186", "1"], ["187", "4"], ["188", "4"], ["189", "1"], ["190", "4"], ["191", "4"], ["192", "1"], ["193", "4"], ["194", "1"], ["195", "1"], ["196", "1"], ["197", "1"], ["198", "1"], ["199", "1"], ["200", "1"], ["201", "4"], ["202", "4"], ["203", "1"], ["204", "2"], ["205", "6"], ["206", "1"], ["207", "3"], ["208", "1"], ["209", "6"], ["210", "6"], ["211", "4"], ["212", "1"], ["213", "1"], ["214", "1"], ["215", "1"], ["216", "1"], ["217", "1"], ["218", "1"], ["219", "4"], ["220", "4"], ["221", "1"], ["222", "7"], ["223", "7"], ["224", "4"], ["225", "4"], ["226", "18"], ["227", "18"], ["227", "19"], ["227", "20"], ["228", "19"], ["228", "21"], ["229", "19"], ["229", "21"], ["230", "19"], ["231", "19"], ["231", "21"], ["232", "1"], ["233", "1"], ["234", "1"], ["235", "1"], ["236", "1"], ["237", "1"], ["238", "1"], ["239", "1"], ["240", "1"], ["241", "8"], ["242", "1"], ["243", "1"], ["244", "1"], ["245", "1"], ["246", "1"], ["247", "7"], ["248", "7"], ["249", "19"], ["250", "19"], ["251", "19"], ["251", "22"], ["252", "1"], ["253", "20"], ["254", "19"], ["255", "9"], ["256", "1"], ["257", "1"], ["258", "17"], ["259", "15"], ["260", "23"], ["261", "19"], ["261", "21"], ["262", "2"], ["263", "16"], ["264", "15"], ["265", "1"], ["266", "7"], ["267", "2"], ["268", "24"], ["269", "23"], ["270", "23"], ["271", "23"], ["272", "24"], ["273", "24"], ["274", "24"], ["275", "24"], ["276", "24"], ["277", "24"], ["278", "24"], ["279", "24"], ["280", "24"], ["281", "24"], ["282", "24"], ["283", "24"], ["284", "24"], ["285", "24"], ["286", "24"], ["287", "24"], ["288", "24"], ["289", "24"], ["290", "24"], ["291", "24"], ["292", "24"], ["293", "24"], ["294", "24"], ["295", "24"], ["296", "24"], ["297", "24"], ["298", "24"], ["299", "24"], ["300", "24"], ["301", "24"], ["302", "24"], ["303", "24"], ["304", "24"], ["305", "24"], ["306", "24"], ["307", "24"], ["308", "24"], ["309", "24"], ["310", "24"], ["311", "24"], ["312", "24"], ["313", "24"], ["314", "24"], ["315", "24"], ["316", "24"], ["317", "25"], ["318", "24"], ["319", "24"], ["320", "24"], ["321", "14"], ["322", "9"], ["323", "23"], ["324", "24"], ["325", "24"], ["326", "24"], ["327", "24"], ["328", "24"], ["329", "24"], ["330", "24"], ["331", "24"], ["332", "24"], ["333", "24"], ["334", "24"], ["335", "24"], ["336", "24"], ["337", "24"], ["338", "24"], ["339", "24"], ["340", "24"], ["341", "24"], ["342", "24"], ["343", "24"], ["344", "24"], ["345", "24"], ["346", "24"], ["347", "10"]] diff --git a/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@genre_counts.prql.snap b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@genre_counts.prql.snap new file mode 100644 index 000000000000..2751f9165721 --- /dev/null +++ b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@genre_counts.prql.snap @@ -0,0 +1,6 @@ +--- +source: prql-compiler/tests/integration-rdbms/main.rs +expression: "format!(\"{:?}\", first_result.1)" +input_file: prql-compiler/tests/integration/queries/genre_counts.prql +--- +[["-25"]] diff --git a/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@group_all.prql.snap b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@group_all.prql.snap new file mode 100644 index 000000000000..adcfc49c15ac --- /dev/null +++ b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@group_all.prql.snap @@ -0,0 +1,6 @@ +--- +source: prql-compiler/tests/integration-rdbms/main.rs +expression: "format!(\"{:?}\", first_result.1)" +input_file: prql-compiler/tests/integration/queries/group_all.prql +--- +[["1", "For Those About To Rock We Salute You", "9.9"], ["2", "Balls to the Wall", "0.99"], ["3", "Restless and Wild", "2.97"], ["4", "Let There Be Rock", "7.92"], ["5", "Big Ones", "14.85"], ["6", "Jagged Little Pill", "12.87"], ["7", "Facelift", "11.88"], ["8", "Warner 25 Anos", "13.86"], ["9", "Plays Metallica By Four Cellos", "7.92"], ["10", "Audioslave", "13.86"]] diff --git a/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@invoice_totals.prql.snap b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@invoice_totals.prql.snap new file mode 100644 index 000000000000..f9bfc736e21c --- /dev/null +++ b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@invoice_totals.prql.snap @@ -0,0 +1,6 @@ +--- +source: prql-compiler/tests/integration-rdbms/main.rs +expression: "format!(\"{:?}\", first_result.1)" +input_file: prql-compiler/tests/integration/queries/invoice_totals.prql +--- +[["2009-01", "2009-01-01", "1", "2", "1.98", "2", ""], ["2009-01", "2009-01-02", "1", "4", "3.96", "6", ""], ["2009-01", "2009-01-03", "1", "6", "5.94", "12", ""], ["2009-01", "2009-01-06", "1", "9", "8.91", "21", ""], ["2009-01", "2009-01-11", "1", "14", "13.86", "35", ""], ["2009-01", "2009-01-19", "1", "1", "0.99", "36", ""], ["2009-02", "2009-02-01", "2", "4", "3.96", "4", ""], ["2009-02", "2009-02-02", "1", "4", "3.96", "8", "2"], ["2009-02", "2009-02-03", "1", "6", "5.94", "14", "4"], ["2009-02", "2009-02-06", "1", "9", "8.91", "23", "6"], ["2009-02", "2009-02-11", "1", "14", "13.86", "37", "9"], ["2009-02", "2009-02-19", "1", "1", "0.99", "38", "14"], ["2009-03", "2009-03-04", "2", "4", "3.96", "4", "1"], ["2009-03", "2009-03-05", "1", "4", "3.96", "8", "4"], ["2009-03", "2009-03-06", "1", "6", "5.94", "14", "4"], ["2009-03", "2009-03-09", "1", "9", "8.91", "23", "6"], ["2009-03", "2009-03-14", "1", "14", "13.86", "37", "9"], ["2009-03", "2009-03-22", "1", "1", "0.99", "38", "14"], ["2009-04", "2009-04-04", "2", "4", "3.96", "4", "1"], ["2009-04", "2009-04-05", "1", "4", "3.96", "8", "4"], ["2009-04", "2009-04-06", "1", "6", "5.94", "14", "4"], ["2009-04", "2009-04-09", "1", "9", "8.91", "23", "6"], ["2009-04", "2009-04-14", "1", "14", "13.86", "37", "9"], ["2009-04", "2009-04-22", "1", "1", "0.99", "38", "14"], ["2009-05", "2009-05-05", "2", "4", "3.96", "4", "1"], ["2009-05", "2009-05-06", "1", "4", "3.96", "8", "4"], ["2009-05", "2009-05-07", "1", "6", "5.94", "14", "4"], ["2009-05", "2009-05-10", "1", "9", "8.91", "23", "6"], ["2009-05", "2009-05-15", "1", "14", "13.86", "37", "9"], ["2009-05", "2009-05-23", "1", "1", "0.99", "38", "14"], ["2009-06", "2009-06-05", "2", "4", "3.96", "4", "1"], ["2009-06", "2009-06-06", "1", "4", "3.96", "8", "4"], ["2009-06", "2009-06-07", "1", "6", "5.94", "14", "4"], ["2009-06", "2009-06-10", "1", "9", "8.91", "23", "6"], ["2009-06", "2009-06-15", "1", "14", "13.86", "37", "9"], ["2009-06", "2009-06-23", "1", "1", "0.99", "38", "14"], ["2009-07", "2009-07-06", "2", "4", "3.96", "4", "1"], ["2009-07", "2009-07-07", "1", "4", "3.96", "8", "4"], ["2009-07", "2009-07-08", "1", "6", "5.94", "14", "4"], ["2009-07", "2009-07-11", "1", "9", "8.91", "23", "6"], ["2009-07", "2009-07-16", "1", "14", "13.86", "37", "9"], ["2009-07", "2009-07-24", "1", "1", "0.99", "38", "14"], ["2009-08", "2009-08-06", "2", "4", "3.96", "4", "1"], ["2009-08", "2009-08-07", "1", "4", "3.96", "8", "4"], ["2009-08", "2009-08-08", "1", "6", "5.94", "14", "4"], ["2009-08", "2009-08-11", "1", "9", "8.91", "23", "6"], ["2009-08", "2009-08-16", "1", "14", "13.86", "37", "9"], ["2009-08", "2009-08-24", "1", "1", "0.99", "38", "14"], ["2009-09", "2009-09-06", "2", "4", "3.96", "4", "1"], ["2009-09", "2009-09-07", "1", "4", "3.96", "8", "4"], ["2009-09", "2009-09-08", "1", "6", "5.94", "14", "4"], ["2009-09", "2009-09-11", "1", "9", "8.91", "23", "6"], ["2009-09", "2009-09-16", "1", "14", "13.86", "37", "9"], ["2009-09", "2009-09-24", "1", "1", "0.99", "38", "14"], ["2009-10", "2009-10-07", "2", "4", "3.96", "4", "1"], ["2009-10", "2009-10-08", "1", "4", "3.96", "8", "4"], ["2009-10", "2009-10-09", "1", "6", "5.94", "14", "4"], ["2009-10", "2009-10-12", "1", "9", "8.91", "23", "6"], ["2009-10", "2009-10-17", "1", "14", "13.86", "37", "9"], ["2009-10", "2009-10-25", "1", "1", "0.99", "38", "14"], ["2009-11", "2009-11-07", "2", "4", "3.96", "4", "1"], ["2009-11", "2009-11-08", "1", "4", "3.96", "8", "4"], ["2009-11", "2009-11-09", "1", "6", "5.94", "14", "4"], ["2009-11", "2009-11-12", "1", "9", "8.91", "23", "6"], ["2009-11", "2009-11-17", "1", "14", "13.86", "37", "9"], ["2009-11", "2009-11-25", "1", "1", "0.99", "38", "14"], ["2009-12", "2009-12-08", "2", "4", "3.96", "4", "1"], ["2009-12", "2009-12-09", "1", "4", "3.96", "8", "4"], ["2009-12", "2009-12-10", "1", "6", "5.94", "14", "4"], ["2009-12", "2009-12-13", "1", "9", "8.91", "23", "6"], ["2009-12", "2009-12-18", "1", "14", "13.86", "37", "9"], ["2009-12", "2009-12-26", "1", "1", "0.99", "38", "14"], ["2010-01", "2010-01-08", "2", "4", "3.96", "4", "1"], ["2010-01", "2010-01-09", "1", "4", "3.96", "8", "4"], ["2010-01", "2010-01-10", "1", "6", "6.94", "14", "4"], ["2010-01", "2010-01-13", "1", "9", "17.91", "23", "6"], ["2010-01", "2010-01-18", "1", "14", "18.86", "37", "9"], ["2010-01", "2010-01-26", "1", "1", "0.99", "38", "14"], ["2010-02", "2010-02-08", "2", "4", "3.96", "4", "1"], ["2010-02", "2010-02-09", "1", "4", "3.96", "8", "4"], ["2010-02", "2010-02-10", "1", "6", "5.94", "14", "4"], ["2010-02", "2010-02-13", "1", "9", "8.91", "23", "6"], ["2010-02", "2010-02-18", "1", "14", "21.86", "37", "9"], ["2010-02", "2010-02-26", "1", "1", "1.99", "38", "14"], ["2010-03", "2010-03-11", "2", "4", "7.96", "4", "1"], ["2010-03", "2010-03-12", "1", "4", "3.96", "8", "4"], ["2010-03", "2010-03-13", "1", "6", "5.94", "14", "4"], ["2010-03", "2010-03-16", "1", "9", "9.91", "23", "6"], ["2010-03", "2010-03-21", "1", "14", "15.86", "37", "9"], ["2010-03", "2010-03-29", "1", "1", "0.99", "38", "14"], ["2010-04", "2010-04-11", "2", "4", "3.96", "4", "1"], ["2010-04", "2010-04-12", "1", "4", "3.96", "8", "4"], ["2010-04", "2010-04-13", "1", "6", "5.94", "14", "4"], ["2010-04", "2010-04-16", "1", "9", "8.91", "23", "6"], ["2010-04", "2010-04-21", "1", "14", "13.86", "37", "9"], ["2010-04", "2010-04-29", "1", "1", "0.99", "38", "14"], ["2010-05", "2010-05-12", "2", "4", "3.96", "4", "1"], ["2010-05", "2010-05-13", "1", "4", "3.96", "8", "4"], ["2010-05", "2010-05-14", "1", "6", "5.94", "14", "4"], ["2010-05", "2010-05-17", "1", "9", "8.91", "23", "6"], ["2010-05", "2010-05-22", "1", "14", "13.86", "37", "9"], ["2010-05", "2010-05-30", "1", "1", "0.99", "38", "14"], ["2010-06", "2010-06-12", "2", "4", "3.96", "4", "1"], ["2010-06", "2010-06-13", "1", "4", "3.96", "8", "4"], ["2010-06", "2010-06-14", "1", "6", "5.94", "14", "4"], ["2010-06", "2010-06-17", "1", "9", "8.91", "23", "6"], ["2010-06", "2010-06-22", "1", "14", "13.86", "37", "9"], ["2010-06", "2010-06-30", "1", "1", "0.99", "38", "14"], ["2010-07", "2010-07-13", "2", "4", "3.96", "4", "1"], ["2010-07", "2010-07-14", "1", "4", "3.96", "8", "4"], ["2010-07", "2010-07-15", "1", "6", "5.94", "14", "4"], ["2010-07", "2010-07-18", "1", "9", "8.91", "23", "6"], ["2010-07", "2010-07-23", "1", "14", "13.86", "37", "9"], ["2010-07", "2010-07-31", "1", "1", "0.99", "38", "14"], ["2010-08", "2010-08-13", "2", "4", "3.96", "4", "1"], ["2010-08", "2010-08-14", "1", "4", "3.96", "8", "4"], ["2010-08", "2010-08-15", "1", "6", "5.94", "14", "4"], ["2010-08", "2010-08-18", "1", "9", "8.91", "23", "6"], ["2010-08", "2010-08-23", "1", "14", "13.86", "37", "9"], ["2010-08", "2010-08-31", "1", "1", "0.99", "38", "14"], ["2010-09", "2010-09-13", "2", "4", "3.96", "4", "1"], ["2010-09", "2010-09-14", "1", "4", "3.96", "8", "4"], ["2010-09", "2010-09-15", "1", "6", "5.94", "14", "4"], ["2010-09", "2010-09-18", "1", "9", "8.91", "23", "6"], ["2010-09", "2010-09-23", "1", "14", "13.86", "37", "9"], ["2010-10", "2010-10-01", "1", "1", "0.99", "1", "14"], ["2010-10", "2010-10-14", "2", "4", "3.96", "5", "1"], ["2010-10", "2010-10-15", "1", "4", "3.96", "9", "4"], ["2010-10", "2010-10-16", "1", "6", "5.94", "15", "4"], ["2010-10", "2010-10-19", "1", "9", "8.91", "24", "6"], ["2010-10", "2010-10-24", "1", "14", "13.86", "38", "9"], ["2010-11", "2010-11-01", "1", "1", "0.99", "1", "14"], ["2010-11", "2010-11-14", "2", "4", "3.96", "5", "1"], ["2010-11", "2010-11-15", "1", "4", "3.96", "9", "4"], ["2010-11", "2010-11-16", "1", "6", "5.94", "15", "4"], ["2010-11", "2010-11-19", "1", "9", "8.91", "24", "6"], ["2010-11", "2010-11-24", "1", "14", "13.86", "38", "9"], ["2010-12", "2010-12-02", "1", "1", "0.99", "1", "14"], ["2010-12", "2010-12-15", "2", "4", "3.96", "5", "1"], ["2010-12", "2010-12-16", "1", "4", "3.96", "9", "4"], ["2010-12", "2010-12-17", "1", "6", "5.94", "15", "4"], ["2010-12", "2010-12-20", "1", "9", "8.91", "24", "6"], ["2010-12", "2010-12-25", "1", "14", "13.86", "38", "9"], ["2011-01", "2011-01-02", "1", "1", "0.99", "1", "14"], ["2011-01", "2011-01-15", "2", "4", "3.96", "5", "1"], ["2011-01", "2011-01-16", "1", "4", "3.96", "9", "4"], ["2011-01", "2011-01-17", "1", "6", "5.94", "15", "4"], ["2011-01", "2011-01-20", "1", "9", "8.91", "24", "6"], ["2011-01", "2011-01-25", "1", "14", "13.86", "38", "9"], ["2011-02", "2011-02-02", "1", "1", "0.99", "1", "14"], ["2011-02", "2011-02-15", "2", "4", "3.96", "5", "1"], ["2011-02", "2011-02-16", "1", "4", "3.96", "9", "4"], ["2011-02", "2011-02-17", "1", "6", "5.94", "15", "4"], ["2011-02", "2011-02-20", "1", "9", "8.91", "24", "6"], ["2011-02", "2011-02-25", "1", "14", "13.86", "38", "9"], ["2011-03", "2011-03-05", "1", "1", "0.99", "1", "14"], ["2011-03", "2011-03-18", "2", "4", "3.96", "5", "1"], ["2011-03", "2011-03-19", "1", "4", "3.96", "9", "4"], ["2011-03", "2011-03-20", "1", "6", "5.94", "15", "4"], ["2011-03", "2011-03-23", "1", "9", "8.91", "24", "6"], ["2011-03", "2011-03-28", "1", "14", "13.86", "38", "9"], ["2011-04", "2011-04-05", "1", "1", "0.99", "1", "14"], ["2011-04", "2011-04-18", "2", "4", "3.96", "5", "1"], ["2011-04", "2011-04-19", "1", "4", "3.96", "9", "4"], ["2011-04", "2011-04-20", "1", "6", "5.94", "15", "4"], ["2011-04", "2011-04-23", "1", "9", "14.91", "24", "6"], ["2011-04", "2011-04-28", "1", "14", "21.86", "38", "9"], ["2011-05", "2011-05-06", "1", "1", "0.99", "1", "14"], ["2011-05", "2011-05-19", "2", "4", "3.96", "5", "1"], ["2011-05", "2011-05-20", "1", "4", "3.96", "9", "4"], ["2011-05", "2011-05-21", "1", "6", "5.94", "15", "4"], ["2011-05", "2011-05-24", "1", "9", "8.91", "24", "6"], ["2011-05", "2011-05-29", "1", "14", "18.86", "38", "9"], ["2011-06", "2011-06-06", "1", "1", "1.99", "1", "14"], ["2011-06", "2011-06-19", "2", "4", "6.96", "5", "1"], ["2011-06", "2011-06-20", "1", "4", "7.96", "9", "4"], ["2011-06", "2011-06-21", "1", "6", "8.94", "15", "4"], ["2011-06", "2011-06-24", "1", "9", "8.91", "24", "6"], ["2011-06", "2011-06-29", "1", "14", "15.86", "38", "9"], ["2011-07", "2011-07-07", "1", "1", "0.99", "1", "14"], ["2011-07", "2011-07-20", "2", "4", "3.96", "5", "1"], ["2011-07", "2011-07-21", "1", "4", "3.96", "9", "4"], ["2011-07", "2011-07-22", "1", "6", "5.94", "15", "4"], ["2011-07", "2011-07-25", "1", "9", "8.91", "24", "6"], ["2011-07", "2011-07-30", "1", "14", "13.86", "38", "9"], ["2011-08", "2011-08-07", "1", "1", "0.99", "1", "14"], ["2011-08", "2011-08-20", "2", "4", "3.96", "5", "1"], ["2011-08", "2011-08-21", "1", "4", "3.96", "9", "4"], ["2011-08", "2011-08-22", "1", "6", "5.94", "15", "4"], ["2011-08", "2011-08-25", "1", "9", "8.91", "24", "6"], ["2011-08", "2011-08-30", "1", "14", "13.86", "38", "9"], ["2011-09", "2011-09-07", "1", "1", "0.99", "1", "14"], ["2011-09", "2011-09-20", "2", "4", "3.96", "5", "1"], ["2011-09", "2011-09-21", "1", "4", "3.96", "9", "4"], ["2011-09", "2011-09-22", "1", "6", "5.94", "15", "4"], ["2011-09", "2011-09-25", "1", "9", "8.91", "24", "6"], ["2011-09", "2011-09-30", "1", "14", "13.86", "38", "9"], ["2011-10", "2011-10-08", "1", "1", "0.99", "1", "14"], ["2011-10", "2011-10-21", "2", "4", "3.96", "5", "1"], ["2011-10", "2011-10-22", "1", "4", "3.96", "9", "4"], ["2011-10", "2011-10-23", "1", "6", "5.94", "15", "4"], ["2011-10", "2011-10-26", "1", "9", "8.91", "24", "6"], ["2011-10", "2011-10-31", "1", "14", "13.86", "38", "9"], ["2011-11", "2011-11-08", "1", "1", "0.99", "1", "14"], ["2011-11", "2011-11-21", "2", "4", "3.96", "5", "1"], ["2011-11", "2011-11-22", "1", "4", "3.96", "9", "4"], ["2011-11", "2011-11-23", "1", "6", "5.94", "15", "4"], ["2011-11", "2011-11-26", "1", "9", "8.91", "24", "6"], ["2011-12", "2011-12-01", "1", "14", "13.86", "14", "9"], ["2011-12", "2011-12-09", "1", "1", "0.99", "15", "14"], ["2011-12", "2011-12-22", "2", "4", "3.96", "19", "1"], ["2011-12", "2011-12-23", "1", "4", "3.96", "23", "4"], ["2011-12", "2011-12-24", "1", "6", "5.94", "29", "4"], ["2011-12", "2011-12-27", "1", "9", "8.91", "38", "6"], ["2012-01", "2012-01-01", "1", "14", "13.86", "14", "9"], ["2012-01", "2012-01-09", "1", "1", "0.99", "15", "14"], ["2012-01", "2012-01-22", "2", "4", "3.96", "19", "1"], ["2012-01", "2012-01-23", "1", "4", "3.96", "23", "4"], ["2012-01", "2012-01-24", "1", "6", "5.94", "29", "4"], ["2012-01", "2012-01-27", "1", "9", "8.91", "38", "6"], ["2012-02", "2012-02-01", "1", "14", "13.86", "14", "9"], ["2012-02", "2012-02-09", "1", "1", "0.99", "15", "14"], ["2012-02", "2012-02-22", "2", "4", "3.96", "19", "1"], ["2012-02", "2012-02-23", "1", "4", "3.96", "23", "4"], ["2012-02", "2012-02-24", "1", "6", "5.94", "29", "4"], ["2012-02", "2012-02-27", "1", "9", "8.91", "38", "6"], ["2012-03", "2012-03-03", "1", "14", "13.86", "14", "9"], ["2012-03", "2012-03-11", "1", "1", "0.99", "15", "14"], ["2012-03", "2012-03-24", "2", "4", "3.96", "19", "1"], ["2012-03", "2012-03-25", "1", "4", "3.96", "23", "4"], ["2012-03", "2012-03-26", "1", "6", "5.94", "29", "4"], ["2012-03", "2012-03-29", "1", "9", "8.91", "38", "6"], ["2012-04", "2012-04-03", "1", "14", "13.86", "14", "9"], ["2012-04", "2012-04-11", "1", "1", "0.99", "15", "14"], ["2012-04", "2012-04-24", "2", "4", "3.96", "19", "1"], ["2012-04", "2012-04-25", "1", "4", "3.96", "23", "4"], ["2012-04", "2012-04-26", "1", "6", "5.94", "29", "4"], ["2012-04", "2012-04-29", "1", "9", "8.91", "38", "6"], ["2012-05", "2012-05-04", "1", "14", "13.86", "14", "9"], ["2012-05", "2012-05-12", "1", "1", "0.99", "15", "14"], ["2012-05", "2012-05-25", "2", "4", "3.96", "19", "1"], ["2012-05", "2012-05-26", "1", "4", "3.96", "23", "4"], ["2012-05", "2012-05-27", "1", "6", "5.94", "29", "4"], ["2012-05", "2012-05-30", "1", "9", "8.91", "38", "6"], ["2012-06", "2012-06-04", "1", "14", "13.86", "14", "9"], ["2012-06", "2012-06-12", "1", "1", "0.99", "15", "14"], ["2012-06", "2012-06-25", "2", "4", "3.96", "19", "1"], ["2012-06", "2012-06-26", "1", "4", "3.96", "23", "4"], ["2012-06", "2012-06-27", "1", "6", "5.94", "29", "4"], ["2012-06", "2012-06-30", "1", "9", "8.91", "38", "6"], ["2012-07", "2012-07-05", "1", "14", "13.86", "14", "9"], ["2012-07", "2012-07-13", "1", "1", "0.99", "15", "14"], ["2012-07", "2012-07-26", "2", "4", "3.96", "19", "1"], ["2012-07", "2012-07-27", "1", "4", "3.96", "23", "4"], ["2012-07", "2012-07-28", "1", "6", "5.94", "29", "4"], ["2012-07", "2012-07-31", "1", "9", "10.91", "38", "6"], ["2012-08", "2012-08-05", "1", "14", "23.86", "14", "9"], ["2012-08", "2012-08-13", "1", "1", "0.99", "15", "14"], ["2012-08", "2012-08-26", "2", "4", "3.96", "19", "1"], ["2012-08", "2012-08-27", "1", "4", "3.96", "23", "4"], ["2012-08", "2012-08-28", "1", "6", "5.94", "29", "4"], ["2012-08", "2012-08-31", "1", "9", "8.91", "38", "6"], ["2012-09", "2012-09-05", "1", "14", "16.86", "14", "9"], ["2012-09", "2012-09-13", "1", "1", "1.99", "15", "14"], ["2012-09", "2012-09-26", "2", "4", "7.96", "19", "1"], ["2012-09", "2012-09-27", "1", "4", "7.96", "23", "4"], ["2012-09", "2012-09-28", "1", "6", "11.94", "29", "4"], ["2012-10", "2012-10-01", "1", "9", "10.91", "9", "6"], ["2012-10", "2012-10-06", "1", "14", "16.86", "23", "9"], ["2012-10", "2012-10-14", "1", "1", "0.99", "24", "14"], ["2012-10", "2012-10-27", "2", "4", "3.96", "28", "1"], ["2012-10", "2012-10-28", "1", "4", "3.96", "32", "4"], ["2012-10", "2012-10-29", "1", "6", "5.94", "38", "4"], ["2012-11", "2012-11-01", "1", "9", "8.91", "9", "6"], ["2012-11", "2012-11-06", "1", "14", "13.86", "23", "9"], ["2012-11", "2012-11-14", "1", "1", "0.99", "24", "14"], ["2012-11", "2012-11-27", "2", "4", "3.96", "28", "1"], ["2012-11", "2012-11-28", "1", "4", "3.96", "32", "4"], ["2012-11", "2012-11-29", "1", "6", "5.94", "38", "4"], ["2012-12", "2012-12-02", "1", "9", "8.91", "9", "6"], ["2012-12", "2012-12-07", "1", "14", "13.86", "23", "9"], ["2012-12", "2012-12-15", "1", "1", "0.99", "24", "14"], ["2012-12", "2012-12-28", "2", "4", "3.96", "28", "1"], ["2012-12", "2012-12-29", "1", "4", "3.96", "32", "4"], ["2012-12", "2012-12-30", "1", "6", "5.94", "38", "4"], ["2013-01", "2013-01-02", "1", "9", "8.91", "9", "6"], ["2013-01", "2013-01-07", "1", "14", "13.86", "23", "9"], ["2013-01", "2013-01-15", "1", "1", "0.99", "24", "14"], ["2013-01", "2013-01-28", "2", "4", "3.96", "28", "1"], ["2013-01", "2013-01-29", "1", "4", "3.96", "32", "4"], ["2013-01", "2013-01-30", "1", "6", "5.94", "38", "4"], ["2013-02", "2013-02-02", "1", "9", "8.91", "9", "6"], ["2013-02", "2013-02-07", "1", "14", "13.86", "23", "9"], ["2013-02", "2013-02-15", "1", "1", "0.99", "24", "14"], ["2013-02", "2013-02-28", "2", "4", "3.96", "28", "1"], ["2013-03", "2013-03-01", "1", "4", "3.96", "4", "4"], ["2013-03", "2013-03-02", "1", "6", "5.94", "10", "4"], ["2013-03", "2013-03-05", "1", "9", "8.91", "19", "6"], ["2013-03", "2013-03-10", "1", "14", "13.86", "33", "9"], ["2013-03", "2013-03-18", "1", "1", "0.99", "34", "14"], ["2013-03", "2013-03-31", "2", "4", "3.96", "38", "1"], ["2013-04", "2013-04-01", "1", "4", "3.96", "4", "4"], ["2013-04", "2013-04-02", "1", "6", "5.94", "10", "4"], ["2013-04", "2013-04-05", "1", "9", "8.91", "19", "6"], ["2013-04", "2013-04-10", "1", "14", "13.86", "33", "9"], ["2013-04", "2013-04-18", "1", "1", "0.99", "34", "14"], ["2013-05", "2013-05-01", "2", "4", "3.96", "4", "1"], ["2013-05", "2013-05-02", "1", "4", "3.96", "8", "4"], ["2013-05", "2013-05-03", "1", "6", "5.94", "14", "4"], ["2013-05", "2013-05-06", "1", "9", "8.91", "23", "6"], ["2013-05", "2013-05-11", "1", "14", "13.86", "37", "9"], ["2013-05", "2013-05-19", "1", "1", "0.99", "38", "14"], ["2013-06", "2013-06-01", "2", "4", "3.96", "4", "1"], ["2013-06", "2013-06-02", "1", "4", "3.96", "8", "4"], ["2013-06", "2013-06-03", "1", "6", "5.94", "14", "4"], ["2013-06", "2013-06-06", "1", "9", "8.91", "23", "6"], ["2013-06", "2013-06-11", "1", "14", "13.86", "37", "9"], ["2013-06", "2013-06-19", "1", "1", "0.99", "38", "14"], ["2013-07", "2013-07-02", "2", "4", "3.96", "4", "1"], ["2013-07", "2013-07-03", "1", "4", "3.96", "8", "4"], ["2013-07", "2013-07-04", "1", "6", "5.94", "14", "4"], ["2013-07", "2013-07-07", "1", "9", "8.91", "23", "6"], ["2013-07", "2013-07-12", "1", "14", "13.86", "37", "9"], ["2013-07", "2013-07-20", "1", "1", "0.99", "38", "14"], ["2013-08", "2013-08-02", "2", "4", "3.96", "4", "1"], ["2013-08", "2013-08-03", "1", "4", "3.96", "8", "4"], ["2013-08", "2013-08-04", "1", "6", "5.94", "14", "4"], ["2013-08", "2013-08-07", "1", "9", "8.91", "23", "6"], ["2013-08", "2013-08-12", "1", "14", "13.86", "37", "9"], ["2013-08", "2013-08-20", "1", "1", "0.99", "38", "14"], ["2013-09", "2013-09-02", "2", "4", "3.96", "4", "1"], ["2013-09", "2013-09-03", "1", "4", "3.96", "8", "4"], ["2013-09", "2013-09-04", "1", "6", "5.94", "14", "4"], ["2013-09", "2013-09-07", "1", "9", "8.91", "23", "6"], ["2013-09", "2013-09-12", "1", "14", "13.86", "37", "9"], ["2013-09", "2013-09-20", "1", "1", "0.99", "38", "14"], ["2013-10", "2013-10-03", "2", "4", "3.96", "4", "1"], ["2013-10", "2013-10-04", "1", "4", "3.96", "8", "4"], ["2013-10", "2013-10-05", "1", "6", "5.94", "14", "4"], ["2013-10", "2013-10-08", "1", "9", "8.91", "23", "6"], ["2013-10", "2013-10-13", "1", "14", "13.86", "37", "9"], ["2013-10", "2013-10-21", "1", "1", "0.99", "38", "14"], ["2013-11", "2013-11-03", "2", "4", "3.96", "4", "1"], ["2013-11", "2013-11-04", "1", "4", "3.96", "8", "4"], ["2013-11", "2013-11-05", "1", "6", "5.94", "14", "4"], ["2013-11", "2013-11-08", "1", "9", "8.91", "23", "6"], ["2013-11", "2013-11-13", "1", "14", "25.86", "37", "9"], ["2013-11", "2013-11-21", "1", "1", "0.99", "38", "14"], ["2013-12", "2013-12-04", "2", "4", "3.96", "4", "1"], ["2013-12", "2013-12-05", "1", "4", "3.96", "8", "4"], ["2013-12", "2013-12-06", "1", "6", "5.94", "14", "4"], ["2013-12", "2013-12-09", "1", "9", "8.91", "23", "6"], ["2013-12", "2013-12-14", "1", "14", "13.86", "37", "9"], ["2013-12", "2013-12-22", "1", "1", "1.99", "38", "14"]] diff --git a/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@loop.prql.snap b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@loop.prql.snap new file mode 100644 index 000000000000..58ff5dde5c95 --- /dev/null +++ b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@loop.prql.snap @@ -0,0 +1,6 @@ +--- +source: prql-compiler/tests/integration-rdbms/main.rs +expression: "format!(\"{:?}\", first_result.1)" +input_file: prql-compiler/tests/integration/queries/loop.prql +--- +[["-2"], ["0"], ["2"], ["4"], ["6"], ["8"]] diff --git a/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@pipelines.prql.snap b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@pipelines.prql.snap new file mode 100644 index 000000000000..1399a70119ed --- /dev/null +++ b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@pipelines.prql.snap @@ -0,0 +1,6 @@ +--- +source: prql-compiler/tests/integration-rdbms/main.rs +expression: "format!(\"{:?}\", first_result.1)" +input_file: prql-compiler/tests/integration/queries/pipelines.prql +--- +[["0", "20"], ["0", "21"], ["0", "22"], ["1", "23"], ["1", "24"], ["1", "25"]] diff --git a/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@set_ops_remove.prql.snap b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@set_ops_remove.prql.snap new file mode 100644 index 000000000000..59dd2b6211f1 --- /dev/null +++ b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@set_ops_remove.prql.snap @@ -0,0 +1,6 @@ +--- +source: prql-compiler/tests/integration-rdbms/main.rs +expression: "format!(\"{:?}\", first_result.1)" +input_file: prql-compiler/tests/integration/queries/set_ops_remove.prql +--- +[["3"]] diff --git a/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@switch.prql.snap b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@switch.prql.snap new file mode 100644 index 000000000000..d3a93beee26a --- /dev/null +++ b/prql-compiler/tests/integration-rdbms/snapshots/integration_rdbms__tests__rdbms@switch.prql.snap @@ -0,0 +1,6 @@ +--- +source: prql-compiler/tests/integration-rdbms/main.rs +expression: "format!(\"{:?}\", first_result.1)" +input_file: prql-compiler/tests/integration/queries/switch.prql +--- +[["Samuel Rosa", "1071"], ["no composer", "4884"], ["no composer", "6373"], ["no composer", "6635"], ["L. Muggerud", "7941"], ["no composer", "11650"], ["L. Muggerud", "21211"], ["unknown composer", "29048"], ["Gilberto Gil", "32287"], ["Chico Science", "33149"]] From 58958d3ec51048072df02853e99f6dda2a2926f4 Mon Sep 17 00:00:00 2001 From: Maximilian Roos <5635139+max-sixty@users.noreply.github.com> Date: Tue, 28 Mar 2023 14:17:29 -0700 Subject: [PATCH 23/29] Update prql-compiler/prqlc/src/cli.rs --- prql-compiler/prqlc/src/cli.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/prql-compiler/prqlc/src/cli.rs b/prql-compiler/prqlc/src/cli.rs index ea0938e5f3d1..a0b5ca13ec7e 100644 --- a/prql-compiler/prqlc/src/cli.rs +++ b/prql-compiler/prqlc/src/cli.rs @@ -364,13 +364,13 @@ group a_column (take 10 | sort b_column | derive [the_number = rank, last = lag input, ); assert_display_snapshot!(result.unwrap_err(), @r###" - Error: - ╭─[:1:1] - │ - 1 │ asdf -  │ ──┬─ -  │ ╰─── Unknown name asdf - ───╯ + Error: + ╭─[:1:1] + │ + 1 │ asdf + │ ──┬─ + │ ╰─── Unknown name asdf + ───╯ "###); } From eb56f7a15945670b00b6e0ed7f02d58ca114b6cf Mon Sep 17 00:00:00 2001 From: Jelenkee Date: Wed, 29 Mar 2023 17:36:46 +0200 Subject: [PATCH 24/29] -removed test on macOS --- .github/workflows/test-taskfile.yaml | 3 +++ prql-compiler/tests/integration-rdbms/connection.rs | 3 --- prql-compiler/tests/integration-rdbms/main.rs | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-taskfile.yaml b/.github/workflows/test-taskfile.yaml index 365c689ae889..48e3eba6b4e5 100644 --- a/.github/workflows/test-taskfile.yaml +++ b/.github/workflows/test-taskfile.yaml @@ -12,6 +12,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }}-taskfile cancel-in-progress: true +env: + SKIP_INTEGRATION: true + jobs: test-taskfile: runs-on: macos-latest diff --git a/prql-compiler/tests/integration-rdbms/connection.rs b/prql-compiler/tests/integration-rdbms/connection.rs index 394d9c127bb7..c9c50ab3b940 100644 --- a/prql-compiler/tests/integration-rdbms/connection.rs +++ b/prql-compiler/tests/integration-rdbms/connection.rs @@ -166,10 +166,7 @@ impl DBConnection for SQLiteConnection { .join(",") ); self.run_query(q.as_str(), runtime); - //println!("{:?}", q); } - //self.run_query(&format!(".mode csv; .import --skip 1 '{path}' {csv_name};"), runtime); - //self.run_query(&format!(".mode csv;"), runtime); } fn get_dialect(&self) -> Dialect { diff --git a/prql-compiler/tests/integration-rdbms/main.rs b/prql-compiler/tests/integration-rdbms/main.rs index 8b7b0d6fdda8..2f3cafd63dc9 100644 --- a/prql-compiler/tests/integration-rdbms/main.rs +++ b/prql-compiler/tests/integration-rdbms/main.rs @@ -1,4 +1,6 @@ #![cfg(not(any(target_family = "windows", target_family = "wasm")))] +// TODO enable it for all OS +#![cfg(target_os = "linux")] mod connection; @@ -22,6 +24,9 @@ mod tests { #[test] fn test_rdbms() { + if env::var("SKIP_INTEGRATION").is_ok() { + return; + } for port in [5432u16, 3306, 1433 /*, 50000*/] { // test is skipped locally when DB is not listening // in CI it fails From 5c5aa21b6fb78a9852261807f152ab9dd7f489cb Mon Sep 17 00:00:00 2001 From: Jelenkee Date: Wed, 29 Mar 2023 17:46:10 +0200 Subject: [PATCH 25/29] empty From b936ae59366a77d5df2cea5ca3920ed9f8d95c2a Mon Sep 17 00:00:00 2001 From: Jelenkee Date: Wed, 29 Mar 2023 20:11:13 +0200 Subject: [PATCH 26/29] -skip integration test on windows --- .github/workflows/test-rust.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test-rust.yaml b/.github/workflows/test-rust.yaml index 631b1f81b85a..4ea7567d4d7c 100644 --- a/.github/workflows/test-rust.yaml +++ b/.github/workflows/test-rust.yaml @@ -57,11 +57,16 @@ jobs: - name: Run docker compose run: docker compose up -d working-directory: ./prql-compiler/tests/integration-rdbms + if: ${{ inputs.os != 'windows-latest' }} - name: Wait for database uses: ifaxity/wait-on-action@v1 with: resource: "tcp:5432 tcp:3306 tcp:1433" timeout: 60000 + if: ${{ inputs.os != 'windows-latest' }} + - name: skip integration if windows + run: echo "SKIP_INTEGRATION=true" >> $GITHUB_ENV + if: ${{ inputs.os == 'windows-latest' }} # Only check unreferenced snapshots on the default target tests on ubuntu # # (Maybe there's a nicer approach where we can parameterize one step From 6b5b099a9d9a5af7804c25785a01b7f139d7999d Mon Sep 17 00:00:00 2001 From: Jelenkee Date: Wed, 29 Mar 2023 22:11:03 +0200 Subject: [PATCH 27/29] -fixed taskfile --- .github/workflows/test-rust.yaml | 10 +++++----- Taskfile.yml | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-rust.yaml b/.github/workflows/test-rust.yaml index 4ea7567d4d7c..5a3b48f19812 100644 --- a/.github/workflows/test-rust.yaml +++ b/.github/workflows/test-rust.yaml @@ -57,16 +57,16 @@ jobs: - name: Run docker compose run: docker compose up -d working-directory: ./prql-compiler/tests/integration-rdbms - if: ${{ inputs.os != 'windows-latest' }} + if: ${{ inputs.os == 'ubuntu-latest' }} - name: Wait for database uses: ifaxity/wait-on-action@v1 with: resource: "tcp:5432 tcp:3306 tcp:1433" timeout: 60000 - if: ${{ inputs.os != 'windows-latest' }} - - name: skip integration if windows - run: echo "SKIP_INTEGRATION=true" >> $GITHUB_ENV - if: ${{ inputs.os == 'windows-latest' }} + if: ${{ inputs.os == 'ubuntu-latest' }} + - name: skip integration if not linux + run: "echo 'SKIP_INTEGRATION=true' >> $GITHUB_ENV" + if: ${{ inputs.os != 'ubuntu-latest' }} # Only check unreferenced snapshots on the default target tests on ubuntu # # (Maybe there's a nicer approach where we can parameterize one step diff --git a/Taskfile.yml b/Taskfile.yml index 4347eb5028d9..9a5e052e3b63 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -195,7 +195,9 @@ tasks: # excluded under wasm. Note that this will also over-delete on Windows. # Note that we need to pass the target explicitly to manage # https://github.com/rust-lang/cargo/issues/8899 - - cargo insta test --accept --unreferenced=auto + - cargo insta test --accept + # see #2286 + #- cargo insta test --accept --unreferenced=auto - cargo insta test --accept --target=wasm32-unknown-unknown # We build the book too, because that acts as a test - cd web/book && mdbook build From 8a39f9f24d3ac289fbc87aea53650b9d350a7b0f Mon Sep 17 00:00:00 2001 From: Jelenkee Date: Wed, 29 Mar 2023 22:42:49 +0200 Subject: [PATCH 28/29] -added double quotes --- .github/workflows/test-rust.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-rust.yaml b/.github/workflows/test-rust.yaml index 5a3b48f19812..8cb5a7872aaf 100644 --- a/.github/workflows/test-rust.yaml +++ b/.github/workflows/test-rust.yaml @@ -65,7 +65,7 @@ jobs: timeout: 60000 if: ${{ inputs.os == 'ubuntu-latest' }} - name: skip integration if not linux - run: "echo 'SKIP_INTEGRATION=true' >> $GITHUB_ENV" + run: echo "SKIP_INTEGRATION=true" >> $GITHUB_ENV if: ${{ inputs.os != 'ubuntu-latest' }} # Only check unreferenced snapshots on the default target tests on ubuntu # From b9a5f46d135422a4f1afd4dbc9b405673f4650be Mon Sep 17 00:00:00 2001 From: Maximilian Roos <5635139+max-sixty@users.noreply.github.com> Date: Wed, 29 Mar 2023 15:19:46 -0700 Subject: [PATCH 29/29] Update .github/workflows/test-rust.yaml --- .github/workflows/test-rust.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-rust.yaml b/.github/workflows/test-rust.yaml index 8cb5a7872aaf..b3c67090ed78 100644 --- a/.github/workflows/test-rust.yaml +++ b/.github/workflows/test-rust.yaml @@ -65,7 +65,7 @@ jobs: timeout: 60000 if: ${{ inputs.os == 'ubuntu-latest' }} - name: skip integration if not linux - run: echo "SKIP_INTEGRATION=true" >> $GITHUB_ENV + run: echo "SKIP_INTEGRATION=true" >> "$GITHUB_ENV" if: ${{ inputs.os != 'ubuntu-latest' }} # Only check unreferenced snapshots on the default target tests on ubuntu #