diff --git a/book/tests/snapshot.rs b/book/tests/snapshot.rs index e86b59ae20fc..d26bfe754dec 100644 --- a/book/tests/snapshot.rs +++ b/book/tests/snapshot.rs @@ -1,6 +1,6 @@ #![cfg(not(target_family = "wasm"))] /// This test: -/// - Extracts PRQL code blocks into the `examples` path. +/// - Extracts PRQL code blocks into files in the `examples` path /// - Converts them to SQL using insta, raising an error if there's a diff. /// - Replaces the PRQL code block with a comparison table. /// @@ -18,69 +18,38 @@ // us. They introduce a bunch of non-rust dependencies, which is not ideal, but // passable. They don't let us customize our formatting (e.g. in a table). // -use anyhow::{bail, Result}; +use anyhow::{bail, Error, Result}; use globset::Glob; -use insta::{assert_display_snapshot, assert_snapshot, glob}; +use insta::{assert_snapshot, glob}; +use itertools::Itertools; use log::warn; use prql_compiler::*; use pulldown_cmark::{CodeBlockKind, Event, Parser, Tag}; -use std::fs; use std::path::Path; +use std::{collections::HashMap, fs}; use walkdir::WalkDir; #[test] -fn run_examples() -> Result<()> { - // TODO: In CI this could pass by replacing incorrect files. To catch that, - // we could check if there are any diffs after this has run? - +fn test_examples() -> Result<()> { // Note that on windows, markdown is read differently, and so // writing on Windows. ref https://github.com/PRQL/prql/issues/356 #[cfg(not(target_family = "windows"))] - write_reference_prql()?; - run_reference_prql(); - - // TODO: Currently we run this in the same test, since we need the - // `write_reference_prql` function to have been run. If we could iterate - // over the PRQL examples without writing them to disk, we could run this as - // a separate test. (Though then we'd lose the deferred failures feature - // that insta's `glob!` macro provides.) - run_display_reference_prql(); + write_prql_examples()?; + test_prql_examples(); Ok(()) } -/// Extract reference examples from the PRQL docs and write them to the -/// `tests/prql` path, one in each file. -// We could alternatively have used something like -// https://github.com/earldouglas/codedown, but it's not much code, and it -// requires no dependencies. -// -// We allow dead_code because of the window issue described above. (Can we allow -// it only for windows?) -#[allow(dead_code)] -fn write_reference_prql() -> Result<()> { - // Remove old .prql files, since we're going to rewrite them, and we don't want - // old files which wouldn't be rewritten from hanging around. - // We use `trash`, since we don't want to be removing files with test code - // in case there's a bug. - // - // A more elegant approach would be to keep a list of the files and remove - // the ones we don't write. - - let examples_path = Path::new("tests/prql"); - if examples_path.exists() { - trash::delete(Path::new("tests/prql")).unwrap_or_else(|e| { - warn!("Failed to delete old examples: {}", e); - }); - } +const ROOT_EXAMPLES_PATH: &str = "tests/prql"; +/// Collect all the PRQL examples in the book, as a map of . +fn collect_book_examples() -> Result> { let glob = Glob::new("**/*.md")?.compile_matcher(); - - WalkDir::new(Path::new("./src/")) + let examples_in_book: HashMap = WalkDir::new(Path::new("./src/")) .into_iter() .flatten() .filter(|x| glob.is_match(x.path())) - .try_for_each(|dir_entry| { + .flat_map(|dir_entry| { let text = fs::read_to_string(dir_entry.path())?; let mut parser = Parser::new(&text); let mut prql_blocks = vec![]; @@ -102,33 +71,85 @@ fn write_reference_prql() -> Result<()> { _ => {} } } - - // Write each one to a new file. - prql_blocks + let snapshot_prefix = &dir_entry + .path() + .strip_prefix("./src/")? + .to_str() + .unwrap() + .trim_end_matches(".md"); + Ok(prql_blocks .iter() .enumerate() - .try_for_each(|(i, example)| { - let file_relative = &dir_entry - .path() - .strip_prefix("./src/")? - .to_str() - .unwrap() - .trim_end_matches(".md"); - let prql_path = format!("tests/prql/{file_relative}-{i}.prql"); - - fs::create_dir_all(Path::new(&prql_path).parent().unwrap())?; - fs::write(prql_path, example.to_string())?; - - Ok::<(), anyhow::Error>(()) - })?; - Ok(()) + .map(|(i, example)| { + ( + format!("{ROOT_EXAMPLES_PATH}/{snapshot_prefix}-{i}.prql"), + example.to_string(), + ) + }) + .collect::>()) + }) + .flatten() + .collect(); + + Ok(examples_in_book) +} + +/// Extract reference examples from the PRQL docs and write them to the +/// `tests/prql` path, one in each file. +// We could alternatively have used something like +// https://github.com/earldouglas/codedown, but it's not much code, and it +// requires no dependencies. +// +// We allow dead_code because of the window issue described above. (Can we allow +// it only for windows?) +#[allow(dead_code)] +fn write_prql_examples() -> Result<()> { + // If we have to modify any files, raise an error at the end, so it fails in CI. + let mut snapshots_updated = false; + + let examples_path = Path::new(ROOT_EXAMPLES_PATH); + let prql_matcher = Glob::new("**.prql")?.compile_matcher(); + let mut existing_snapshots: HashMap<_, _> = WalkDir::new(examples_path) + .into_iter() + .flatten() + .filter(|x| prql_matcher.is_match(x.path())) + .map(|x| x.path().to_owned()) + .map(|x| Ok::<_, Error>((x.to_string_lossy().to_string(), fs::read_to_string(x)?))) + .try_collect()?; + + // Write any new snapshots, or update any that have changed. = + collect_book_examples()? + .iter() + .try_for_each(|(prql_path, example)| { + if existing_snapshots + .remove(prql_path) + .map(|existing| existing != *example) + .unwrap_or(true) + { + snapshots_updated = true; + fs::create_dir_all(Path::new(prql_path).parent().unwrap())?; + fs::write(prql_path, example)?; + } + + Ok::<(), anyhow::Error>(()) })?; + // If there are any files left in `existing_snapshots`, we remove them, since + // they don't reference anything. + existing_snapshots.iter().for_each(|(path, _)| { + trash::delete(path).unwrap_or_else(|e| { + warn!("Failed to delete unreferenced example: {}", e); + }) + }); + + if snapshots_updated { + bail!("Some book snapshots were not consistent with the queries in the book and have been updated. Subsequent runs should pass."); + } Ok(()) } /// Snapshot the output of each example. -fn run_reference_prql() { +fn test_prql_examples() { glob!("prql/**/*.prql", |path| { let prql = fs::read_to_string(path).unwrap(); @@ -147,20 +168,25 @@ fn run_reference_prql() { } /// Snapshot the display trait output of each example. -// Currently not a separate test, see notes in caller. // // TODO: this involves writing out almost the same PRQL again — instead we could // compare the output of Display to the auto-formatted source. But we need an // autoformatter for that (unless we want to raise on any non-matching input, // which seems very strict) -fn run_display_reference_prql() { - glob!("prql/**/*.prql", |path| { - let prql = fs::read_to_string(path).unwrap(); - - if prql.contains("skip_test") { - return; - } +#[test] +fn test_display() -> Result<(), ErrorMessages> { + use prql_compiler::downcast; + collect_book_examples() + .map_err(downcast)? + .iter() + .try_for_each(|(path, example)| { + assert_snapshot!( + path.to_owned(), + prql_to_pl(example).and_then(pl_to_prql)?, + example + ); + Ok::<(), ErrorMessages>(()) + })?; - assert_display_snapshot!(prql_to_pl(&prql).and_then(pl_to_prql).unwrap()); - }); + Ok(()) } diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__list-equivalence-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@examples__list-equivalence-0.prql.snap deleted file mode 100644 index 085bada98319..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__list-equivalence-0.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/examples/list-equivalence-0.prql ---- -from employees -select salary - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__list-equivalence-1.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@examples__list-equivalence-1.prql.snap deleted file mode 100644 index 6ab6d90cdd10..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__list-equivalence-1.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/examples/list-equivalence-1.prql ---- -from employees -select [salary] - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__misc-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@examples__misc-0.prql.snap deleted file mode 100644 index 930d29f6d477..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__misc-0.prql.snap +++ /dev/null @@ -1,26 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/examples/misc-0.prql ---- -let parts = ( - from seq_1_to_5 -) - - - -from pl = prospect_lists_prospects -filter prospect_list_id == "cc675eee-8bd1-237f-be5e-622ba511d65e" -join a = accounts [a.id == pl.related_id] -join er = email_addr_bean_rel [er.bean_id == a.id and er.primary_address == "1"] -join ea = email_addresses [ea.id == er.email_address_id] -select ea.email_address -derive prefix = s"regexp_replace(SUBSTRING_INDEX({email_address}, '@', 1), '[.0-9-_:]+', '.')" -derive stub = s"SUBSTRING_INDEX(SUBSTRING_INDEX({prefix}, '.', part), '.', -1)" -select [ - email_address, - stub, -] - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__misc-1.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@examples__misc-1.prql.snap deleted file mode 100644 index d48e3fe1307a..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__misc-1.prql.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/examples/misc-1.prql ---- -from club_ratings -filter rating != null -group year ( - derive [rating_norm = rating - ( average rating ) / ( stddev rating )] -) - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__variables-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@examples__variables-0.prql.snap deleted file mode 100644 index c4e1df527811..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__variables-0.prql.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/examples/variables-0.prql ---- -from employees -filter country == "USA" -derive [ - gross_salary = salary + payroll_tax, - gross_cost = gross_salary + benefits_cost, -] -filter gross_cost > 0 -group [ - title, - country, -] ( - aggregate [ - average salary, - average gross_salary, - sum salary, - sum gross_salary, - average gross_cost, - sum_gross_cost = sum gross_cost, - ct = count, -] -) -sort sum_gross_cost -filter ct > 200 -take 20 - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__variables-1.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@examples__variables-1.prql.snap deleted file mode 100644 index 1f588bf0d309..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__variables-1.prql.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/examples/variables-1.prql ---- -from employees -group [emp_no] ( - aggregate [emp_salary = average salary] -) -join titles [==emp_no] -group [title] ( - aggregate [avg_salary = average emp_salary] -) -select salary_k = avg_salary / 1000 -take 10 -derive salary = salary_k * 1000 - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@internals__functional-lang-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@internals__functional-lang-0.prql.snap deleted file mode 100644 index 96d5d50a00e1..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@internals__functional-lang-0.prql.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/internals/functional-lang-0.prql ---- -from employees -filter age > 50 -sort name - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@internals__functional-lang-1.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@internals__functional-lang-1.prql.snap deleted file mode 100644 index ae83420f23d3..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@internals__functional-lang-1.prql.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/internals/functional-lang-1.prql ---- -from employees -filter age > 50 -sort name - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@internals__functional-lang-2.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@internals__functional-lang-2.prql.snap deleted file mode 100644 index f15a84e195b3..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@internals__functional-lang-2.prql.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/internals/functional-lang-2.prql ---- -filter age > 50 ( - from employees -) -sort name - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@internals__functional-lang-3.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@internals__functional-lang-3.prql.snap deleted file mode 100644 index aa777d923706..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@internals__functional-lang-3.prql.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/internals/functional-lang-3.prql ---- -sort name ( - filter age > 50 ( - from employees -) -) - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@internals__name-resolving-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@internals__name-resolving-0.prql.snap deleted file mode 100644 index a7bd8bc3730a..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@internals__name-resolving-0.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/internals/name-resolving-0.prql ---- -from employees -select first_name - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@introduction-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@introduction-0.prql.snap deleted file mode 100644 index bc40a390e21a..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@introduction-0.prql.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/introduction-0.prql ---- -from employees -filter start_date > @2021-01-01 -derive [ - gross_salary = salary + tax ?? 0, - gross_cost = gross_salary + benefits_cost, -] -filter gross_cost > 0 -group [ - title, - country, -] ( - aggregate [ - average gross_salary, - sum_gross_cost = sum gross_cost, -] -) -filter sum_gross_cost > 100000 -derive id = f"{title}_{country}" -derive country_code = s"LEFT(country, 2)" -sort [ - sum_gross_cost, - -country, -] -take 1..20 - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__coalesce-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__coalesce-0.prql.snap deleted file mode 100644 index 16833c5f8cfa..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__coalesce-0.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/coalesce-0.prql ---- -from orders -derive amount ?? 0 - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__dates-and-times-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__dates-and-times-0.prql.snap deleted file mode 100644 index ca08e6d69631..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__dates-and-times-0.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/dates-and-times-0.prql ---- -from employees -derive age_at_year_end = @2022-12-31 - dob - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__dates-and-times-1.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__dates-and-times-1.prql.snap deleted file mode 100644 index 07d9b568eac6..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__dates-and-times-1.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/dates-and-times-1.prql ---- -from orders -derive should_have_shipped_today = order_time < @08:30 - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__dates-and-times-2.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__dates-and-times-2.prql.snap deleted file mode 100644 index 6e0b688f7f7a..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__dates-and-times-2.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/dates-and-times-2.prql ---- -from commits -derive first_prql_commit = @2020-01-01T13:19:55-0800 - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__dates-and-times-3.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__dates-and-times-3.prql.snap deleted file mode 100644 index 5080f647a12c..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__dates-and-times-3.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/dates-and-times-3.prql ---- -from projects -derive first_check_in = start + 10days - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__distinct-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__distinct-0.prql.snap deleted file mode 100644 index 587f75ff1bd2..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__distinct-0.prql.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/distinct-0.prql ---- -from employees -select department -group department ( - take 1 -) - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__distinct-1.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__distinct-1.prql.snap deleted file mode 100644 index d6bcee7acf86..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__distinct-1.prql.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/distinct-1.prql ---- -from employees -select department -group department ( - take 1 -) - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__distinct-2.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__distinct-2.prql.snap deleted file mode 100644 index 4f2e5f381a88..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__distinct-2.prql.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/distinct-2.prql ---- -from employees -group department ( - sort age - take 1 -) - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__f-strings-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__f-strings-0.prql.snap deleted file mode 100644 index 2b8a822ba481..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__f-strings-0.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/f-strings-0.prql ---- -from employees -select full_name = f"{first_name} {last_name}" - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__f-strings-1.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__f-strings-1.prql.snap deleted file mode 100644 index b61f8780aa34..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__f-strings-1.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/f-strings-1.prql ---- -from web -select url = f"http{tls}://www.{domain}.{tld}/{page}" - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__null-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__null-0.prql.snap deleted file mode 100644 index 016809741efe..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__null-0.prql.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/null-0.prql ---- -from employees -filter first_name == null -filter null != last_name - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__ranges-1.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__ranges-1.prql.snap deleted file mode 100644 index 46ce8b767eb3..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__ranges-1.prql.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/ranges-1.prql ---- -from orders -sort [ - -value, - date, -] -take 101..110 - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__s-strings-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__s-strings-0.prql.snap deleted file mode 100644 index fa9c95fb9f4c..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__s-strings-0.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/s-strings-0.prql ---- -from my_table -select db_version = s"version()" - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__s-strings-1.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__s-strings-1.prql.snap deleted file mode 100644 index 7de6990c149c..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__s-strings-1.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/s-strings-1.prql ---- -from employees -aggregate [average salary] - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__standard-library-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__standard-library-0.prql.snap deleted file mode 100644 index 691cabab4a62..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__standard-library-0.prql.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/standard-library-0.prql ---- -from employees -derive [ - gross_salary = ( - salary + payroll_tax - as int -), - gross_salary_rounded = ( - gross_salary - round 0 -), - time = s"NOW()", -] - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__strings-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__strings-0.prql.snap deleted file mode 100644 index 08b198a45ab3..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__strings-0.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/strings-0.prql ---- -from my_table -select x = "hello world" - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__strings-1.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__strings-1.prql.snap deleted file mode 100644 index 014e0927ce0e..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__strings-1.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/strings-1.prql ---- -from my_table -select x = "hello world" - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__strings-2.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__strings-2.prql.snap deleted file mode 100644 index 52b190fec22a..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__strings-2.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/strings-2.prql ---- -from my_table -select x = '"hello world"' - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__strings-3.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__strings-3.prql.snap deleted file mode 100644 index eddb87ee8834..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__strings-3.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/strings-3.prql ---- -from my_table -select x = 'I said "hello world"!' - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__strings-4.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__strings-4.prql.snap deleted file mode 100644 index 5966be260e48..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__strings-4.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/strings-4.prql ---- -from my_table -select x = 'I said """hello world"""!' - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__target-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__target-0.prql.snap deleted file mode 100644 index 8d46fc69595c..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__target-0.prql.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/target-0.prql ---- -prql target:sql.postgres - - - -from employees -sort age -take 10 - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__target-1.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__target-1.prql.snap deleted file mode 100644 index 2719c8e16911..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__target-1.prql.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/target-1.prql ---- -prql target:sql.mssql - - - -from employees -sort age -take 10 - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__target-2.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__target-2.prql.snap deleted file mode 100644 index 5bf77265c6a4..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__target-2.prql.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/target-2.prql ---- -prql version:^0.5 - - - -from employees - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@queries__pipelines-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@queries__pipelines-0.prql.snap deleted file mode 100644 index 7162e861b213..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@queries__pipelines-0.prql.snap +++ /dev/null @@ -1,9 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/queries/pipelines-0.prql ---- -from employees - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@queries__pipelines-1.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@queries__pipelines-1.prql.snap deleted file mode 100644 index f64f5d68dc56..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@queries__pipelines-1.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/queries/pipelines-1.prql ---- -from employees -derive gross_salary = salary + payroll_tax - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@queries__variables-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@queries__variables-0.prql.snap deleted file mode 100644 index fbb8c9dfa00f..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@queries__variables-0.prql.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/queries/variables-0.prql ---- -let top_50 = ( - from employees - sort salary - take 50 - aggregate [total_salary = sum salary] -) - - - -from top_50 - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-11.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-11.prql.snap deleted file mode 100644 index f719b0acbbd4..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-11.prql.snap +++ /dev/null @@ -1,9 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/syntax-11.prql ---- -from `dir/*.parquet` - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-13.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-13.prql.snap deleted file mode 100644 index 6316d2280516..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-13.prql.snap +++ /dev/null @@ -1,9 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/syntax-13.prql ---- -from `music.albums` - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-14.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-14.prql.snap deleted file mode 100644 index a38f2f750602..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-14.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/syntax-14.prql ---- -from employees -filter id == $1 - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-3.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-3.prql.snap deleted file mode 100644 index 6820f7c5e628..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-3.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/syntax-3.prql ---- -from employees -select [first_name] - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-4.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-4.prql.snap deleted file mode 100644 index 6e06fe3ee2e5..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-4.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/syntax-4.prql ---- -from employees -select first_name - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-6.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-6.prql.snap deleted file mode 100644 index d6668fe305c7..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-6.prql.snap +++ /dev/null @@ -1,40 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/syntax-6.prql ---- -from employees -derive is_proximate = ( - distance - in 0..20 -) -derive ( - total_distance = sum distance -) -derive ( - min_capped_distance = min distance ?? 5 -) -derive travel_time = distance / 40 -derive ( - distance_rounded_2_dp = round 1 + 1 distance -) -derive [ - is_far = ( - distance - in 100.. -), - is_negative = ( - distance - in -100..0 -), - is_negative = ( - distance - in -100..0 -), - average_distance = average distance, -] -sort -distance -sort [-distance] - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-8.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-8.prql.snap deleted file mode 100644 index 55a51e5d833f..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-8.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/syntax-8.prql ---- -from employees -aggregate [average salary] - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__aggregate-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__aggregate-0.prql.snap deleted file mode 100644 index 89e3271c8316..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__aggregate-0.prql.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/aggregate-0.prql ---- -from employees -aggregate [ - average salary, - ct = count, -] - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__aggregate-2.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__aggregate-2.prql.snap deleted file mode 100644 index 21468ff11aeb..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__aggregate-2.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/aggregate-2.prql ---- -from employees -derive [avg_sal = average salary] - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__append-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__append-0.prql.snap deleted file mode 100644 index 821c0f010d36..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__append-0.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/append-0.prql ---- -from employees_1 -append employees_2 - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__append-1.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__append-1.prql.snap deleted file mode 100644 index 2a61ec1251b1..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__append-1.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/append-1.prql ---- -from employees_1 -remove employees_2 - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__append-2.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__append-2.prql.snap deleted file mode 100644 index dddeb63b7c9f..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__append-2.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/append-2.prql ---- -from employees_1 -intersect employees_2 - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__derive-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__derive-0.prql.snap deleted file mode 100644 index e90d9add3db4..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__derive-0.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/derive-0.prql ---- -from employees -derive gross_salary = salary + payroll_tax - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__filter-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__filter-0.prql.snap deleted file mode 100644 index 8a68bf997bd7..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__filter-0.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/filter-0.prql ---- -from employees -filter age > 25 - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__filter-1.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__filter-1.prql.snap deleted file mode 100644 index 1bc8cf6d4a34..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__filter-1.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/filter-1.prql ---- -from employees -filter age > 25 or department != "IT" - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__filter-2.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__filter-2.prql.snap deleted file mode 100644 index ad800e09070f..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__filter-2.prql.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/filter-2.prql ---- -from employees -filter ( - age - in 25..40 -) - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__from-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__from-0.prql.snap deleted file mode 100644 index 0adcf6191d9e..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__from-0.prql.snap +++ /dev/null @@ -1,9 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/from-0.prql ---- -from employees - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__from-1.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__from-1.prql.snap deleted file mode 100644 index b90898f6f93e..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__from-1.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/from-1.prql ---- -from e = employees -select e.first_name - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__from_text-2.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__from_text-2.prql.snap deleted file mode 100644 index a0aaabe15cb7..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__from_text-2.prql.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/from_text-2.prql ---- -let x = ( - from_text format:json '{ - "columns": ["a", "b", "c"], - "data": [ - [1, "x", false], - [4, "y", null] - ] -}' -) - - - -let y = ( - from_text format:json ' - [ - {"a": 1, "m": "5"}, - {"a": 4, "n": "6"} - ] -' -) - - - -from x -join y [==a] - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__group-1.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__group-1.prql.snap deleted file mode 100644 index f916e255f991..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__group-1.prql.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/group-1.prql ---- -from employees -sort join_date -take 1 - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__group-2.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__group-2.prql.snap deleted file mode 100644 index 6b2cb62586b3..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__group-2.prql.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/group-2.prql ---- -from employees -group role ( - sort join_date - take 1 -) - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__join-2.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__join-2.prql.snap deleted file mode 100644 index 19b950c9d24b..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__join-2.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/join-2.prql ---- -from employees -join positions [==emp_no] - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__select-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__select-0.prql.snap deleted file mode 100644 index 9841ec3d8249..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__select-0.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/select-0.prql ---- -from employees -select name = f"{first_name} {last_name}" - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__select-2.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__select-2.prql.snap deleted file mode 100644 index 522050c7dd99..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__select-2.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/select-2.prql ---- -from employees -select first_name - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__select-3.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__select-3.prql.snap deleted file mode 100644 index d6596a9ce634..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__select-3.prql.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/select-3.prql ---- -from e = employees -select [ - e.first_name, - e.last_name, -] - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__select-6.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__select-6.prql.snap deleted file mode 100644 index 102555240bdb..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__select-6.prql.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/select-6.prql ---- -from artists -derive nick = name -select not [artists.`*`] - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__sort-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__sort-0.prql.snap deleted file mode 100644 index 91b36c10532f..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__sort-0.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/sort-0.prql ---- -from employees -sort age - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__sort-1.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__sort-1.prql.snap deleted file mode 100644 index d7f443472fc9..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__sort-1.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/sort-1.prql ---- -from employees -sort [-age] - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__sort-2.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__sort-2.prql.snap deleted file mode 100644 index 1df292e0b57f..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__sort-2.prql.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/sort-2.prql ---- -from employees -sort [ - age, - -tenure, - salary, -] - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__sort-3.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__sort-3.prql.snap deleted file mode 100644 index 3ef53a4676e9..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__sort-3.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/sort-3.prql ---- -from employees -sort [s"substr({first_name}, 2, 5)"] - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__sort-5.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__sort-5.prql.snap deleted file mode 100644 index 52f805544586..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__sort-5.prql.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/sort-5.prql ---- -from employees -sort tenure -join locations [==employee_id] - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__take-0.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__take-0.prql.snap deleted file mode 100644 index 7f798967b647..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__take-0.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/take-0.prql ---- -from employees -take 10 - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__take-1.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__take-1.prql.snap deleted file mode 100644 index 4107c86bfd92..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__take-1.prql.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/take-1.prql ---- -from orders -sort [ - -value, - date, -] -take 101..110 - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__window-2.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__window-2.prql.snap deleted file mode 100644 index 3015829b90db..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__window-2.prql.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/window-2.prql ---- -from employees -sort age -derive rnk = rank - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__window-3.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__window-3.prql.snap deleted file mode 100644 index 26a5eb5d9d46..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__window-3.prql.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/window-3.prql ---- -from employees -group department ( - sort age - derive rnk = rank -) - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__window-4.prql.snap b/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__window-4.prql.snap deleted file mode 100644 index be549656354d..000000000000 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__window-4.prql.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/window-4.prql ---- -from employees -filter salary < ( average salary ) - - - diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__cte-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__examples__cte-0.prql.snap similarity index 51% rename from book/tests/snapshots/snapshot__run_display_reference_prql@examples__cte-0.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__examples__cte-0.prql.snap index b246de058091..83e9f48a0e9e 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__cte-0.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__examples__cte-0.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/examples/cte-0.prql +expression: "let newest_employees = (\n from employees\n sort tenure\n take 50\n)\n\nlet average_salaries = (\n from salaries\n group country (\n aggregate average_country_salary = (average salary)\n )\n)\n\nfrom newest_employees\njoin average_salaries [==country]\nselect [name, salary, average_country_salary]\n" --- let newest_employees = ( from employees diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__employees-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__examples__employees-0.prql.snap similarity index 52% rename from book/tests/snapshots/snapshot__run_display_reference_prql@examples__employees-0.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__examples__employees-0.prql.snap index 692c476512cc..ac80804d08a1 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__employees-0.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__examples__employees-0.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/examples/employees-0.prql +expression: "from salaries\ngroup [emp_no] (\n aggregate [emp_salary = average salary]\n)\njoin t=titles [==emp_no]\njoin dept_emp side:left [==emp_no]\ngroup [dept_emp.dept_no, t.title] (\n aggregate [avg_salary = average emp_salary]\n)\njoin departments [==dept_no]\nselect [dept_name, title, avg_salary]\n" --- from salaries group [emp_no] ( diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__employees-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__examples__employees-1.prql.snap similarity index 51% rename from book/tests/snapshots/snapshot__run_display_reference_prql@examples__employees-1.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__examples__employees-1.prql.snap index 665754bd3fb5..c5d5366f6306 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__employees-1.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__examples__employees-1.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/examples/employees-1.prql +expression: "from e=employees\njoin salaries [==emp_no]\ngroup [e.emp_no, e.gender] (\n aggregate [\n emp_salary = average salaries.salary\n ]\n)\njoin de=dept_emp [==emp_no] side:left\ngroup [de.dept_no, gender] (\n aggregate [\n salary_avg = average emp_salary,\n salary_sd = stddev emp_salary,\n ]\n)\njoin departments [==dept_no]\nselect [dept_name, gender, salary_avg, salary_sd]\n" --- from e = employees join salaries [==emp_no] diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__employees-2.prql.snap b/book/tests/snapshots/snapshot__tests__prql__examples__employees-2.prql.snap similarity index 50% rename from book/tests/snapshots/snapshot__run_display_reference_prql@examples__employees-2.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__examples__employees-2.prql.snap index 3823173006c7..d957c280a5c6 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__employees-2.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__examples__employees-2.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/examples/employees-2.prql +expression: "from e=employees\njoin salaries [==emp_no]\ngroup [e.emp_no, e.gender] (\n aggregate [\n emp_salary = average salaries.salary\n ]\n)\njoin de=dept_emp [==emp_no]\njoin dm=dept_manager [\n (dm.dept_no == de.dept_no) and s\"(de.from_date, de.to_date) OVERLAPS (dm.from_date, dm.to_date)\"\n]\ngroup [dm.emp_no, gender] (\n aggregate [\n salary_avg = average emp_salary,\n salary_sd = stddev emp_salary\n ]\n)\nderive mng_no = emp_no\njoin managers=employees [==emp_no]\nderive mng_name = s\"managers.first_name || ' ' || managers.last_name\"\nselect [mng_name, managers.gender, salary_avg, salary_sd]\n" --- from e = employees join salaries [==emp_no] diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__employees-3.prql.snap b/book/tests/snapshots/snapshot__tests__prql__examples__employees-3.prql.snap similarity index 52% rename from book/tests/snapshots/snapshot__run_display_reference_prql@examples__employees-3.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__examples__employees-3.prql.snap index 611769e8f06d..9cc6115f24bd 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__employees-3.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__examples__employees-3.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/examples/employees-3.prql +expression: "from de=dept_emp\njoin s=salaries side:left [\n (s.emp_no == de.emp_no),\n s\"({s.from_date}, {s.to_date}) OVERLAPS ({de.from_date}, {de.to_date})\"\n]\ngroup [de.emp_no, de.dept_no] (\n aggregate salary = (average s.salary)\n)\njoin employees [==emp_no]\njoin titles [==emp_no]\nselect [dept_no, salary, employees.gender, titles.title]\n" --- from de = dept_emp join side:left s = salaries [ diff --git a/book/tests/snapshots/snapshot__tests__prql__examples__list-equivalence-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__examples__list-equivalence-0.prql.snap new file mode 100644 index 000000000000..8566dfaeb2b2 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__examples__list-equivalence-0.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nselect salary\n" +--- +from employees +select salary + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__examples__list-equivalence-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__examples__list-equivalence-1.prql.snap new file mode 100644 index 000000000000..055af64b363a --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__examples__list-equivalence-1.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nselect [salary]\n" +--- +from employees +select [salary] + + + diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__list-equivalence-2.prql.snap b/book/tests/snapshots/snapshot__tests__prql__examples__list-equivalence-2.prql.snap similarity index 54% rename from book/tests/snapshots/snapshot__run_display_reference_prql@examples__list-equivalence-2.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__examples__list-equivalence-2.prql.snap index 5ba483c522d7..3d298b6f9b55 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__list-equivalence-2.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__examples__list-equivalence-2.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/examples/list-equivalence-2.prql +expression: "from employees\nderive [\n gross_salary = salary + payroll_tax,\n gross_cost = gross_salary + benefits_cost\n]\n" --- from employees derive [ diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__list-equivalence-3.prql.snap b/book/tests/snapshots/snapshot__tests__prql__examples__list-equivalence-3.prql.snap similarity index 54% rename from book/tests/snapshots/snapshot__run_display_reference_prql@examples__list-equivalence-3.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__examples__list-equivalence-3.prql.snap index c1c8e138f806..254f07187889 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@examples__list-equivalence-3.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__examples__list-equivalence-3.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/examples/list-equivalence-3.prql +expression: "from employees\nderive gross_salary = salary + payroll_tax\nderive gross_cost = gross_salary + benefits_cost\n" --- from employees derive gross_salary = salary + payroll_tax diff --git a/book/tests/snapshots/snapshot__tests__prql__examples__misc-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__examples__misc-0.prql.snap new file mode 100644 index 000000000000..63b13a31ec56 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__examples__misc-0.prql.snap @@ -0,0 +1,25 @@ +--- +source: book/tests/snapshot.rs +expression: "# TODO: this table should have a column `part` with values 1..5,\n# but such data declaration is not yet supported, see #286\nlet parts = (\n from seq_1_to_5\n)\n\nfrom pl=prospect_lists_prospects\nfilter prospect_list_id == 'cc675eee-8bd1-237f-be5e-622ba511d65e'\njoin a=accounts [a.id == pl.related_id]\njoin er=email_addr_bean_rel [er.bean_id == a.id and er.primary_address == '1']\njoin ea=email_addresses [ea.id == er.email_address_id]\nselect ea.email_address\nderive prefix = s\"regexp_replace(SUBSTRING_INDEX({email_address}, '@', 1), '[.0-9-_:]+', '.')\"\nderive stub = s\"SUBSTRING_INDEX(SUBSTRING_INDEX({prefix}, '.', part), '.', -1)\"\nselect [email_address, stub]\n" +--- +let parts = ( + from seq_1_to_5 +) + + + +from pl = prospect_lists_prospects +filter prospect_list_id == "cc675eee-8bd1-237f-be5e-622ba511d65e" +join a = accounts [a.id == pl.related_id] +join er = email_addr_bean_rel [er.bean_id == a.id and er.primary_address == "1"] +join ea = email_addresses [ea.id == er.email_address_id] +select ea.email_address +derive prefix = s"regexp_replace(SUBSTRING_INDEX({email_address}, '@', 1), '[.0-9-_:]+', '.')" +derive stub = s"SUBSTRING_INDEX(SUBSTRING_INDEX({prefix}, '.', part), '.', -1)" +select [ + email_address, + stub, +] + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__examples__misc-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__examples__misc-1.prql.snap new file mode 100644 index 000000000000..50dcca896ea5 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__examples__misc-1.prql.snap @@ -0,0 +1,12 @@ +--- +source: book/tests/snapshot.rs +expression: "from club_ratings\nfilter rating != null\n# TODO: this is real ugly. `average rating` should not require parenthesis\n# TODO: why cannot we put comments in group's pipeline?\ngroup year (\n derive [rating_norm = rating - (average rating) / (stddev rating)]\n)\n" +--- +from club_ratings +filter rating != null +group year ( + derive [rating_norm = rating - ( average rating ) / ( stddev rating )] +) + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__examples__variables-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__examples__variables-0.prql.snap new file mode 100644 index 000000000000..4b1f4fce84c1 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__examples__variables-0.prql.snap @@ -0,0 +1,31 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nfilter country == \"USA\" # Each line transforms the previous result.\nderive [ # This adds columns / variables.\n gross_salary = salary + payroll_tax,\n gross_cost = gross_salary + benefits_cost # Variables can use other variables.\n]\nfilter gross_cost > 0\ngroup [title, country] ( # For each group use a nested pipeline\n aggregate [ # Aggregate each group to a single row\n average salary,\n average gross_salary,\n sum salary,\n sum gross_salary,\n average gross_cost,\n sum_gross_cost = sum gross_cost,\n ct = count,\n ]\n)\nsort sum_gross_cost\nfilter ct > 200\ntake 20\n" +--- +from employees +filter country == "USA" +derive [ + gross_salary = salary + payroll_tax, + gross_cost = gross_salary + benefits_cost, +] +filter gross_cost > 0 +group [ + title, + country, +] ( + aggregate [ + average salary, + average gross_salary, + sum salary, + sum gross_salary, + average gross_cost, + sum_gross_cost = sum gross_cost, + ct = count, +] +) +sort sum_gross_cost +filter ct > 200 +take 20 + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__examples__variables-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__examples__variables-1.prql.snap new file mode 100644 index 000000000000..cfb45e96a801 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__examples__variables-1.prql.snap @@ -0,0 +1,18 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\ngroup [emp_no] (\n aggregate [\n emp_salary = average salary # average salary resolves to \"AVG(salary)\" (from stdlib)\n ]\n)\njoin titles [==emp_no]\ngroup [title] (\n aggregate [\n avg_salary = average emp_salary\n ]\n)\nselect salary_k = avg_salary / 1000 # avg_salary should resolve to \"AVG(emp_salary)\"\ntake 10 # induces new SELECT\nderive salary = salary_k * 1000 # salary_k should not resolve to \"avg_salary / 1000\"\n" +--- +from employees +group [emp_no] ( + aggregate [emp_salary = average salary] +) +join titles [==emp_no] +group [title] ( + aggregate [avg_salary = average emp_salary] +) +select salary_k = avg_salary / 1000 +take 10 +derive salary = salary_k * 1000 + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__internals__functional-lang-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__internals__functional-lang-0.prql.snap new file mode 100644 index 000000000000..1bd2d905e16d --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__internals__functional-lang-0.prql.snap @@ -0,0 +1,10 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nfilter age > 50\nsort name\n" +--- +from employees +filter age > 50 +sort name + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__internals__functional-lang-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__internals__functional-lang-1.prql.snap new file mode 100644 index 000000000000..da4b761a9e4b --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__internals__functional-lang-1.prql.snap @@ -0,0 +1,10 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees | filter age > 50 | sort name\n" +--- +from employees +filter age > 50 +sort name + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__internals__functional-lang-2.prql.snap b/book/tests/snapshots/snapshot__tests__prql__internals__functional-lang-2.prql.snap new file mode 100644 index 000000000000..7da897d0dd14 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__internals__functional-lang-2.prql.snap @@ -0,0 +1,11 @@ +--- +source: book/tests/snapshot.rs +expression: "filter age > 50 (from employees) | sort name\n" +--- +filter age > 50 ( + from employees +) +sort name + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__internals__functional-lang-3.prql.snap b/book/tests/snapshots/snapshot__tests__prql__internals__functional-lang-3.prql.snap new file mode 100644 index 000000000000..045c663815a8 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__internals__functional-lang-3.prql.snap @@ -0,0 +1,12 @@ +--- +source: book/tests/snapshot.rs +expression: "sort name (filter age > 50 (from employees))\n" +--- +sort name ( + filter age > 50 ( + from employees +) +) + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__internals__name-resolving-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__internals__name-resolving-0.prql.snap new file mode 100644 index 000000000000..56e49df27e11 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__internals__name-resolving-0.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nselect first_name\n" +--- +from employees +select first_name + + + diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@internals__name-resolving-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__internals__name-resolving-1.prql.snap similarity index 56% rename from book/tests/snapshots/snapshot__run_display_reference_prql@internals__name-resolving-1.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__internals__name-resolving-1.prql.snap index 6161fd5892e6..a9d9e5bada6d 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@internals__name-resolving-1.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__internals__name-resolving-1.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/internals/name-resolving-1.prql +expression: "from employees\nderive [first_name, dept_id]\njoin d=departments [==dept_id]\nselect [first_name, d.title]\n" --- from employees derive [ diff --git a/book/tests/snapshots/snapshot__tests__prql__introduction-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__introduction-0.prql.snap new file mode 100644 index 000000000000..96f55b8ab057 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__introduction-0.prql.snap @@ -0,0 +1,31 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nfilter start_date > @2021-01-01 # Clear date syntax\nderive [ # `derive` adds columns / variables\n gross_salary = salary + (tax ?? 0), # Terse coalesce\n gross_cost = gross_salary + benefits_cost, # Variables can use other variables\n]\nfilter gross_cost > 0\ngroup [title, country] ( # `group` runs a pipeline over each group\n aggregate [ # `aggregate` reduces each group to a value\n average gross_salary,\n sum_gross_cost = sum gross_cost, # `=` sets a column name\n ]\n)\nfilter sum_gross_cost > 100_000 # `filter` replaces both of SQL's `WHERE` & `HAVING`\nderive id = f\"{title}_{country}\" # F-strings like Python\nderive country_code = s\"LEFT(country, 2)\" # S-strings allow using SQL as an escape hatch\nsort [sum_gross_cost, -country] # `-country` means descending order\ntake 1..20 # Range expressions (also valid here as `take 20`)\n" +--- +from employees +filter start_date > @2021-01-01 +derive [ + gross_salary = salary + tax ?? 0, + gross_cost = gross_salary + benefits_cost, +] +filter gross_cost > 0 +group [ + title, + country, +] ( + aggregate [ + average gross_salary, + sum_gross_cost = sum gross_cost, +] +) +filter sum_gross_cost > 100000 +derive id = f"{title}_{country}" +derive country_code = s"LEFT(country, 2)" +sort [ + sum_gross_cost, + -country, +] +take 1..20 + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__language-features__coalesce-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__coalesce-0.prql.snap new file mode 100644 index 000000000000..24ff749cfbc8 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__coalesce-0.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from orders\nderive amount ?? 0\n" +--- +from orders +derive amount ?? 0 + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__language-features__dates-and-times-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__dates-and-times-0.prql.snap new file mode 100644 index 000000000000..acb71c71fc9a --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__dates-and-times-0.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nderive age_at_year_end = (@2022-12-31 - dob)\n" +--- +from employees +derive age_at_year_end = @2022-12-31 - dob + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__language-features__dates-and-times-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__dates-and-times-1.prql.snap new file mode 100644 index 000000000000..fd2fe52b3f6c --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__dates-and-times-1.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from orders\nderive should_have_shipped_today = (order_time < @08:30)\n" +--- +from orders +derive should_have_shipped_today = order_time < @08:30 + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__language-features__dates-and-times-2.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__dates-and-times-2.prql.snap new file mode 100644 index 000000000000..1507a39b0252 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__dates-and-times-2.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from commits\nderive first_prql_commit = @2020-01-01T13:19:55-0800\n" +--- +from commits +derive first_prql_commit = @2020-01-01T13:19:55-0800 + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__language-features__dates-and-times-3.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__dates-and-times-3.prql.snap new file mode 100644 index 000000000000..70ac66f365a2 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__dates-and-times-3.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from projects\nderive first_check_in = start + 10days\n" +--- +from projects +derive first_check_in = start + 10days + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__language-features__distinct-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__distinct-0.prql.snap new file mode 100644 index 000000000000..7929401e23b6 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__distinct-0.prql.snap @@ -0,0 +1,12 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nselect department\ngroup department (\n take 1\n)\n" +--- +from employees +select department +group department ( + take 1 +) + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__language-features__distinct-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__distinct-1.prql.snap new file mode 100644 index 000000000000..22ba087f087c --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__distinct-1.prql.snap @@ -0,0 +1,12 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nselect department\ngroup department (take 1)\n" +--- +from employees +select department +group department ( + take 1 +) + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__language-features__distinct-2.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__distinct-2.prql.snap new file mode 100644 index 000000000000..ceb0035e6601 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__distinct-2.prql.snap @@ -0,0 +1,12 @@ +--- +source: book/tests/snapshot.rs +expression: "# youngest employee from each department\nfrom employees\ngroup department (\n sort age\n take 1\n)\n" +--- +from employees +group department ( + sort age + take 1 +) + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__language-features__f-strings-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__f-strings-0.prql.snap new file mode 100644 index 000000000000..5f490aa52f00 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__f-strings-0.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nselect full_name = f\"{first_name} {last_name}\"\n" +--- +from employees +select full_name = f"{first_name} {last_name}" + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__language-features__f-strings-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__f-strings-1.prql.snap new file mode 100644 index 000000000000..f00e2becbab2 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__f-strings-1.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from web\nselect url = f\"http{tls}://www.{domain}.{tld}/{page}\"\n" +--- +from web +select url = f"http{tls}://www.{domain}.{tld}/{page}" + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__language-features__null-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__null-0.prql.snap new file mode 100644 index 000000000000..73594522238f --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__null-0.prql.snap @@ -0,0 +1,10 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nfilter first_name == null\nfilter null != last_name\n" +--- +from employees +filter first_name == null +filter null != last_name + + + diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__ranges-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__ranges-0.prql.snap similarity index 55% rename from book/tests/snapshots/snapshot__run_display_reference_prql@language-features__ranges-0.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__language-features__ranges-0.prql.snap index e20b2b97240c..2d5baa98ae2d 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__ranges-0.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__ranges-0.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/ranges-0.prql +expression: "from events\nfilter (date | in @1776-07-04..@1787-09-17)\nfilter (magnitude | in 50..100)\nderive is_northern = (latitude | in 0..)\n" --- from events filter ( diff --git a/book/tests/snapshots/snapshot__tests__prql__language-features__ranges-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__ranges-1.prql.snap new file mode 100644 index 000000000000..b68c1920a669 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__ranges-1.prql.snap @@ -0,0 +1,13 @@ +--- +source: book/tests/snapshot.rs +expression: "from orders\nsort [-value, date]\ntake 101..110\n" +--- +from orders +sort [ + -value, + date, +] +take 101..110 + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__language-features__s-strings-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__s-strings-0.prql.snap new file mode 100644 index 000000000000..12abfcc2518c --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__s-strings-0.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from my_table\nselect db_version = s\"version()\"\n" +--- +from my_table +select db_version = s"version()" + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__language-features__s-strings-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__s-strings-1.prql.snap new file mode 100644 index 000000000000..c57ed2561d58 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__s-strings-1.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\naggregate [average salary]\n" +--- +from employees +aggregate [average salary] + + + diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__s-strings-2.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__s-strings-2.prql.snap similarity index 51% rename from book/tests/snapshots/snapshot__run_display_reference_prql@language-features__s-strings-2.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__language-features__s-strings-2.prql.snap index 8d39feed0f0d..e28b7f46ed0a 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__s-strings-2.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__s-strings-2.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/s-strings-2.prql +expression: "from de=dept_emp\njoin s=salaries side:left [\n (s.emp_no == de.emp_no),\n s\"\"\"({s.from_date}, {s.to_date})\n OVERLAPS\n ({de.from_date}, {de.to_date})\"\"\"\n]\n" --- from de = dept_emp join side:left s = salaries [ diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__s-strings-3.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__s-strings-3.prql.snap similarity index 53% rename from book/tests/snapshots/snapshot__run_display_reference_prql@language-features__s-strings-3.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__language-features__s-strings-3.prql.snap index 85661196009c..2cb93849dda8 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__s-strings-3.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__s-strings-3.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/s-strings-3.prql +expression: "from s\"SELECT DISTINCT ON first_name, id, age FROM employees ORDER BY age ASC\"\njoin s = s\"SELECT * FROM salaries\" [==id]\n" --- from s"SELECT DISTINCT ON first_name, id, age FROM employees ORDER BY age ASC" join s = s"SELECT * FROM salaries" [==id] diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__s-strings-4.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__s-strings-4.prql.snap similarity index 51% rename from book/tests/snapshots/snapshot__run_display_reference_prql@language-features__s-strings-4.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__language-features__s-strings-4.prql.snap index d7482d2f4cfb..00c1d5e17349 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__s-strings-4.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__s-strings-4.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/s-strings-4.prql +expression: "from employees\nderive [\n has_valid_title = s\"regexp_contains(title, '([a-z0-9]*-){{2,}}')\"\n]\n" --- from employees derive [has_valid_title = s"regexp_contains(title, '([a-z0-9]*-){2,}')"] diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__s-strings-5.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__s-strings-5.prql.snap similarity index 53% rename from book/tests/snapshots/snapshot__run_display_reference_prql@language-features__s-strings-5.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__language-features__s-strings-5.prql.snap index 4313e1e554a7..9bd3b0d3fe16 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__s-strings-5.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__s-strings-5.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/s-strings-5.prql +expression: "from employees\nderive [\n gross_salary = salary + benefits,\n daily_rate = s\"{gross_salary} / 365\"\n]\n" --- from employees derive [ diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__s-strings-6.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__s-strings-6.prql.snap similarity index 53% rename from book/tests/snapshots/snapshot__run_display_reference_prql@language-features__s-strings-6.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__language-features__s-strings-6.prql.snap index 8ac94b9d968f..3dc30b6885ae 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__s-strings-6.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__s-strings-6.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/s-strings-6.prql +expression: "from employees\nderive [\n gross_salary = salary + benefits,\n daily_rate = s\"({gross_salary}) / 365\"\n]\n" --- from employees derive [ diff --git a/book/tests/snapshots/snapshot__tests__prql__language-features__standard-library-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__standard-library-0.prql.snap new file mode 100644 index 000000000000..011d5f416c47 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__standard-library-0.prql.snap @@ -0,0 +1,19 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nderive [\n gross_salary = (salary + payroll_tax | as int),\n gross_salary_rounded = (gross_salary | round 0),\n time = s\"NOW()\", # an s-string, given no `now` function exists in PRQL\n]\n" +--- +from employees +derive [ + gross_salary = ( + salary + payroll_tax + as int +), + gross_salary_rounded = ( + gross_salary + round 0 +), + time = s"NOW()", +] + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__language-features__strings-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__strings-0.prql.snap new file mode 100644 index 000000000000..6a1d79036036 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__strings-0.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from my_table\nselect x = \"hello world\"\n" +--- +from my_table +select x = "hello world" + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__language-features__strings-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__strings-1.prql.snap new file mode 100644 index 000000000000..2da7a07937de --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__strings-1.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from my_table\nselect x = 'hello world'\n" +--- +from my_table +select x = "hello world" + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__language-features__strings-2.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__strings-2.prql.snap new file mode 100644 index 000000000000..8d79cd8cedbc --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__strings-2.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from my_table\nselect x = '\"hello world\"'\n" +--- +from my_table +select x = '"hello world"' + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__language-features__strings-3.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__strings-3.prql.snap new file mode 100644 index 000000000000..a681bc62a036 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__strings-3.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from my_table\nselect x = \"\"\"I said \"hello world\"!\"\"\"\n" +--- +from my_table +select x = 'I said "hello world"!' + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__language-features__strings-4.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__strings-4.prql.snap new file mode 100644 index 000000000000..0bae3f836774 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__strings-4.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from my_table\nselect x = \"\"\"\"\"I said \"\"\"hello world\"\"\"!\"\"\"\"\"\n" +--- +from my_table +select x = 'I said """hello world"""!' + + + diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__switch-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__switch-0.prql.snap similarity index 53% rename from book/tests/snapshots/snapshot__run_display_reference_prql@language-features__switch-0.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__language-features__switch-0.prql.snap index 85bb6bac32b8..7618b9e71723 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__switch-0.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__switch-0.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/switch-0.prql +expression: "from employees\nderive distance = switch [\n city == \"Calgary\" -> 0,\n city == \"Edmonton\" -> 300,\n]\n" --- from employees derive distance = switch [ diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__switch-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__switch-1.prql.snap similarity index 51% rename from book/tests/snapshots/snapshot__run_display_reference_prql@language-features__switch-1.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__language-features__switch-1.prql.snap index dd4c64e0b6b0..f9ee3312b92b 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@language-features__switch-1.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__switch-1.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/language-features/switch-1.prql +expression: "from employees\nderive distance = switch [\n city == \"Calgary\" -> 0,\n city == \"Edmonton\" -> 300,\n true -> \"Unknown\",\n]\n" --- from employees derive distance = switch [ diff --git a/book/tests/snapshots/snapshot__tests__prql__language-features__target-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__target-0.prql.snap new file mode 100644 index 000000000000..b22539422ae4 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__target-0.prql.snap @@ -0,0 +1,14 @@ +--- +source: book/tests/snapshot.rs +expression: "prql target:sql.postgres\n\nfrom employees\nsort age\ntake 10\n" +--- +prql target:sql.postgres + + + +from employees +sort age +take 10 + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__language-features__target-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__target-1.prql.snap new file mode 100644 index 000000000000..ed7e10fd7388 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__target-1.prql.snap @@ -0,0 +1,14 @@ +--- +source: book/tests/snapshot.rs +expression: "prql target:sql.mssql\n\nfrom employees\nsort age\ntake 10\n" +--- +prql target:sql.mssql + + + +from employees +sort age +take 10 + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__language-features__target-2.prql.snap b/book/tests/snapshots/snapshot__tests__prql__language-features__target-2.prql.snap new file mode 100644 index 000000000000..b05787ed8bae --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__language-features__target-2.prql.snap @@ -0,0 +1,12 @@ +--- +source: book/tests/snapshot.rs +expression: "prql version:\"0.5\"\n\nfrom employees\n" +--- +prql version:^0.5 + + + +from employees + + + diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@queries__functions-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__queries__functions-0.prql.snap similarity index 54% rename from book/tests/snapshots/snapshot__run_display_reference_prql@queries__functions-0.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__queries__functions-0.prql.snap index bde459b05cf8..e5bb0a64491b 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@queries__functions-0.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__queries__functions-0.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/queries/functions-0.prql +expression: "func fahrenheit_to_celsius temp -> (temp - 32) / 1.8\n\nfrom cities\nderive temp_c = (fahrenheit_to_celsius temp_f)\n" --- func fahrenheit_to_celsius temp -> temp - 32 / 1.8 diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@queries__functions-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__queries__functions-1.prql.snap similarity index 51% rename from book/tests/snapshots/snapshot__run_display_reference_prql@queries__functions-1.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__queries__functions-1.prql.snap index d8d3e0185fd9..ef971e8402bc 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@queries__functions-1.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__queries__functions-1.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/queries/functions-1.prql +expression: "func interp lower:0 higher x -> (x - lower) / (higher - lower)\n\nfrom students\nderive [\n sat_proportion_1 = (interp 1600 sat_score),\n sat_proportion_2 = (interp lower:0 1600 sat_score),\n]\n" --- func interp higher x lower:0 -> x - lower / higher - lower diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@queries__functions-2.prql.snap b/book/tests/snapshots/snapshot__tests__prql__queries__functions-2.prql.snap similarity index 52% rename from book/tests/snapshots/snapshot__run_display_reference_prql@queries__functions-2.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__queries__functions-2.prql.snap index 49560fe48496..2e8f243ea009 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@queries__functions-2.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__queries__functions-2.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/queries/functions-2.prql +expression: "func interp lower:0 higher x -> (x - lower) / (higher - lower)\n\nfrom students\nderive [\n sat_proportion_1 = (sat_score | interp 1600),\n sat_proportion_2 = (sat_score | interp lower:0 1600),\n]\n" --- func interp higher x lower:0 -> x - lower / higher - lower diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@queries__functions-3.prql.snap b/book/tests/snapshots/snapshot__tests__prql__queries__functions-3.prql.snap similarity index 54% rename from book/tests/snapshots/snapshot__run_display_reference_prql@queries__functions-3.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__queries__functions-3.prql.snap index 83e91977fe3f..bc1453813dc9 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@queries__functions-3.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__queries__functions-3.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/queries/functions-3.prql +expression: "func fahrenheit_to_celsius temp -> (temp - 32) / 1.8\n\nfrom cities\nderive temp_c = (temp_f | fahrenheit_to_celsius)\n" --- func fahrenheit_to_celsius temp -> temp - 32 / 1.8 diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@queries__functions-4.prql.snap b/book/tests/snapshots/snapshot__tests__prql__queries__functions-4.prql.snap similarity index 52% rename from book/tests/snapshots/snapshot__run_display_reference_prql@queries__functions-4.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__queries__functions-4.prql.snap index 8ed62cca5158..3deae6fcab9c 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@queries__functions-4.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__queries__functions-4.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/queries/functions-4.prql +expression: "func fahrenheit_to_celsius temp -> (temp - 32) / 1.8\nfunc interp lower:0 higher x -> (x - lower) / (higher - lower)\n\nfrom kettles\nderive boiling_proportion = (temp_c | fahrenheit_to_celsius | interp 100)\n" --- func fahrenheit_to_celsius temp -> temp - 32 / 1.8 diff --git a/book/tests/snapshots/snapshot__tests__prql__queries__pipelines-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__queries__pipelines-0.prql.snap new file mode 100644 index 000000000000..8ef6dce0bb66 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__queries__pipelines-0.prql.snap @@ -0,0 +1,8 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\n" +--- +from employees + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__queries__pipelines-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__queries__pipelines-1.prql.snap new file mode 100644 index 000000000000..b2b18409f03a --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__queries__pipelines-1.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nderive gross_salary = (salary + payroll_tax)\n" +--- +from employees +derive gross_salary = salary + payroll_tax + + + diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@queries__pipelines-2.prql.snap b/book/tests/snapshots/snapshot__tests__prql__queries__pipelines-2.prql.snap similarity index 53% rename from book/tests/snapshots/snapshot__run_display_reference_prql@queries__pipelines-2.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__queries__pipelines-2.prql.snap index e3ff662251a8..5c74bd2eeb81 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@queries__pipelines-2.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__queries__pipelines-2.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/queries/pipelines-2.prql +expression: "from e = employees\nderive gross_salary = (salary + payroll_tax)\nsort gross_salary\ntake 10\njoin d = department [==dept_no]\nselect [e.name, gross_salary, d.name]\n" --- from e = employees derive gross_salary = salary + payroll_tax diff --git a/book/tests/snapshots/snapshot__tests__prql__queries__variables-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__queries__variables-0.prql.snap new file mode 100644 index 000000000000..3c4edace1010 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__queries__variables-0.prql.snap @@ -0,0 +1,17 @@ +--- +source: book/tests/snapshot.rs +expression: "let top_50 = (\n from employees\n sort salary\n take 50\n aggregate [total_salary = sum salary]\n)\n\nfrom top_50 # Starts a new pipeline\n" +--- +let top_50 = ( + from employees + sort salary + take 50 + aggregate [total_salary = sum salary] +) + + + +from top_50 + + + diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@queries__variables-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__queries__variables-1.prql.snap similarity index 51% rename from book/tests/snapshots/snapshot__run_display_reference_prql@queries__variables-1.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__queries__variables-1.prql.snap index f7a3cbcd9431..dd72ddc9b4bb 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@queries__variables-1.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__queries__variables-1.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/queries/variables-1.prql +expression: "let grouping = s\"\"\"\n SELECT SUM(a)\n FROM tbl\n GROUP BY\n GROUPING SETS\n ((b, c, d), (d), (b, d))\n\"\"\"\n\nfrom grouping\n" --- let grouping = s" SELECT SUM(a) diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__syntax-0.prql.snap similarity index 55% rename from book/tests/snapshots/snapshot__run_display_reference_prql@syntax-0.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__syntax-0.prql.snap index 16788f8c5410..ee78d7a29c00 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-0.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__syntax-0.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/syntax-0.prql +expression: "from employees\nfilter department == \"Product\"\nselect [first_name, last_name]\n" --- from employees filter department == "Product" diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__syntax-1.prql.snap similarity index 55% rename from book/tests/snapshots/snapshot__run_display_reference_prql@syntax-1.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__syntax-1.prql.snap index 7d3684118966..ae9d7fcbb81c 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-1.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__syntax-1.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/syntax-1.prql +expression: "from employees | filter department == \"Product\" | select [first_name, last_name]\n" --- from employees filter department == "Product" diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-10.prql.snap b/book/tests/snapshots/snapshot__tests__prql__syntax-10.prql.snap similarity index 50% rename from book/tests/snapshots/snapshot__run_display_reference_prql@syntax-10.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__syntax-10.prql.snap index e12239744931..0ef6f6c5ea4e 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-10.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__syntax-10.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/syntax-10.prql +expression: "prql target:sql.postgres\nfrom employees\nselect `first name`\n" --- prql target:sql.postgres diff --git a/book/tests/snapshots/snapshot__tests__prql__syntax-11.prql.snap b/book/tests/snapshots/snapshot__tests__prql__syntax-11.prql.snap new file mode 100644 index 000000000000..acd1651bdbb9 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__syntax-11.prql.snap @@ -0,0 +1,8 @@ +--- +source: book/tests/snapshot.rs +expression: "from `dir/*.parquet`\n" +--- +from `dir/*.parquet` + + + diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-12.prql.snap b/book/tests/snapshots/snapshot__tests__prql__syntax-12.prql.snap similarity index 55% rename from book/tests/snapshots/snapshot__run_display_reference_prql@syntax-12.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__syntax-12.prql.snap index 79ec4c9aa74d..6be462d1cb08 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-12.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__syntax-12.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/syntax-12.prql +expression: "prql target:sql.bigquery\nfrom `project-foo.dataset.table`\njoin `project-bar.dataset.table` [==col_bax]\n" --- prql target:sql.bigquery diff --git a/book/tests/snapshots/snapshot__tests__prql__syntax-13.prql.snap b/book/tests/snapshots/snapshot__tests__prql__syntax-13.prql.snap new file mode 100644 index 000000000000..fc9310bcceea --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__syntax-13.prql.snap @@ -0,0 +1,8 @@ +--- +source: book/tests/snapshot.rs +expression: "from `music.albums`\n" +--- +from `music.albums` + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__syntax-14.prql.snap b/book/tests/snapshots/snapshot__tests__prql__syntax-14.prql.snap new file mode 100644 index 000000000000..429e57d0faf3 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__syntax-14.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nfilter id == $1\n" +--- +from employees +filter id == $1 + + + diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-15.prql.snap b/book/tests/snapshots/snapshot__tests__prql__syntax-15.prql.snap similarity index 50% rename from book/tests/snapshots/snapshot__run_display_reference_prql@syntax-15.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__syntax-15.prql.snap index 34d44267ba17..7aa2caf4c217 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-15.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__syntax-15.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/syntax-15.prql +expression: "from numbers\nselect [\n small = 1.000_000_1,\n big = 5_000_000,\n]\n" --- from numbers select [ diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-2.prql.snap b/book/tests/snapshots/snapshot__tests__prql__syntax-2.prql.snap similarity index 54% rename from book/tests/snapshots/snapshot__run_display_reference_prql@syntax-2.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__syntax-2.prql.snap index 8c5b5825e8c4..a12652162d23 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-2.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__syntax-2.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/syntax-2.prql +expression: "from numbers\nderive [x = 1, y = 2]\nderive [\n a = x,\n b = y\n]\nderive [\n c = a,\n d = b,\n]\n" --- from numbers derive [ diff --git a/book/tests/snapshots/snapshot__tests__prql__syntax-3.prql.snap b/book/tests/snapshots/snapshot__tests__prql__syntax-3.prql.snap new file mode 100644 index 000000000000..4077d71aaa9b --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__syntax-3.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nselect [first_name]\n" +--- +from employees +select [first_name] + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__syntax-4.prql.snap b/book/tests/snapshots/snapshot__tests__prql__syntax-4.prql.snap new file mode 100644 index 000000000000..56e49df27e11 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__syntax-4.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nselect first_name\n" +--- +from employees +select first_name + + + diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-5.prql.snap b/book/tests/snapshots/snapshot__tests__prql__syntax-5.prql.snap similarity index 53% rename from book/tests/snapshots/snapshot__run_display_reference_prql@syntax-5.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__syntax-5.prql.snap index f3ebf960c4bf..027e1a5e000f 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-5.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__syntax-5.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/syntax-5.prql +expression: "from foo\nselect [\n circumference = diameter * 3.14159,\n color,\n]\nfilter circumference > 10 and color != \"red\"\n" --- from foo select [ diff --git a/book/tests/snapshots/snapshot__tests__prql__syntax-6.prql.snap b/book/tests/snapshots/snapshot__tests__prql__syntax-6.prql.snap new file mode 100644 index 000000000000..b9f326d968cc --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__syntax-6.prql.snap @@ -0,0 +1,39 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\n# Requires parentheses, because it's contains a pipe\nderive is_proximate = (distance | in 0..20)\n# Requires parentheses, because it's a function call\nderive total_distance = (sum distance)\n# `??` doesn't require parentheses, as it's not a function call\nderive min_capped_distance = (min distance ?? 5)\n# No parentheses needed, because no function call\nderive travel_time = distance / 40\n# No inner parentheses needed around `1+1` because no function call\nderive distance_rounded_2_dp = (round 1+1 distance)\nderive [\n # Requires parentheses, because it contains a pipe\n is_far = (distance | in 100..),\n # The left value of the range requires parentheses,\n # because of the minus sign\n is_negative = (distance | in (-100..0)),\n # ...this is equivalent\n is_negative = (distance | in (-100)..0),\n # Doesn't require parentheses, because it's in a list (confusing, see footnote)!\n average_distance = average distance,\n]\n# Requires parentheses because of the minus sign\nsort (-distance)\n# A list is fine too\nsort [-distance]\n" +--- +from employees +derive is_proximate = ( + distance + in 0..20 +) +derive ( + total_distance = sum distance +) +derive ( + min_capped_distance = min distance ?? 5 +) +derive travel_time = distance / 40 +derive ( + distance_rounded_2_dp = round 1 + 1 distance +) +derive [ + is_far = ( + distance + in 100.. +), + is_negative = ( + distance + in -100..0 +), + is_negative = ( + distance + in -100..0 +), + average_distance = average distance, +] +sort -distance +sort [-distance] + + + diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-7.prql.snap b/book/tests/snapshots/snapshot__tests__prql__syntax-7.prql.snap similarity index 54% rename from book/tests/snapshots/snapshot__run_display_reference_prql@syntax-7.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__syntax-7.prql.snap index 29e0c6d26c1e..81e0a3146955 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-7.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__syntax-7.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/syntax-7.prql +expression: "from employees\ngroup [title, country] (\n aggregate [\n average salary,\n ct = count\n ]\n)\n" --- from employees group [ diff --git a/book/tests/snapshots/snapshot__tests__prql__syntax-8.prql.snap b/book/tests/snapshots/snapshot__tests__prql__syntax-8.prql.snap new file mode 100644 index 000000000000..4f94033b1f86 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__syntax-8.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees # Comment 1\n# Comment 2\naggregate [average salary]\n" +--- +from employees +aggregate [average salary] + + + diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-9.prql.snap b/book/tests/snapshots/snapshot__tests__prql__syntax-9.prql.snap similarity index 50% rename from book/tests/snapshots/snapshot__run_display_reference_prql@syntax-9.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__syntax-9.prql.snap index 9e5a61c3e446..19c4de64822f 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@syntax-9.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__syntax-9.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/syntax-9.prql +expression: "prql target:sql.mysql\nfrom employees\nselect `first name`\n" --- prql target:sql.mysql diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__aggregate-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__aggregate-0.prql.snap new file mode 100644 index 000000000000..1c202ec4ba25 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__aggregate-0.prql.snap @@ -0,0 +1,12 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\naggregate [\n average salary,\n ct = count\n]\n" +--- +from employees +aggregate [ + average salary, + ct = count, +] + + + diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__aggregate-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__aggregate-1.prql.snap similarity index 54% rename from book/tests/snapshots/snapshot__run_display_reference_prql@transforms__aggregate-1.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__transforms__aggregate-1.prql.snap index bbf253ec6dd5..81e0a3146955 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__aggregate-1.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__aggregate-1.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/aggregate-1.prql +expression: "from employees\ngroup [title, country] (\n aggregate [\n average salary,\n ct = count\n ]\n)\n" --- from employees group [ diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__aggregate-2.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__aggregate-2.prql.snap new file mode 100644 index 000000000000..9b49b51df2a5 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__aggregate-2.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nderive [avg_sal = average salary]\n" +--- +from employees +derive [avg_sal = average salary] + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__append-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__append-0.prql.snap new file mode 100644 index 000000000000..cbbd0478001b --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__append-0.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees_1\nappend employees_2\n" +--- +from employees_1 +append employees_2 + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__append-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__append-1.prql.snap new file mode 100644 index 000000000000..e2b9a1338479 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__append-1.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees_1\nremove employees_2\n" +--- +from employees_1 +remove employees_2 + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__append-2.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__append-2.prql.snap new file mode 100644 index 000000000000..1971d287b890 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__append-2.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees_1\nintersect employees_2\n" +--- +from employees_1 +intersect employees_2 + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__derive-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__derive-0.prql.snap new file mode 100644 index 000000000000..183b59f98112 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__derive-0.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nderive gross_salary = salary + payroll_tax\n" +--- +from employees +derive gross_salary = salary + payroll_tax + + + diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__derive-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__derive-1.prql.snap similarity index 54% rename from book/tests/snapshots/snapshot__run_display_reference_prql@transforms__derive-1.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__transforms__derive-1.prql.snap index f2b9dd7bd20d..3d298b6f9b55 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__derive-1.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__derive-1.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/derive-1.prql +expression: "from employees\nderive [\n gross_salary = salary + payroll_tax,\n gross_cost = gross_salary + benefits_cost\n]\n" --- from employees derive [ diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__filter-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__filter-0.prql.snap new file mode 100644 index 000000000000..bd5e2c425e25 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__filter-0.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nfilter age > 25\n" +--- +from employees +filter age > 25 + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__filter-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__filter-1.prql.snap new file mode 100644 index 000000000000..a6cb5b5b569e --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__filter-1.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nfilter (age > 25 or department != \"IT\")\n" +--- +from employees +filter age > 25 or department != "IT" + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__filter-2.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__filter-2.prql.snap new file mode 100644 index 000000000000..d3b04cd4de31 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__filter-2.prql.snap @@ -0,0 +1,12 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nfilter (age | in 25..40)\n" +--- +from employees +filter ( + age + in 25..40 +) + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__from-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__from-0.prql.snap new file mode 100644 index 000000000000..8ef6dce0bb66 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__from-0.prql.snap @@ -0,0 +1,8 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\n" +--- +from employees + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__from-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__from-1.prql.snap new file mode 100644 index 000000000000..ef1312a86941 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__from-1.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from e = employees\nselect e.first_name\n" +--- +from e = employees +select e.first_name + + + diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__from_text-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__from_text-0.prql.snap similarity index 50% rename from book/tests/snapshots/snapshot__run_display_reference_prql@transforms__from_text-0.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__transforms__from_text-0.prql.snap index d86f2e1e86bb..6a730d3a1f7e 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__from_text-0.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__from_text-0.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/from_text-0.prql +expression: "from_text \"\"\"\na,b,c\n1,2,3\n4,5,6\n\"\"\"\nderive [\n d = b + c,\n answer = 20 * 2 + 2,\n]\n" --- from_text " a,b,c diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__from_text-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__from_text-1.prql.snap similarity index 51% rename from book/tests/snapshots/snapshot__run_display_reference_prql@transforms__from_text-1.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__transforms__from_text-1.prql.snap index 740349748e00..6f9f848bbd6e 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__from_text-1.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__from_text-1.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/from_text-1.prql +expression: "let temp_format_lookup = from_text format:csv \"\"\"\ncountry_code,format\nuk,C\nus,F\nlr,F\nde,C\n\"\"\"\n\nfrom temperatures\njoin temp_format_lookup [==country_code]\n" --- let temp_format_lookup = ( from_text format:csv " diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__from_text-2.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__from_text-2.prql.snap new file mode 100644 index 000000000000..da17c3b1fe6f --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__from_text-2.prql.snap @@ -0,0 +1,32 @@ +--- +source: book/tests/snapshot.rs +expression: "let x = from_text format:json \"\"\"{\n \"columns\": [\"a\", \"b\", \"c\"],\n \"data\": [\n [1, \"x\", false],\n [4, \"y\", null]\n ]\n}\"\"\"\n\nlet y = from_text format:json \"\"\"\n [\n {\"a\": 1, \"m\": \"5\"},\n {\"a\": 4, \"n\": \"6\"}\n ]\n\"\"\"\n\nfrom x | join y [==a]\n" +--- +let x = ( + from_text format:json '{ + "columns": ["a", "b", "c"], + "data": [ + [1, "x", false], + [4, "y", null] + ] +}' +) + + + +let y = ( + from_text format:json ' + [ + {"a": 1, "m": "5"}, + {"a": 4, "n": "6"} + ] +' +) + + + +from x +join y [==a] + + + diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__group-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__group-0.prql.snap similarity index 54% rename from book/tests/snapshots/snapshot__run_display_reference_prql@transforms__group-0.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__transforms__group-0.prql.snap index 754f23c1d76e..81e0a3146955 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__group-0.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__group-0.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/group-0.prql +expression: "from employees\ngroup [title, country] (\n aggregate [\n average salary,\n ct = count\n ]\n)\n" --- from employees group [ diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__group-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__group-1.prql.snap new file mode 100644 index 000000000000..2517396a1418 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__group-1.prql.snap @@ -0,0 +1,10 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nsort join_date\ntake 1\n" +--- +from employees +sort join_date +take 1 + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__group-2.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__group-2.prql.snap new file mode 100644 index 000000000000..11467687bbbb --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__group-2.prql.snap @@ -0,0 +1,12 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\ngroup role (\n sort join_date # taken from above\n take 1\n)\n" +--- +from employees +group role ( + sort join_date + take 1 +) + + + diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__join-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__join-0.prql.snap similarity index 52% rename from book/tests/snapshots/snapshot__run_display_reference_prql@transforms__join-0.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__transforms__join-0.prql.snap index 0334411b6614..4d113382409a 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__join-0.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__join-0.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/join-0.prql +expression: "from employees\njoin side:left positions [employees.id==positions.employee_id]\n" --- from employees join side:left positions [employees.id == positions.employee_id] diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__join-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__join-1.prql.snap similarity index 51% rename from book/tests/snapshots/snapshot__run_display_reference_prql@transforms__join-1.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__transforms__join-1.prql.snap index 073e5b79b5ee..b3e13a1d23f8 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__join-1.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__join-1.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/join-1.prql +expression: "from employees\njoin side:left p=positions [employees.id==p.employee_id]\n" --- from employees join side:left p = positions [employees.id == p.employee_id] diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__join-2.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__join-2.prql.snap new file mode 100644 index 000000000000..ba833fa01b02 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__join-2.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\njoin positions [==emp_no]\n" +--- +from employees +join positions [==emp_no] + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__select-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__select-0.prql.snap new file mode 100644 index 000000000000..ef3e65965333 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__select-0.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nselect name = f\"{first_name} {last_name}\"\n" +--- +from employees +select name = f"{first_name} {last_name}" + + + diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__select-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__select-1.prql.snap similarity index 53% rename from book/tests/snapshots/snapshot__run_display_reference_prql@transforms__select-1.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__transforms__select-1.prql.snap index 1ecfbb0be8f6..57c345371217 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__select-1.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__select-1.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/select-1.prql +expression: "from employees\nselect [\n name = f\"{first_name} {last_name}\",\n age_eoy = dob - @2022-12-31,\n]\n" --- from employees select [ diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__select-2.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__select-2.prql.snap new file mode 100644 index 000000000000..56e49df27e11 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__select-2.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nselect first_name\n" +--- +from employees +select first_name + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__select-3.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__select-3.prql.snap new file mode 100644 index 000000000000..059b92276754 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__select-3.prql.snap @@ -0,0 +1,12 @@ +--- +source: book/tests/snapshot.rs +expression: "from e=employees\nselect [e.first_name, e.last_name]\n" +--- +from e = employees +select [ + e.first_name, + e.last_name, +] + + + diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__select-4.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__select-4.prql.snap similarity index 51% rename from book/tests/snapshots/snapshot__run_display_reference_prql@transforms__select-4.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__transforms__select-4.prql.snap index c8837e7a5780..6445588450d2 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__select-4.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__select-4.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/select-4.prql +expression: "prql target:sql.bigquery\nfrom tracks\nselect ![milliseconds,bytes]\n" --- prql target:sql.bigquery diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__select-5.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__select-5.prql.snap similarity index 55% rename from book/tests/snapshots/snapshot__run_display_reference_prql@transforms__select-5.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__transforms__select-5.prql.snap index ee470cf35cf6..568bc821ba4f 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__select-5.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__select-5.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/select-5.prql +expression: "from tracks\nselect [track_id, title, composer, bytes]\nselect ![title, composer]\n" --- from tracks select [ diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__select-6.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__select-6.prql.snap new file mode 100644 index 000000000000..19b65db61c48 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__select-6.prql.snap @@ -0,0 +1,10 @@ +--- +source: book/tests/snapshot.rs +expression: "from artists\nderive nick = name\nselect ![artists.*]\n" +--- +from artists +derive nick = name +select not [artists.`*`] + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__sort-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__sort-0.prql.snap new file mode 100644 index 000000000000..cb41ef4b5ddb --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__sort-0.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nsort age\n" +--- +from employees +sort age + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__sort-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__sort-1.prql.snap new file mode 100644 index 000000000000..12203dcc78d3 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__sort-1.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nsort [-age]\n" +--- +from employees +sort [-age] + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__sort-2.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__sort-2.prql.snap new file mode 100644 index 000000000000..23c2050900c8 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__sort-2.prql.snap @@ -0,0 +1,13 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nsort [age, -tenure, +salary]\n" +--- +from employees +sort [ + age, + -tenure, + salary, +] + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__sort-3.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__sort-3.prql.snap new file mode 100644 index 000000000000..01b0d75eb4e3 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__sort-3.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nsort [s\"substr({first_name}, 2, 5)\"]\n" +--- +from employees +sort [s"substr({first_name}, 2, 5)"] + + + diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__sort-4.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__sort-4.prql.snap similarity index 50% rename from book/tests/snapshots/snapshot__run_display_reference_prql@transforms__sort-4.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__transforms__sort-4.prql.snap index 01b5c740c41a..51c71b587af5 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__sort-4.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__sort-4.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/sort-4.prql +expression: "from employees\nsort tenure\nderive name = f\"{first_name} {last_name}\"\n" --- from employees sort tenure diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__sort-5.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__sort-5.prql.snap new file mode 100644 index 000000000000..405c461df7e4 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__sort-5.prql.snap @@ -0,0 +1,10 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nsort tenure\njoin locations [==employee_id]\n" +--- +from employees +sort tenure +join locations [==employee_id] + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__take-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__take-0.prql.snap new file mode 100644 index 000000000000..4c39e0cddcea --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__take-0.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\ntake 10\n" +--- +from employees +take 10 + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__take-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__take-1.prql.snap new file mode 100644 index 000000000000..b68c1920a669 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__take-1.prql.snap @@ -0,0 +1,13 @@ +--- +source: book/tests/snapshot.rs +expression: "from orders\nsort [-value, date]\ntake 101..110\n" +--- +from orders +sort [ + -value, + date, +] +take 101..110 + + + diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__window-0.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__window-0.prql.snap similarity index 52% rename from book/tests/snapshots/snapshot__run_display_reference_prql@transforms__window-0.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__transforms__window-0.prql.snap index 2366506585b0..08d6e23e2468 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__window-0.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__window-0.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/window-0.prql +expression: "from employees\ngroup employee_id (\n sort month\n window rolling:12 (\n derive [trail_12_m_comp = sum paycheck]\n )\n)\n" --- from employees group employee_id ( diff --git a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__window-1.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__window-1.prql.snap similarity index 51% rename from book/tests/snapshots/snapshot__run_display_reference_prql@transforms__window-1.prql.snap rename to book/tests/snapshots/snapshot__tests__prql__transforms__window-1.prql.snap index afffeb8eb185..c0663a94bc4a 100644 --- a/book/tests/snapshots/snapshot__run_display_reference_prql@transforms__window-1.prql.snap +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__window-1.prql.snap @@ -1,7 +1,6 @@ --- source: book/tests/snapshot.rs -expression: prql_to_pl(&prql).and_then(pl_to_prql).unwrap() -input_file: book/tests/prql/transforms/window-1.prql +expression: "from orders\nsort day\nwindow rows:-3..3 (\n derive [centered_weekly_average = average value]\n)\ngroup [order_month] (\n sort day\n window expanding:true (\n derive [monthly_running_total = sum value]\n )\n)\n" --- from orders sort day diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__window-2.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__window-2.prql.snap new file mode 100644 index 000000000000..dc3037c993b3 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__window-2.prql.snap @@ -0,0 +1,10 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nsort age\nderive rnk = rank\n" +--- +from employees +sort age +derive rnk = rank + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__window-3.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__window-3.prql.snap new file mode 100644 index 000000000000..b71455102a11 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__window-3.prql.snap @@ -0,0 +1,12 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\ngroup department (\n sort age\n derive rnk = rank\n)\n" +--- +from employees +group department ( + sort age + derive rnk = rank +) + + + diff --git a/book/tests/snapshots/snapshot__tests__prql__transforms__window-4.prql.snap b/book/tests/snapshots/snapshot__tests__prql__transforms__window-4.prql.snap new file mode 100644 index 000000000000..9e104fbe34a9 --- /dev/null +++ b/book/tests/snapshots/snapshot__tests__prql__transforms__window-4.prql.snap @@ -0,0 +1,9 @@ +--- +source: book/tests/snapshot.rs +expression: "from employees\nfilter salary < (average salary)\n" +--- +from employees +filter salary < ( average salary ) + + +