From e66d73b20fa20ba56036735a2f8b1f69f3fa8bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alja=C5=BE=20Mur=20Er=C5=BEen?= Date: Fri, 24 Jan 2025 15:29:25 +0100 Subject: [PATCH] refactor: remove any type --- lutra/lutra/src/pull_schema.rs | 4 +- prqlc/bindings/prqlc-python/src/lib.rs | 4 +- prqlc/prqlc-parser/src/parser/mod.rs | 1 - prqlc/prqlc-parser/src/parser/pr/types.rs | 27 +- prqlc/prqlc-parser/src/parser/types.rs | 59 +- prqlc/prqlc/src/cli/docs_generator.rs | 14 - prqlc/prqlc/src/cli/test.rs | 40 +- prqlc/prqlc/src/codegen/types.rs | 43 +- prqlc/prqlc/src/ir/pl/fold.rs | 19 +- prqlc/prqlc/src/semantic/lowering.rs | 15 +- prqlc/prqlc/src/semantic/module.rs | 2 +- prqlc/prqlc/src/semantic/resolver/expr.rs | 2 + .../prqlc/src/semantic/resolver/inference.rs | 2 + ...c__resolver__test__frames_and_names-2.snap | 9 +- ...c__resolver__test__frames_and_names-3.snap | 11 +- ...tic__resolver__test__frames_and_names.snap | 11 +- ...semantic__resolver__test__functions_1.snap | 26 - ...tic__resolver__test__functions_nested.snap | 66 -- ..._resolver__test__functions_pipeline-2.snap | 73 +- ...c__resolver__test__functions_pipeline.snap | 23 +- ..._semantic__resolver__test__named_args.snap | 51 -- ...semantic__resolver__test__variables_1.snap | 51 -- ...ms__tests__aggregate_positional_arg-2.snap | 251 +------ prqlc/prqlc/src/semantic/resolver/stmt.rs | 3 +- .../prqlc/src/semantic/resolver/transforms.rs | 21 +- prqlc/prqlc/src/semantic/resolver/types.rs | 544 +------------- prqlc/prqlc/src/semantic/std.prql | 84 +-- .../tests/integration/bad_error_messages.rs | 6 +- .../prqlc/tests/integration/error_messages.rs | 25 +- prqlc/prqlc/tests/integration/resolving.rs | 40 -- ...__queries__debug_lineage__aggregation.snap | 127 ++-- ...n__queries__debug_lineage__arithmetic.snap | 667 +++++++++--------- ...gration__queries__debug_lineage__cast.snap | 83 ++- ...ueries__debug_lineage__constants_only.snap | 87 ++- ..._queries__debug_lineage__date_to_text.snap | 249 ++++--- ...ion__queries__debug_lineage__distinct.snap | 101 ++- ...__queries__debug_lineage__distinct_on.snap | 119 ++-- ..._queries__debug_lineage__genre_counts.snap | 57 +- ...on__queries__debug_lineage__group_all.snap | 141 ++-- ...n__queries__debug_lineage__group_sort.snap | 149 ++-- ..._debug_lineage__group_sort_limit_take.snap | 171 +++-- ...ueries__debug_lineage__invoice_totals.snap | 433 ++++++------ ...tion__queries__debug_lineage__loop_01.snap | 201 +++--- ...__queries__debug_lineage__math_module.snap | 357 +++++----- ...on__queries__debug_lineage__pipelines.snap | 155 ++-- ...ion__queries__debug_lineage__read_csv.snap | 31 +- ...ueries__debug_lineage__set_ops_remove.snap | 175 +++-- ...gration__queries__debug_lineage__sort.snap | 139 ++-- ...ation__queries__debug_lineage__sort_2.snap | 124 ++-- ...ation__queries__debug_lineage__switch.snap | 103 ++- ...gration__queries__debug_lineage__take.snap | 43 +- ...__queries__debug_lineage__text_module.snap | 271 ++++--- ...ation__queries__debug_lineage__window.snap | 221 +++--- prqlc/prqlc/tests/integration/sql.rs | 19 +- 54 files changed, 2293 insertions(+), 3457 deletions(-) diff --git a/lutra/lutra/src/pull_schema.rs b/lutra/lutra/src/pull_schema.rs index 92094b9ee404..e989dbe031e2 100644 --- a/lutra/lutra/src/pull_schema.rs +++ b/lutra/lutra/src/pull_schema.rs @@ -48,8 +48,8 @@ fn convert_arrow_schema_to_table_def(table_name: String, schema: SchemaRef) -> R kind: prqlc::pr::VarDefKind::Let, name: table_name, value: None, - ty: Some(Ty::new(TyKind::Array(Box::new(Ty::new(TyKind::Tuple( - fields, + ty: Some(Ty::new(TyKind::Array(Some(Box::new(Ty::new( + TyKind::Tuple(fields), )))))), }; diff --git a/prqlc/bindings/prqlc-python/src/lib.rs b/prqlc/bindings/prqlc-python/src/lib.rs index cd4e91c9727f..31be8e04f7af 100644 --- a/prqlc/bindings/prqlc-python/src/lib.rs +++ b/prqlc/bindings/prqlc-python/src/lib.rs @@ -232,7 +232,7 @@ mod test { fn debug_prql_lineage() { assert_snapshot!( debug::prql_lineage(r#"from a | select { beta, gamma }"#).unwrap(), - @r#"{"frames":[["1:9-31",{"columns":[{"Single":{"name":["a","beta"],"target_id":120,"target_name":null}},{"Single":{"name":["a","gamma"],"target_id":121,"target_name":null}}],"inputs":[{"id":118,"name":"a","table":["default_db","a"]}]}]],"nodes":[{"id":118,"kind":"Ident","span":"1:0-6","ident":{"Ident":["default_db","a"]},"parent":123},{"id":120,"kind":"Ident","span":"1:18-22","ident":{"Ident":["this","a","beta"]},"targets":[118],"parent":122},{"id":121,"kind":"Ident","span":"1:24-29","ident":{"Ident":["this","a","gamma"]},"targets":[118],"parent":122},{"id":122,"kind":"Tuple","span":"1:16-31","children":[120,121],"parent":123},{"id":123,"kind":"TransformCall: Select","span":"1:9-31","children":[118,122]}],"ast":{"name":"Project","stmts":[{"VarDef":{"kind":"Main","name":"main","value":{"Pipeline":{"exprs":[{"FuncCall":{"name":{"Ident":"from","span":"1:0-4"},"args":[{"Ident":"a","span":"1:5-6"}]},"span":"1:0-6"},{"FuncCall":{"name":{"Ident":"select","span":"1:9-15"},"args":[{"Tuple":[{"Ident":"beta","span":"1:18-22"},{"Ident":"gamma","span":"1:24-29"}],"span":"1:16-31"}]},"span":"1:9-31"}]},"span":"1:0-31"}},"span":"1:0-31"}]}}"# + @r#"{"frames":[["1:9-31",{"columns":[{"Single":{"name":["a","beta"],"target_id":117,"target_name":null}},{"Single":{"name":["a","gamma"],"target_id":118,"target_name":null}}],"inputs":[{"id":115,"name":"a","table":["default_db","a"]}]}]],"nodes":[{"id":115,"kind":"Ident","span":"1:0-6","ident":{"Ident":["default_db","a"]},"parent":120},{"id":117,"kind":"Ident","span":"1:18-22","ident":{"Ident":["this","a","beta"]},"targets":[115],"parent":119},{"id":118,"kind":"Ident","span":"1:24-29","ident":{"Ident":["this","a","gamma"]},"targets":[115],"parent":119},{"id":119,"kind":"Tuple","span":"1:16-31","children":[117,118],"parent":120},{"id":120,"kind":"TransformCall: Select","span":"1:9-31","children":[115,119]}],"ast":{"name":"Project","stmts":[{"VarDef":{"kind":"Main","name":"main","value":{"Pipeline":{"exprs":[{"FuncCall":{"name":{"Ident":"from","span":"1:0-4"},"args":[{"Ident":"a","span":"1:5-6"}]},"span":"1:0-6"},{"FuncCall":{"name":{"Ident":"select","span":"1:9-15"},"args":[{"Tuple":[{"Ident":"beta","span":"1:18-22"},{"Ident":"gamma","span":"1:24-29"}],"span":"1:16-31"}]},"span":"1:9-31"}]},"span":"1:0-31"}},"span":"1:0-31"}]}}"# ); } @@ -240,7 +240,7 @@ mod test { fn debug_pl_to_lineage() { assert_snapshot!( prql_to_pl(r#"from a | select { beta, gamma }"#).and_then(|x| debug::pl_to_lineage(&x)).unwrap(), - @r#"{"frames":[["1:9-31",{"columns":[{"Single":{"name":["a","beta"],"target_id":120,"target_name":null}},{"Single":{"name":["a","gamma"],"target_id":121,"target_name":null}}],"inputs":[{"id":118,"name":"a","table":["default_db","a"]}]}]],"nodes":[{"id":118,"kind":"Ident","span":"1:0-6","ident":{"Ident":["default_db","a"]},"parent":123},{"id":120,"kind":"Ident","span":"1:18-22","ident":{"Ident":["this","a","beta"]},"targets":[118],"parent":122},{"id":121,"kind":"Ident","span":"1:24-29","ident":{"Ident":["this","a","gamma"]},"targets":[118],"parent":122},{"id":122,"kind":"Tuple","span":"1:16-31","children":[120,121],"parent":123},{"id":123,"kind":"TransformCall: Select","span":"1:9-31","children":[118,122]}],"ast":{"name":"Project","stmts":[{"VarDef":{"kind":"Main","name":"main","value":{"Pipeline":{"exprs":[{"FuncCall":{"name":{"Ident":"from","span":"1:0-4"},"args":[{"Ident":"a","span":"1:5-6"}]},"span":"1:0-6"},{"FuncCall":{"name":{"Ident":"select","span":"1:9-15"},"args":[{"Tuple":[{"Ident":"beta","span":"1:18-22"},{"Ident":"gamma","span":"1:24-29"}],"span":"1:16-31"}]},"span":"1:9-31"}]},"span":"1:0-31"}},"span":"1:0-31"}]}}"# + @r#"{"frames":[["1:9-31",{"columns":[{"Single":{"name":["a","beta"],"target_id":117,"target_name":null}},{"Single":{"name":["a","gamma"],"target_id":118,"target_name":null}}],"inputs":[{"id":115,"name":"a","table":["default_db","a"]}]}]],"nodes":[{"id":115,"kind":"Ident","span":"1:0-6","ident":{"Ident":["default_db","a"]},"parent":120},{"id":117,"kind":"Ident","span":"1:18-22","ident":{"Ident":["this","a","beta"]},"targets":[115],"parent":119},{"id":118,"kind":"Ident","span":"1:24-29","ident":{"Ident":["this","a","gamma"]},"targets":[115],"parent":119},{"id":119,"kind":"Tuple","span":"1:16-31","children":[117,118],"parent":120},{"id":120,"kind":"TransformCall: Select","span":"1:9-31","children":[115,119]}],"ast":{"name":"Project","stmts":[{"VarDef":{"kind":"Main","name":"main","value":{"Pipeline":{"exprs":[{"FuncCall":{"name":{"Ident":"from","span":"1:0-4"},"args":[{"Ident":"a","span":"1:5-6"}]},"span":"1:0-6"},{"FuncCall":{"name":{"Ident":"select","span":"1:9-15"},"args":[{"Tuple":[{"Ident":"beta","span":"1:18-22"},{"Ident":"gamma","span":"1:24-29"}],"span":"1:16-31"}]},"span":"1:9-31"}]},"span":"1:0-31"}},"span":"1:0-31"}]}}"# ); } } diff --git a/prqlc/prqlc-parser/src/parser/mod.rs b/prqlc/prqlc-parser/src/parser/mod.rs index f28ebff71fed..4644f75e38d2 100644 --- a/prqlc/prqlc-parser/src/parser/mod.rs +++ b/prqlc/prqlc-parser/src/parser/mod.rs @@ -60,7 +60,6 @@ pub(crate) fn prepare_stream<'a>( fn ident_part() -> impl Parser + Clone { select! { TokenKind::Ident(ident) => ident, - TokenKind::Keyword(ident) if &ident == "module" => ident, } .map_err(|e: PError| { PError::expected_input_found( diff --git a/prqlc/prqlc-parser/src/parser/pr/types.rs b/prqlc/prqlc-parser/src/parser/pr/types.rs index 98bda0ba6f25..d75c9f21459b 100644 --- a/prqlc/prqlc-parser/src/parser/pr/types.rs +++ b/prqlc/prqlc-parser/src/parser/pr/types.rs @@ -28,22 +28,15 @@ pub enum TyKind { /// Type that contains only a one value Singleton(Literal), - /// Union of sets (sum) - Union(Vec<(Option, Ty)>), - /// Type of tuples (product) Tuple(Vec), /// Type of arrays - Array(Box), + Array(Option>), /// Type of functions with defined params and return types. Function(Option), - /// Type of every possible value. Super type of all other types. - /// The breaker of chains. Mother of types. - Any, - /// Type that is the largest subtype of `base` while not a subtype of `exclude`. Difference { base: Box, exclude: Box }, @@ -119,32 +112,24 @@ impl Ty { pub fn relation(tuple_fields: Vec) -> Self { let tuple = Ty::new(TyKind::Tuple(tuple_fields)); - Ty::new(TyKind::Array(Box::new(tuple))) - } - - pub fn never() -> Self { - Ty::new(TyKind::Union(Vec::new())) - } - - pub fn is_never(&self) -> bool { - self.kind.as_union().map_or(false, |x| x.is_empty()) + Ty::new(TyKind::Array(Some(Box::new(tuple)))) } pub fn as_relation(&self) -> Option<&Vec> { - self.kind.as_array()?.kind.as_tuple() + self.kind.as_array()?.as_ref()?.kind.as_tuple() } pub fn as_relation_mut(&mut self) -> Option<&mut Vec> { - self.kind.as_array_mut()?.kind.as_tuple_mut() + self.kind.as_array_mut()?.as_mut()?.kind.as_tuple_mut() } pub fn into_relation(self) -> Option> { - self.kind.into_array().ok()?.kind.into_tuple().ok() + self.kind.into_array().ok()??.kind.into_tuple().ok() } pub fn is_relation(&self) -> bool { match &self.kind { - TyKind::Array(elem) => { + TyKind::Array(Some(elem)) => { matches!(elem.kind, TyKind::Tuple(_)) } _ => false, diff --git a/prqlc/prqlc-parser/src/parser/types.rs b/prqlc/prqlc-parser/src/parser/types.rs index 5f34d6212430..767dd9e65d4e 100644 --- a/prqlc/prqlc-parser/src/parser/types.rs +++ b/prqlc/prqlc-parser/src/parser/types.rs @@ -17,7 +17,6 @@ pub(crate) fn type_expr() -> impl Parser + Clone TokenKind::Ident(i) if i == "date"=> TyKind::Primitive(PrimitiveSet::Date), TokenKind::Ident(i) if i == "time"=> TyKind::Primitive(PrimitiveSet::Time), TokenKind::Ident(i) if i == "timestamp"=> TyKind::Primitive(PrimitiveSet::Timestamp), - TokenKind::Ident(i) if i == "anytype"=> TyKind::Any, }; let ident = ident().map(TyKind::Ident); @@ -40,14 +39,16 @@ pub(crate) fn type_expr() -> impl Parser + Clone .map(TyKind::Function); let tuple = sequence(choice(( + select! { TokenKind::Range { bind_right: false, bind_left: _ } => () } + .to(TyTupleField::Wildcard(None)), select! { TokenKind::Range { bind_right: true, bind_left: _ } => () } - .ignore_then(nested_type_expr.clone()) - .map(|ty| TyTupleField::Wildcard(Some(ty))), + .ignore_then(nested_type_expr.clone().or_not()) + .map(TyTupleField::Wildcard), ident_part() .then_ignore(ctrl('=')) .or_not() - .then(nested_type_expr.clone()) - .map(|(name, ty)| TyTupleField::Single(name, Some(ty))), + .then(ctrl('*').to(None).or(nested_type_expr.clone().map(Some))) + .map(|(name, ty)| TyTupleField::Single(name, ty)), ))) .delimited_by(ctrl('{'), ctrl('}')) .recover_with(nested_delimiters( @@ -76,35 +77,9 @@ pub(crate) fn type_expr() -> impl Parser + Clone .map(TyKind::Tuple) .labelled("tuple"); - let enum_ = keyword("enum") - .ignore_then( - sequence( - ident_part() - .then(ctrl('=').ignore_then(nested_type_expr.clone()).or_not()) - .map(|(name, ty)| { - ( - Some(name), - ty.unwrap_or_else(|| Ty::new(TyKind::Tuple(vec![]))), - ) - }), - ) - .delimited_by(ctrl('{'), ctrl('}')) - .recover_with(nested_delimiters( - TokenKind::Control('{'), - TokenKind::Control('}'), - [ - (TokenKind::Control('{'), TokenKind::Control('}')), - (TokenKind::Control('('), TokenKind::Control(')')), - (TokenKind::Control('['), TokenKind::Control(']')), - ], - |_| vec![], - )), - ) - .map(TyKind::Union) - .labelled("union"); - let array = nested_type_expr .map(Box::new) + .or_not() .padded_by(new_line().repeated()) .delimited_by(ctrl('['), ctrl(']')) .recover_with(nested_delimiters( @@ -115,14 +90,12 @@ pub(crate) fn type_expr() -> impl Parser + Clone (TokenKind::Control('('), TokenKind::Control(')')), (TokenKind::Control('['), TokenKind::Control(']')), ], - |_| Box::new(Ty::new(TyKind::Tuple(vec![]))), + |_| None, )) .map(TyKind::Array) .labelled("array"); - let term = choice((basic, ident, func, tuple, array, enum_)) - .map_with_span(TyKind::into_ty) - .boxed(); + choice((basic, ident, func, tuple, array)).map_with_span(TyKind::into_ty) // exclude // term.clone() @@ -142,20 +115,6 @@ pub(crate) fn type_expr() -> impl Parser + Clone // }; // into_ty(kind, span) // }); - - // union - term.clone() - .then(just(TokenKind::Or).ignore_then(term).repeated()) - .map_with_span(|(first, following), span| { - if following.is_empty() { - first - } else { - let mut all = Vec::with_capacity(following.len() + 1); - all.push((None, first)); - all.extend(following.into_iter().map(|x| (None, x))); - TyKind::Union(all).into_ty(span) - } - }) }) .labelled("type expression") } diff --git a/prqlc/prqlc/src/cli/docs_generator.rs b/prqlc/prqlc/src/cli/docs_generator.rs index 757fe3164789..c3afe239fa5b 100644 --- a/prqlc/prqlc/src/cli/docs_generator.rs +++ b/prqlc/prqlc/src/cli/docs_generator.rs @@ -160,7 +160,6 @@ pub fn generate_html_docs(stmts: Vec) -> String { if let Some(return_ty) = &func.return_ty { docs.push_str("

Returns

\n"); match &return_ty.kind { - TyKind::Any => docs.push_str("

Any

\n"), TyKind::Ident(ident) => { docs.push_str(&format!("

{}

\n", ident.name)); } @@ -170,13 +169,6 @@ pub fn generate_html_docs(stmts: Vec) -> String { TyKind::Singleton(literal) => { docs.push_str(&format!("

{literal}

\n")); } - TyKind::Union(vec) => { - docs.push_str("
    \n"); - for (_, ty) in vec { - docs.push_str(&format!("
  • {:?}
  • \n", ty.kind)); - } - docs.push_str("
\n"); - } _ => docs.push_str("

Not implemented

\n"), } } @@ -319,7 +311,6 @@ Generated with [prqlc](https://prql-lang.org/) {}. if let Some(return_ty) = &func.return_ty { docs.push_str("#### Returns\n"); match &return_ty.kind { - TyKind::Any => docs.push_str("Any\n"), TyKind::Ident(ident) => { docs.push_str(&format!("`{}`\n", ident.name)); } @@ -329,11 +320,6 @@ Generated with [prqlc](https://prql-lang.org/) {}. TyKind::Singleton(literal) => { docs.push_str(&format!("`{literal}`\n")); } - TyKind::Union(vec) => { - for (_, ty) in vec { - docs.push_str(&format!("* {:?}\n", ty.kind)); - } - } _ => docs.push_str("Not implemented\n"), } } diff --git a/prqlc/prqlc/src/cli/test.rs b/prqlc/prqlc/src/cli/test.rs index 742736396a2b..6a57290f4021 100644 --- a/prqlc/prqlc/src/cli/test.rs +++ b/prqlc/prqlc/src/cli/test.rs @@ -394,7 +394,7 @@ fn compare_directories(dir1: &Path, dir2: &Path) { fn debug() { assert_cmd_snapshot!(prqlc_command() .args(["debug", "lineage"]) - .pass_stdin("from tracks | select {artist, album}"), @r###" + .pass_stdin("from tracks | select {artist, album}"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -405,29 +405,29 @@ fn debug() { name: - tracks - artist - target_id: 120 + target_id: 117 target_name: null - !Single name: - tracks - album - target_id: 121 + target_id: 118 target_name: null inputs: - - id: 118 + - id: 115 name: tracks table: - default_db - tracks nodes: - - id: 118 + - id: 115 kind: Ident span: 1:0-11 ident: !Ident - default_db - tracks - parent: 123 - - id: 120 + parent: 120 + - id: 117 kind: Ident span: 1:22-28 ident: !Ident @@ -435,9 +435,9 @@ fn debug() { - tracks - artist targets: - - 118 - parent: 122 - - id: 121 + - 115 + parent: 119 + - id: 118 kind: Ident span: 1:30-35 ident: !Ident @@ -445,21 +445,21 @@ fn debug() { - tracks - album targets: - - 118 - parent: 122 - - id: 122 + - 115 + parent: 119 + - id: 119 kind: Tuple span: 1:21-36 children: - - 120 - - 121 - parent: 123 - - id: 123 + - 117 + - 118 + parent: 120 + - id: 120 kind: 'TransformCall: Select' span: 1:14-36 children: - - 118 - - 122 + - 115 + - 119 ast: name: Project stmts: @@ -493,7 +493,7 @@ fn debug() { span: 1:0-36 ----- stderr ----- - "###); + "#); // Don't test the output of this, since on one min-versions check it had // different results, and didn't repro on Mac. It having different results diff --git a/prqlc/prqlc/src/codegen/types.rs b/prqlc/prqlc/src/codegen/types.rs index bca6ca0aa201..cc3ccface1cc 100644 --- a/prqlc/prqlc/src/codegen/types.rs +++ b/prqlc/prqlc/src/codegen/types.rs @@ -26,7 +26,7 @@ impl WriteSource for Option<&pr::Ty> { fn write(&self, opt: WriteOpt) -> Option { match self { Some(ty) => ty.write(opt), - None => Some("infer".to_string()), + None => Some("?".to_string()), } } } @@ -38,26 +38,6 @@ impl WriteSource for pr::TyKind { match &self { Ident(ident) => ident.write(opt), Primitive(prim) => Some(prim.to_string()), - Union(variants) => { - let parenthesize = - // never must be parenthesized - variants.is_empty() || - // named union must be parenthesized - variants.iter().any(|(n, _)| n.is_some()); - - let variants: Vec<_> = variants.iter().map(|(n, t)| UnionVariant(n, t)).collect(); - let sep_exprs = SeparatedExprs { - exprs: &variants, - inline: " || ", - line_end: " ||", - }; - - if parenthesize { - sep_exprs.write_between("(", ")", opt) - } else { - sep_exprs.write(opt) - } - } Singleton(lit) => Some(lit.to_string()), Tuple(elements) => SeparatedExprs { exprs: elements, @@ -65,7 +45,8 @@ impl WriteSource for pr::TyKind { line_end: ",", } .write_between("{", "}", opt), - Array(elem) => Some(format!("[{}]", elem.write(opt)?)), + Array(Some(elem)) => Some(format!("[{}]", elem.write(opt)?)), + Array(None) => Some("[]".into()), Function(None) => Some("func".to_string()), Function(Some(func)) => { let mut r = "func ".to_string(); @@ -78,7 +59,6 @@ impl WriteSource for pr::TyKind { r += &func.return_ty.as_deref().write(opt)?; Some(r) } - Any => Some("anytype".to_string()), Difference { base, exclude } => { let base = base.write(opt.clone())?; let exclude = exclude.write(opt.clone())?; @@ -94,7 +74,7 @@ impl WriteSource for pr::TyTupleField { match self { Self::Wildcard(generic_el) => match generic_el { Some(el) => Some(format!("{}..", el.write(opt)?)), - None => Some("*..".to_string()), + None => Some("..".to_string()), }, Self::Single(name, expr) => { let mut r = String::new(); @@ -113,18 +93,3 @@ impl WriteSource for pr::TyTupleField { } } } - -struct UnionVariant<'a>(&'a Option, &'a pr::Ty); - -impl WriteSource for UnionVariant<'_> { - fn write(&self, mut opt: WriteOpt) -> Option { - let mut r = String::new(); - if let Some(name) = &self.0 { - r += name; - r += " = "; - } - opt.consume_width(r.len() as u16); - r += &self.1.write(opt)?; - Some(r) - } -} diff --git a/prqlc/prqlc/src/ir/pl/fold.rs b/prqlc/prqlc/src/ir/pl/fold.rs index 8714d52b1f2f..ad95845d7513 100644 --- a/prqlc/prqlc/src/ir/pl/fold.rs +++ b/prqlc/prqlc/src/ir/pl/fold.rs @@ -306,15 +306,17 @@ pub fn fold_type_opt(fold: &mut T, ty: Option) -> Result ty.map(|t| fold.fold_type(t)).transpose() } +#[inline] +pub fn fold_type_opt_box( + fold: &mut T, + ty: Option>, +) -> Result>> { + ty.map(|t| fold.fold_type(*t).map(Box::new)).transpose() +} + pub fn fold_type(fold: &mut T, ty: Ty) -> Result { Ok(Ty { kind: match ty.kind { - TyKind::Union(variants) => TyKind::Union( - variants - .into_iter() - .map(|(name, ty)| -> Result<_> { Ok((name, fold.fold_type(ty)?)) }) - .try_collect()?, - ), TyKind::Tuple(fields) => TyKind::Tuple( fields .into_iter() @@ -330,7 +332,7 @@ pub fn fold_type(fold: &mut T, ty: Ty) -> Result { }) .try_collect()?, ), - TyKind::Array(ty) => TyKind::Array(Box::new(fold.fold_type(*ty)?)), + TyKind::Array(ty) => TyKind::Array(fold_type_opt_box(fold, ty)?), TyKind::Function(func) => TyKind::Function( func.map(|f| -> Result<_> { Ok(TyFunc { @@ -349,8 +351,7 @@ pub fn fold_type(fold: &mut T, ty: Ty) -> Result { base: Box::new(fold.fold_type(*base)?), exclude: Box::new(fold.fold_type(*exclude)?), }, - TyKind::Any - | TyKind::Ident(_) + TyKind::Ident(_) | TyKind::Primitive(_) | TyKind::Singleton(_) | TyKind::GenericArg(_) => ty.kind, diff --git a/prqlc/prqlc/src/semantic/lowering.rs b/prqlc/prqlc/src/semantic/lowering.rs index fc089100927e..c37b823a95f5 100644 --- a/prqlc/prqlc/src/semantic/lowering.rs +++ b/prqlc/prqlc/src/semantic/lowering.rs @@ -358,14 +358,15 @@ impl Lowerer { let tid = self.tid.gen(); // pull columns from the table decl - let frame = expr.lineage.as_ref().unwrap(); - let columns = (frame.columns.iter()) - .map(|c| { - RelationColumn::Single( - c.as_single().unwrap().0.as_ref().map(|i| i.name.clone()), - ) + let lineage = expr.lineage.as_ref().unwrap(); + let columns: Vec<_> = (lineage.columns.iter()) + .map(|c| match c { + LineageColumn::Single { name, .. } => Ok(RelationColumn::Single( + name.as_ref().map(|i| i.name.clone()), + )), + LineageColumn::All { .. } => Err(Error::new_bug(4317)), }) - .collect_vec(); + .try_collect()?; let lit = RelationLiteral { columns: columns diff --git a/prqlc/prqlc/src/semantic/module.rs b/prqlc/prqlc/src/semantic/module.rs index 56719d8a3d98..8435f961cc72 100644 --- a/prqlc/prqlc/src/semantic/module.rs +++ b/prqlc/prqlc/src/semantic/module.rs @@ -196,7 +196,7 @@ impl Module { let namespace = self.names.entry(namespace.to_string()).or_default(); let namespace = namespace.kind.as_module_mut().unwrap(); - let lin_ty = *ty_of_lineage(lineage).kind.into_array().unwrap(); + let lin_ty = *ty_of_lineage(lineage).kind.into_array().unwrap().unwrap(); for (col_index, column) in lineage.columns.iter().enumerate() { // determine input name diff --git a/prqlc/prqlc/src/semantic/resolver/expr.rs b/prqlc/prqlc/src/semantic/resolver/expr.rs index 6377b192ebed..8f0fffc6d43b 100644 --- a/prqlc/prqlc/src/semantic/resolver/expr.rs +++ b/prqlc/prqlc/src/semantic/resolver/expr.rs @@ -226,6 +226,8 @@ impl Resolver<'_> { if let pl::ExprKind::TransformCall(call) = &r.kind { r.lineage = Some(call.infer_lineage()?); } else if let Some(relation_columns) = r.ty.as_ref().and_then(|t| t.as_relation()) { + log::debug!("found a relational type without lineage: declaring a new table for it: {relation_columns:?}"); + // lineage from ty let columns = Some(relation_columns.clone()); diff --git a/prqlc/prqlc/src/semantic/resolver/inference.rs b/prqlc/prqlc/src/semantic/resolver/inference.rs index fa8b55678fac..996e4f1152af 100644 --- a/prqlc/prqlc/src/semantic/resolver/inference.rs +++ b/prqlc/prqlc/src/semantic/resolver/inference.rs @@ -118,6 +118,8 @@ impl Resolver<'_> { columns: Option>, name_hint: Option, ) -> Lineage { + log::debug!("declare_table_for_literal: {input_id:?} {columns:?} {name_hint:?}"); + let id = input_id; let global_name = format!("_literal_{}", id); diff --git a/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__frames_and_names-2.snap b/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__frames_and_names-2.snap index 640d43f00166..f81ac569c100 100644 --- a/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__frames_and_names-2.snap +++ b/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__frames_and_names-2.snap @@ -1,22 +1,21 @@ --- source: prqlc/prqlc/src/semantic/resolver/mod.rs expression: "resolve_lineage(r#\"\n from table_1\n join customers (==customer_no)\n \"#).unwrap()" -snapshot_kind: text --- columns: - All: - input_id: 119 + input_id: 116 except: [] - All: - input_id: 116 + input_id: 113 except: [] inputs: - - id: 119 + - id: 116 name: table_1 table: - default_db - table_1 - - id: 116 + - id: 113 name: customers table: - default_db diff --git a/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__frames_and_names-3.snap b/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__frames_and_names-3.snap index c5d44b10b0a4..dc1406d18d08 100644 --- a/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__frames_and_names-3.snap +++ b/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__frames_and_names-3.snap @@ -1,33 +1,32 @@ --- source: prqlc/prqlc/src/semantic/resolver/mod.rs expression: "resolve_lineage(r#\"\n from e = employees\n join salaries (==emp_no)\n group {e.emp_no, e.gender} (\n aggregate {\n emp_salary = average salaries.salary\n }\n )\n \"#).unwrap()" -snapshot_kind: text --- columns: - Single: name: - e - emp_no - target_id: 129 + target_id: 126 target_name: ~ - Single: name: - e - gender - target_id: 130 + target_id: 127 target_name: ~ - Single: name: - emp_salary - target_id: 148 + target_id: 145 target_name: ~ inputs: - - id: 122 + - id: 119 name: e table: - default_db - employees - - id: 119 + - id: 116 name: salaries table: - default_db diff --git a/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__frames_and_names.snap b/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__frames_and_names.snap index d46aa3fb3631..f90554639aa3 100644 --- a/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__frames_and_names.snap +++ b/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__frames_and_names.snap @@ -1,33 +1,32 @@ --- source: prqlc/prqlc/src/semantic/resolver/mod.rs expression: "resolve_lineage(r#\"\n from orders\n select {customer_no, gross, tax, gross - tax}\n take 20\n \"#).unwrap()" -snapshot_kind: text --- columns: - Single: name: - orders - customer_no - target_id: 123 + target_id: 120 target_name: ~ - Single: name: - orders - gross - target_id: 124 + target_id: 121 target_name: ~ - Single: name: - orders - tax - target_id: 125 + target_id: 122 target_name: ~ - Single: name: ~ - target_id: 126 + target_id: 123 target_name: ~ inputs: - - id: 121 + - id: 118 name: orders table: - default_db diff --git a/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__functions_1.snap b/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__functions_1.snap index 1f13e0b50b7e..dd9d1016410d 100644 --- a/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__functions_1.snap +++ b/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__functions_1.snap @@ -1,7 +1,6 @@ --- source: prqlc/prqlc/src/semantic/resolver/mod.rs expression: "resolve_derive(r#\"\n let subtract = a b -> a - b\n\n from employees\n derive {\n net_salary = subtract gross_salary tax\n }\n \"#).unwrap()" -snapshot_kind: text --- - RqOperator: name: std.sub @@ -18,28 +17,3 @@ snapshot_kind: text span: "1:141-144" span: "1:119-144" alias: net_salary - ty: - kind: - Union: - - - ~ - - kind: - Primitive: Int - span: "0:970-973" - name: ~ - - - ~ - - kind: - Primitive: Float - span: "0:977-982" - name: ~ - - - ~ - - kind: - Primitive: Timestamp - span: "0:986-995" - name: ~ - - - ~ - - kind: - Primitive: Date - span: "0:999-1003" - name: ~ - span: "0:970-1003" - name: ~ diff --git a/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__functions_nested.snap b/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__functions_nested.snap index 39667f3b7684..d54558cfe128 100644 --- a/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__functions_nested.snap +++ b/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__functions_nested.snap @@ -1,7 +1,6 @@ --- source: prqlc/prqlc/src/semantic/resolver/mod.rs expression: "resolve_derive(r#\"\n let lag_day = x -> s\"lag_day_todo({x})\"\n let ret = x dividend_return -> x / (lag_day x) - 1 + dividend_return\n\n from a\n derive (ret b c)\n \"#).unwrap()" -snapshot_kind: text --- - RqOperator: name: std.add @@ -30,21 +29,6 @@ snapshot_kind: text - String: ) span: "1:102-111" span: "1:97-112" - ty: - kind: - Union: - - - ~ - - kind: - Primitive: Int - span: "0:779-782" - name: ~ - - - ~ - - kind: - Primitive: Float - span: "0:786-791" - name: ~ - span: "0:779-791" - name: ~ - Literal: Integer: 1 span: "1:115-116" @@ -54,59 +38,9 @@ snapshot_kind: text span: ~ name: ~ span: "1:97-116" - ty: - kind: - Union: - - - ~ - - kind: - Primitive: Int - span: "0:970-973" - name: ~ - - - ~ - - kind: - Primitive: Float - span: "0:977-982" - name: ~ - - - ~ - - kind: - Primitive: Timestamp - span: "0:986-995" - name: ~ - - - ~ - - kind: - Primitive: Date - span: "0:999-1003" - name: ~ - span: "0:970-1003" - name: ~ - Ident: - this - a - c span: "1:181-182" span: "1:175-182" - ty: - kind: - Union: - - - ~ - - kind: - Primitive: Int - span: "0:893-896" - name: ~ - - - ~ - - kind: - Primitive: Float - span: "0:900-905" - name: ~ - - - ~ - - kind: - Primitive: Timestamp - span: "0:909-918" - name: ~ - - - ~ - - kind: - Primitive: Date - span: "0:922-926" - name: ~ - span: "0:893-926" - name: ~ diff --git a/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__functions_pipeline-2.snap b/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__functions_pipeline-2.snap index 4b2ba7705841..9ef8e038b41f 100644 --- a/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__functions_pipeline-2.snap +++ b/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__functions_pipeline-2.snap @@ -1,7 +1,6 @@ --- source: prqlc/prqlc/src/semantic/resolver/mod.rs expression: "resolve_derive(r#\"\n let plus_one = x -> x + 1\n let plus = x y -> x + y\n\n from a\n derive {b = (sum foo | plus_one | plus 2)}\n \"#).unwrap()" -snapshot_kind: text --- - RqOperator: name: std.add @@ -27,28 +26,10 @@ snapshot_kind: text span: "1:124-127" ty: kind: - Array: - kind: Any - span: "0:1929-1936" - name: ~ - span: "0:1928-1937" + Array: ~ + span: "0:1699-1701" name: array span: "1:120-127" - ty: - kind: - Union: - - - ~ - - kind: - Primitive: Int - span: "0:4123-4126" - name: ~ - - - ~ - - kind: - Primitive: Float - span: "0:4130-4135" - name: ~ - span: "0:4123-4135" - name: ~ - Literal: Integer: 1 span: "1:37-38" @@ -58,55 +39,5 @@ snapshot_kind: text span: ~ name: ~ span: "1:130-138" - ty: - kind: - Union: - - - ~ - - kind: - Primitive: Int - span: "0:893-896" - name: ~ - - - ~ - - kind: - Primitive: Float - span: "0:900-905" - name: ~ - - - ~ - - kind: - Primitive: Timestamp - span: "0:909-918" - name: ~ - - - ~ - - kind: - Primitive: Date - span: "0:922-926" - name: ~ - span: "0:893-926" - name: ~ span: "1:141-147" alias: b - ty: - kind: - Union: - - - ~ - - kind: - Primitive: Int - span: "0:893-896" - name: ~ - - - ~ - - kind: - Primitive: Float - span: "0:900-905" - name: ~ - - - ~ - - kind: - Primitive: Timestamp - span: "0:909-918" - name: ~ - - - ~ - - kind: - Primitive: Date - span: "0:922-926" - name: ~ - span: "0:893-926" - name: ~ diff --git a/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__functions_pipeline.snap b/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__functions_pipeline.snap index a183c2a5186a..f966bb922f13 100644 --- a/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__functions_pipeline.snap +++ b/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__functions_pipeline.snap @@ -1,7 +1,6 @@ --- source: prqlc/prqlc/src/semantic/resolver/mod.rs expression: "resolve_derive(r#\"\n from a\n derive one = (foo | sum)\n \"#).unwrap()" -snapshot_kind: text --- - RqOperator: name: std.sum @@ -13,26 +12,8 @@ snapshot_kind: text span: "1:46-49" ty: kind: - Array: - kind: Any - span: "0:1929-1936" - name: ~ - span: "0:1928-1937" + Array: ~ + span: "0:1699-1701" name: array span: "1:52-55" alias: one - ty: - kind: - Union: - - - ~ - - kind: - Primitive: Int - span: "0:4123-4126" - name: ~ - - - ~ - - kind: - Primitive: Float - span: "0:4130-4135" - name: ~ - span: "0:4123-4135" - name: ~ diff --git a/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__named_args.snap b/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__named_args.snap index b37605563346..776d958cb8f0 100644 --- a/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__named_args.snap +++ b/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__named_args.snap @@ -1,7 +1,6 @@ --- source: prqlc/prqlc/src/semantic/resolver/mod.rs expression: "resolve_derive(r#\"\n let add_one = x to:1 -> x + to\n\n from foo_table\n derive {\n added = add_one bar to:3,\n added_default = add_one bar\n }\n \"#).unwrap()" -snapshot_kind: text --- - RqOperator: name: std.add @@ -21,31 +20,6 @@ snapshot_kind: text name: ~ span: "1:117-133" alias: added - ty: - kind: - Union: - - - ~ - - kind: - Primitive: Int - span: "0:893-896" - name: ~ - - - ~ - - kind: - Primitive: Float - span: "0:900-905" - name: ~ - - - ~ - - kind: - Primitive: Timestamp - span: "0:909-918" - name: ~ - - - ~ - - kind: - Primitive: Date - span: "0:922-926" - name: ~ - span: "0:893-926" - name: ~ - RqOperator: name: std.add args: @@ -64,28 +38,3 @@ snapshot_kind: text name: ~ span: "1:167-178" alias: added_default - ty: - kind: - Union: - - - ~ - - kind: - Primitive: Int - span: "0:893-896" - name: ~ - - - ~ - - kind: - Primitive: Float - span: "0:900-905" - name: ~ - - - ~ - - kind: - Primitive: Timestamp - span: "0:909-918" - name: ~ - - - ~ - - kind: - Primitive: Date - span: "0:922-926" - name: ~ - span: "0:893-926" - name: ~ diff --git a/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__variables_1.snap b/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__variables_1.snap index e063292f4522..db936b2064d0 100644 --- a/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__variables_1.snap +++ b/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__test__variables_1.snap @@ -1,7 +1,6 @@ --- source: prqlc/prqlc/src/semantic/resolver/mod.rs expression: "resolve_derive(r#\"\n from employees\n derive {\n gross_salary = salary + payroll_tax,\n gross_cost = gross_salary + benefits_cost\n }\n \"#).unwrap()" -snapshot_kind: text --- - RqOperator: name: std.add @@ -18,31 +17,6 @@ snapshot_kind: text span: "1:89-100" span: "1:80-100" alias: gross_salary - ty: - kind: - Union: - - - ~ - - kind: - Primitive: Int - span: "0:893-896" - name: ~ - - - ~ - - kind: - Primitive: Float - span: "0:900-905" - name: ~ - - - ~ - - kind: - Primitive: Timestamp - span: "0:909-918" - name: ~ - - - ~ - - kind: - Primitive: Date - span: "0:922-926" - name: ~ - span: "0:893-926" - name: ~ - RqOperator: name: std.add args: @@ -57,28 +31,3 @@ snapshot_kind: text span: "1:148-161" span: "1:133-161" alias: gross_cost - ty: - kind: - Union: - - - ~ - - kind: - Primitive: Int - span: "0:893-896" - name: ~ - - - ~ - - kind: - Primitive: Float - span: "0:900-905" - name: ~ - - - ~ - - kind: - Primitive: Timestamp - span: "0:909-918" - name: ~ - - - ~ - - kind: - Primitive: Date - span: "0:922-926" - name: ~ - span: "0:893-926" - name: ~ diff --git a/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__transforms__tests__aggregate_positional_arg-2.snap b/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__transforms__tests__aggregate_positional_arg-2.snap index e485f3e2ba9b..0a8091c88944 100644 --- a/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__transforms__tests__aggregate_positional_arg-2.snap +++ b/prqlc/prqlc/src/semantic/resolver/snapshots/prqlc__semantic__resolver__transforms__tests__aggregate_positional_arg-2.snap @@ -1,7 +1,6 @@ --- source: prqlc/prqlc/src/semantic/resolver/transforms.rs expression: expr -snapshot_kind: text --- TransformCall: input: @@ -14,21 +13,18 @@ TransformCall: Array: kind: Tuple: - - Wildcard: - kind: Any - span: "0:2045-2052" - name: ~ - span: "0:2042-2053" - name: tuple - span: "0:2158-2165" + - Wildcard: ~ + span: "0:1740-1744" + name: ~ + span: "0:1739-1745" name: relation lineage: columns: - All: - input_id: 118 + input_id: 115 except: [] inputs: - - id: 118 + - id: 115 name: c_invoice table: - default_db @@ -47,48 +43,17 @@ TransformCall: span: "1:81-87" ty: kind: - Array: - kind: Any - span: "0:1929-1936" - name: ~ - span: "0:1928-1937" + Array: ~ + span: "0:1699-1701" name: array span: "1:73-87" - ty: - kind: - Union: - - - ~ - - kind: - Primitive: Float - span: "0:4188-4193" - name: ~ - - - ~ - - kind: - Singleton: "Null" - span: "0:4197-4201" - name: ~ - span: "0:4188-4201" - name: ~ span: "1:73-87" ty: kind: Tuple: - Single: - ~ - - kind: - Union: - - - ~ - - kind: - Primitive: Float - span: "0:4188-4193" - name: ~ - - - ~ - - kind: - Singleton: "Null" - span: "0:4197-4201" - name: ~ - span: "0:4188-4201" - name: ~ + - ~ span: ~ name: ~ partition: @@ -98,129 +63,13 @@ TransformCall: - c_invoice - issued_at span: "1:38-47" - ty: - kind: - Union: - - - ~ - - kind: - Union: - - - ~ - - kind: - Primitive: Int - span: "0:1963-1966" - name: ~ - - - ~ - - kind: - Primitive: Float - span: "0:1970-1975" - name: ~ - - - ~ - - kind: - Primitive: Bool - span: "0:1979-1983" - name: ~ - - - ~ - - kind: - Primitive: Text - span: "0:1987-1991" - name: ~ - - - ~ - - kind: - Primitive: Date - span: "0:1995-1999" - name: ~ - - - ~ - - kind: - Primitive: Time - span: "0:2003-2007" - name: ~ - - - ~ - - kind: - Primitive: Timestamp - span: "0:2011-2020" - name: ~ - - - ~ - - kind: - Singleton: "Null" - span: "0:2024-2028" - name: ~ - span: "0:1963-2028" - name: scalar - - - ~ - - kind: - Tuple: - - Wildcard: - kind: Any - span: "0:2045-2052" - name: ~ - span: "0:2042-2053" - name: tuple - span: "0:3013-3028" - name: ~ span: "1:38-47" ty: kind: Tuple: - Single: - issued_at - - kind: - Union: - - - ~ - - kind: - Union: - - - ~ - - kind: - Primitive: Int - span: "0:1963-1966" - name: ~ - - - ~ - - kind: - Primitive: Float - span: "0:1970-1975" - name: ~ - - - ~ - - kind: - Primitive: Bool - span: "0:1979-1983" - name: ~ - - - ~ - - kind: - Primitive: Text - span: "0:1987-1991" - name: ~ - - - ~ - - kind: - Primitive: Date - span: "0:1995-1999" - name: ~ - - - ~ - - kind: - Primitive: Time - span: "0:2003-2007" - name: ~ - - - ~ - - kind: - Primitive: Timestamp - span: "0:2011-2020" - name: ~ - - - ~ - - kind: - Singleton: "Null" - span: "0:2024-2028" - name: ~ - span: "0:1963-2028" - name: scalar - - - ~ - - kind: - Tuple: - - Wildcard: - kind: Any - span: "0:2045-2052" - name: ~ - span: "0:2042-2053" - name: tuple - span: "0:3013-3028" - name: ~ + - ~ span: ~ name: ~ span: "1:62-88" @@ -231,80 +80,10 @@ ty: Tuple: - Single: - issued_at - - kind: - Union: - - - ~ - - kind: - Union: - - - ~ - - kind: - Primitive: Int - span: "0:1963-1966" - name: ~ - - - ~ - - kind: - Primitive: Float - span: "0:1970-1975" - name: ~ - - - ~ - - kind: - Primitive: Bool - span: "0:1979-1983" - name: ~ - - - ~ - - kind: - Primitive: Text - span: "0:1987-1991" - name: ~ - - - ~ - - kind: - Primitive: Date - span: "0:1995-1999" - name: ~ - - - ~ - - kind: - Primitive: Time - span: "0:2003-2007" - name: ~ - - - ~ - - kind: - Primitive: Timestamp - span: "0:2011-2020" - name: ~ - - - ~ - - kind: - Singleton: "Null" - span: "0:2024-2028" - name: ~ - span: "0:1963-2028" - name: scalar - - - ~ - - kind: - Tuple: - - Wildcard: - kind: Any - span: "0:2045-2052" - name: ~ - span: "0:2042-2053" - name: tuple - span: "0:3013-3028" - name: ~ + - ~ - Single: - ~ - - kind: - Union: - - - ~ - - kind: - Primitive: Float - span: "0:4188-4193" - name: ~ - - - ~ - - kind: - Singleton: "Null" - span: "0:4197-4201" - name: ~ - span: "0:4188-4201" - name: ~ + - ~ span: ~ name: ~ span: ~ @@ -315,14 +94,14 @@ lineage: name: - c_invoice - issued_at - target_id: 120 + target_id: 117 target_name: ~ - Single: name: ~ - target_id: 136 + target_id: 133 target_name: ~ inputs: - - id: 118 + - id: 115 name: c_invoice table: - default_db diff --git a/prqlc/prqlc/src/semantic/resolver/stmt.rs b/prqlc/prqlc/src/semantic/resolver/stmt.rs index 7287c64e7c9b..ff1c571e60bb 100644 --- a/prqlc/prqlc/src/semantic/resolver/stmt.rs +++ b/prqlc/prqlc/src/semantic/resolver/stmt.rs @@ -36,8 +36,7 @@ impl super::Resolver<'_> { Ty::new(Literal::Null) }; - let ty = fold_type_opt(self, Some(value))?.unwrap(); - let mut ty = super::types::normalize_type(ty); + let mut ty = fold_type_opt(self, Some(value))?.unwrap(); ty.name = Some(ident.name.clone()); let decl = DeclKind::Ty(ty); diff --git a/prqlc/prqlc/src/semantic/resolver/transforms.rs b/prqlc/prqlc/src/semantic/resolver/transforms.rs index 7983ff98e3dc..3848dc13ef48 100644 --- a/prqlc/prqlc/src/semantic/resolver/transforms.rs +++ b/prqlc/prqlc/src/semantic/resolver/transforms.rs @@ -464,7 +464,8 @@ impl Resolver<'_> { /// Wraps non-tuple Exprs into a singleton Tuple. pub(super) fn coerce_into_tuple(&mut self, expr: Expr) -> Result { - let is_tuple_ty = expr.ty.as_ref().unwrap().kind.is_tuple() && !expr.kind.is_all(); + let is_tuple_ty = + expr.ty.as_ref().map_or(false, |t| t.kind.is_tuple()) && !expr.kind.is_all(); Ok(if is_tuple_ty { // a helpful check for a common anti-pattern if let Some(alias) = expr.alias { @@ -499,7 +500,7 @@ impl Resolver<'_> { TransformKind::Select { assigns } => assigns .ty .clone() - .map(|x| Ty::new(TyKind::Array(Box::new(x)))), + .map(|x| Ty::new(TyKind::Array(Some(Box::new(x))))), TransformKind::Derive { assigns } => { let input = transform_call.input.ty.clone().unwrap(); let input = input.into_relation().unwrap(); @@ -507,14 +508,14 @@ impl Resolver<'_> { let derived = assigns.ty.clone().unwrap(); let derived = derived.kind.into_tuple().unwrap(); - Some(Ty::new(TyKind::Array(Box::new(Ty::new(ty_tuple_kind( - [input, derived].concat(), + Some(Ty::new(TyKind::Array(Some(Box::new(Ty::new( + ty_tuple_kind([input, derived].concat()), )))))) } TransformKind::Aggregate { assigns } => { let tuple = assigns.ty.clone().unwrap(); - Some(Ty::new(TyKind::Array(Box::new(tuple)))) + Some(Ty::new(TyKind::Array(Some(Box::new(tuple))))) } TransformKind::Filter { .. } | TransformKind::Sort { .. } @@ -525,11 +526,11 @@ impl Resolver<'_> { let with_name = with.alias.clone(); let with = with.ty.clone().unwrap(); - let with = with.kind.into_array().unwrap(); + let with = with.kind.into_array().unwrap().unwrap(); let with = TyTupleField::Single(with_name, Some(*with)); - Some(Ty::new(TyKind::Array(Box::new(Ty::new(ty_tuple_kind( - [input, vec![with]].concat(), + Some(Ty::new(TyKind::Array(Some(Box::new(Ty::new( + ty_tuple_kind([input, vec![with]].concat()), )))))) } TransformKind::Group { pipeline, by } => { @@ -540,8 +541,8 @@ impl Resolver<'_> { let pipeline = pipeline.kind.into_function().unwrap().unwrap(); let pipeline = pipeline.return_ty.unwrap().into_relation().unwrap(); - Some(Ty::new(TyKind::Array(Box::new(Ty::new(ty_tuple_kind( - [by, pipeline].concat(), + Some(Ty::new(TyKind::Array(Some(Box::new(Ty::new( + ty_tuple_kind([by, pipeline].concat()), )))))) } TransformKind::Window { pipeline, .. } | TransformKind::Loop(pipeline) => { diff --git a/prqlc/prqlc/src/semantic/resolver/types.rs b/prqlc/prqlc/src/semantic/resolver/types.rs index f4fc388ba8d6..b863059b0e44 100644 --- a/prqlc/prqlc/src/semantic/resolver/types.rs +++ b/prqlc/prqlc/src/semantic/resolver/types.rs @@ -1,10 +1,7 @@ -use std::collections::HashMap; - use itertools::Itertools; use super::Resolver; use crate::codegen::{write_ty, write_ty_kind}; -use crate::ir::decl::DeclKind; use crate::ir::pl::*; use crate::pr::{PrimitiveSet, Ty, TyFunc, TyKind, TyTupleField}; use crate::Result; @@ -66,23 +63,23 @@ impl Resolver<'_> { ty_tuple_kind(ty_fields) } ExprKind::Array(items) => { - let mut variants = Vec::with_capacity(items.len()); + let mut item_tys = Vec::with_capacity(items.len()); for item in items { let item_ty = Resolver::infer_type(item)?; if let Some(item_ty) = item_ty { - variants.push((None, item_ty)); + item_tys.push(item_ty); } } - let items_ty = Ty::new(TyKind::Union(variants)); - let items_ty = normalize_type(items_ty); - TyKind::Array(Box::new(items_ty)) + // TODO verify that types of all items are the same + let items_ty = item_tys.into_iter().next().map(Box::new); + TyKind::Array(items_ty) } ExprKind::All { within, except } => { let base = Box::new(Resolver::infer_type(within)?.unwrap()); let exclude = Box::new(Resolver::infer_type(except)?.unwrap()); - normalize_type(Ty::new(TyKind::Difference { base, exclude })).kind + TyKind::Difference { base, exclude } } _ => return Ok(None), @@ -192,31 +189,6 @@ impl Resolver<'_> { Err(compose_type_error(found, expected, who)) } - /// Saves information that declaration identified by `fq_ident` must be of type `sub_ty`. - /// Param `sub_ty` must be a sub type of the current type of the declaration. - #[allow(dead_code)] - pub fn push_type_info(&mut self, fq_ident: &Ident, sub_ty: Ty) { - let decl = self.root_mod.module.get_mut(fq_ident).unwrap(); - - match &mut decl.kind { - DeclKind::Expr(expr) => { - restrict_type_opt(&mut expr.ty, Some(sub_ty)); - } - - DeclKind::Module(_) - | DeclKind::LayeredModules(_) - | DeclKind::Column(_) - | DeclKind::Infer(_) - | DeclKind::TableDecl(_) - | DeclKind::Ty(_) - | DeclKind::InstanceOf { .. } - | DeclKind::QueryDef(_) - | DeclKind::Import(_) => { - panic!("declaration {decl} is not able to have a type") - } - } - } - pub fn resolve_generic_args(&mut self, mut ty: Ty) -> Result { ty.kind = match ty.kind { // the meaningful part @@ -249,7 +221,9 @@ impl Resolver<'_> { }) .try_collect()?, ), - TyKind::Array(ty) => TyKind::Array(Box::new(self.resolve_generic_args(*ty)?)), + TyKind::Array(ty) => { + TyKind::Array(Some(Box::new(self.resolve_generic_args(*ty.unwrap())?))) + } TyKind::Function(func) => TyKind::Function( func.map(|f| -> Result<_, Error> { Ok(TyFunc { @@ -295,416 +269,6 @@ pub fn ty_tuple_kind(fields: Vec) -> TyKind { TyKind::Tuple(res) } -/// Sink type difference operators down in the type expression, -/// float unions operators up, simplify type expression. -/// -/// For more info, read web/book/src/reference/spec/type-system.md -pub(crate) fn normalize_type(ty: Ty) -> Ty { - match ty.kind { - TyKind::Union(variants) => { - let variants = sink_union_into_array_and_tuple(variants); - - let mut res: Vec<(_, Ty)> = Vec::with_capacity(variants.len()); - - for (variant_name, variant_ty) in variants { - let variant_ty = normalize_type(variant_ty); - - // (A || ()) = A - // skip never - if variant_ty.is_never() && variant_name.is_none() { - continue; - } - - // (A || A || B) = A || B - // skip duplicates - let already_included = res.iter().any(|(_, r)| is_super_type_of(r, &variant_ty)); - if already_included { - continue; - } - - res.push((variant_name, variant_ty)); - } - - if res.len() == 1 { - res.into_iter().next().unwrap().1 - } else { - Ty { - kind: TyKind::Union(res), - ..ty - } - } - } - - TyKind::Difference { base, exclude } => { - let (base, exclude) = match (*base, *exclude) { - // (A || B) - C = (A - C) || (B - C) - ( - Ty { - kind: TyKind::Union(variants), - name, - span, - }, - c, - ) => { - let kind = TyKind::Union( - variants - .into_iter() - .map(|(name, ty)| { - ( - name, - Ty::new(TyKind::Difference { - base: Box::new(ty), - exclude: Box::new(c.clone()), - }), - ) - }) - .collect(), - ); - return normalize_type(Ty { kind, name, span }); - } - // (A - B) - C = A - (B || C) - ( - Ty { - kind: - TyKind::Difference { - base: a, - exclude: b, - }, - .. - }, - c, - ) => { - let kind = TyKind::Difference { - base: a, - exclude: Box::new(union_and_flatten(*b, c)), - }; - return normalize_type(Ty { kind, ..ty }); - } - - // A - (B - C) = - // = A & not (B & not C) - // = A & (not B || C) - // = (A & not B) || (A & C) - // = (A - B) || (A & C) - ( - a, - Ty { - kind: - TyKind::Difference { - base: b, - exclude: c, - }, - .. - }, - ) => { - let first = Ty::new(TyKind::Difference { - base: Box::new(a.clone()), - exclude: b, - }); - let second = type_intersection(a, *c); - let kind = TyKind::Union(vec![(None, first), (None, second)]); - return normalize_type(Ty { kind, ..ty }); - } - - // [A] - [B] = [A - B] - ( - Ty { - kind: TyKind::Array(base), - .. - }, - Ty { - kind: TyKind::Array(exclude), - .. - }, - ) => { - let item = Ty::new(TyKind::Difference { base, exclude }); - let kind = TyKind::Array(Box::new(item)); - return normalize_type(Ty { kind, ..ty }); - } - // [A] - non-array = [A] - ( - Ty { - kind: TyKind::Array(item), - .. - }, - _, - ) => { - return normalize_type(Ty { - kind: TyKind::Array(item), - ..ty - }); - } - // non-array - [B] = non-array - ( - base, - Ty { - kind: TyKind::Array(_), - .. - }, - ) => { - return normalize_type(base); - } - - // {A, B} - {C, D} = {A - C, B - D} - ( - Ty { - kind: TyKind::Tuple(base_fields), - .. - }, - Ty { - kind: TyKind::Tuple(exclude_fields), - .. - }, - ) => { - let exclude_fields: HashMap<&String, &Option> = exclude_fields - .iter() - .flat_map(|field| match field { - TyTupleField::Single(Some(name), ty) => Some((name, ty)), - _ => None, - }) - .collect(); - - let mut res = Vec::new(); - for field in base_fields { - // TODO: this whole block should be redone - I'm not sure it fully correct. - match field { - TyTupleField::Single(Some(name), Some(ty)) => { - if let Some(right_field) = exclude_fields.get(&name) { - let right_tuple = - right_field.as_ref().map_or(false, |x| x.kind.is_tuple()); - - if right_tuple { - // recursively erase selection - let ty = Ty::new(TyKind::Difference { - base: Box::new(ty), - exclude: Box::new((*right_field).clone().unwrap()), - }); - let ty = normalize_type(ty); - res.push(TyTupleField::Single(Some(name), Some(ty))) - } else { - // erase completely - } - } else { - res.push(TyTupleField::Single(Some(name), Some(ty))) - } - } - TyTupleField::Single(Some(name), None) => { - if exclude_fields.contains_key(&name) { - // TODO: I'm not sure what should happen in this case - continue; - } else { - res.push(TyTupleField::Single(Some(name), None)) - } - } - TyTupleField::Single(None, ty) => { - res.push(TyTupleField::Single(None, ty)); - } - TyTupleField::Wildcard(_) => res.push(field), - } - } - return Ty { - kind: TyKind::Tuple(res), - ..ty - }; - } - - // noop - (a, b) => (a, b), - }; - - let base = Box::new(normalize_type(base)); - let exclude = Box::new(normalize_type(exclude)); - - // A - (A || B) = () - if let TyKind::Union(excluded) = &exclude.kind { - for (_, e) in excluded { - if base.as_ref() == e { - return Ty::never(); - } - } - } - let kind = TyKind::Difference { base, exclude }; - Ty { kind, ..ty } - } - - TyKind::Array(items_ty) => Ty { - kind: TyKind::Array(Box::new(normalize_type(*items_ty))), - ..ty - }, - - kind => Ty { kind, ..ty }, - } -} - -/// Sinks union into arrays and tuples. -/// [A] || [B] -> [A || B] -/// {a = A, B} || {c = C, D} -> {a = A, c = C, B || D} -fn sink_union_into_array_and_tuple( - variants: Vec<(Option, Ty)>, -) -> Vec<(Option, Ty)> { - let mut remaining = Vec::with_capacity(variants.len()); - - let mut array_variants = Vec::new(); - let mut tuple_variants = Vec::new(); - for (variant_name, variant_ty) in variants { - // handle array variants separately - if let TyKind::Array(item) = variant_ty.kind { - array_variants.push((None, *item)); - continue; - } - // handle tuple variants separately - if let TyKind::Tuple(fields) = variant_ty.kind { - tuple_variants.push(fields); - continue; - } - remaining.push((variant_name, variant_ty)); - } - - match array_variants.len() { - 2.. => { - let item_ty = Ty::new(TyKind::Union(array_variants)); - remaining.push((None, Ty::new(TyKind::Array(Box::new(item_ty))))); - } - 1 => { - let item_ty = array_variants.into_iter().next().unwrap().1; - remaining.push((None, Ty::new(TyKind::Array(Box::new(item_ty))))); - } - _ => {} - } - - match tuple_variants.len() { - 2.. => { - remaining.push((None, union_of_tuples(tuple_variants))); - } - 1 => { - let fields = tuple_variants.into_iter().next().unwrap(); - remaining.push((None, Ty::new(TyKind::Tuple(fields)))); - } - _ => {} - } - - remaining -} - -fn union_of_tuples(tuple_variants: Vec>) -> Ty { - let mut fields = Vec::::new(); - let mut has_wildcard = false; - - for tuple_variant in tuple_variants { - for field in tuple_variant { - match field { - TyTupleField::Single(Some(name), ty) => { - // find by name - let existing = fields.iter_mut().find_map(|f| match f { - TyTupleField::Single(n, t) if n.as_ref() == Some(&name) => Some(t), - _ => None, - }); - if let Some(existing) = existing { - // union with the existing - *existing = maybe_union(existing.take(), ty); - } else { - // push - fields.push(TyTupleField::Single(Some(name), ty)); - } - } - TyTupleField::Single(None, ty) => { - // push - fields.push(TyTupleField::Single(None, ty)); - } - TyTupleField::Wildcard(_) => has_wildcard = true, - } - } - } - if has_wildcard { - fields.push(TyTupleField::Wildcard(None)); - } - Ty::new(TyKind::Tuple(fields)) -} - -fn restrict_type_opt(ty: &mut Option, sub_ty: Option) { - let Some(sub_ty) = sub_ty else { - return; - }; - if let Some(ty) = ty { - restrict_type(ty, sub_ty) - } else { - *ty = Some(sub_ty); - } -} - -fn restrict_type(ty: &mut Ty, sub_ty: Ty) { - match (&mut ty.kind, sub_ty.kind) { - (TyKind::Any, sub) => ty.kind = sub, - - (TyKind::Union(variants), sub_kind) => { - let sub_ty = Ty { - kind: sub_kind, - ..sub_ty - }; - let drained = variants - .drain(..) - .filter(|(_, variant)| is_super_type_of(variant, &sub_ty)) - .map(|(name, mut ty)| { - restrict_type(&mut ty, sub_ty.clone()); - (name, ty) - }) - .collect_vec(); - variants.extend(drained); - } - - (kind, TyKind::Union(sub_variants)) => { - todo!("restrict {kind:?} to union of {sub_variants:?}") - } - - (TyKind::Primitive(_), _) => {} - - (TyKind::Singleton(_), _) => {} - - (TyKind::Tuple(tuple), TyKind::Tuple(sub_tuple)) => { - for sub_field in sub_tuple { - match sub_field { - TyTupleField::Single(sub_name, sub_ty) => { - if let Some(sub_name) = sub_name { - let existing = tuple - .iter_mut() - .filter_map(|x| x.as_single_mut()) - .find(|f| f.0.as_ref() == Some(&sub_name)); - - if let Some((_, existing)) = existing { - restrict_type_opt(existing, sub_ty) - } else { - tuple.push(TyTupleField::Single(Some(sub_name), sub_ty)); - } - } else { - // TODO: insert unnamed fields? - } - } - TyTupleField::Wildcard(_) => todo!("remove TupleField::Wildcard"), - } - } - } - - (TyKind::Array(ty), TyKind::Array(sub_ty)) => restrict_type(ty, *sub_ty), - - (TyKind::Function(ty), TyKind::Function(sub_ty)) => { - if sub_ty.is_none() { - return; - } - if ty.is_none() { - *ty = sub_ty; - return; - } - if let (Some(func), Some(sub_func)) = (ty, sub_ty) { - todo!("restrict function {func:?} to function {sub_func:?}") - } - } - - _ => { - panic!("trying to restrict a type with a non sub type") - } - } -} - fn compose_type_error(found_ty: &mut Ty, expected: &Ty, who: &F) -> Error where F: Fn() -> Option, @@ -759,7 +323,7 @@ where /// Analogous to [crate::ir::pl::Lineage::rename()] pub fn rename_relation(ty_kind: &mut TyKind, alias: String) { - if let TyKind::Array(items_ty) = ty_kind { + if let TyKind::Array(Some(items_ty)) = ty_kind { rename_tuples(&mut items_ty.kind, alias); } } @@ -806,26 +370,25 @@ pub fn is_super_type_of(superset: &Ty, subset: &Ty) -> bool { is_super_type_of_kind(&superset.kind, &subset.kind) } +pub fn is_super_type_of_opt(superset: Option<&Ty>, subset: Option<&Ty>) -> bool { + let Some(subset) = subset else { + return true; + }; + let Some(superset) = superset else { + return true; + }; + is_super_type_of_kind(&superset.kind, &subset.kind) +} + pub fn is_sub_type_of_array(ty: &Ty) -> bool { - let array = TyKind::Array(Box::new(Ty::new(TyKind::Any))); + let array = TyKind::Array(None); is_super_type_of_kind(&array, &ty.kind) } fn is_super_type_of_kind(superset: &TyKind, subset: &TyKind) -> bool { match (superset, subset) { - (TyKind::Any, _) => true, - (_, TyKind::Any) => false, - (TyKind::Primitive(l0), TyKind::Primitive(r0)) => l0 == r0, - (one, TyKind::Union(many)) => many - .iter() - .all(|(_, each)| is_super_type_of_kind(one, &each.kind)), - - (TyKind::Union(many), one) => many - .iter() - .any(|(_, any)| is_super_type_of_kind(&any.kind, one)), - (TyKind::Function(None), TyKind::Function(_)) => true, (TyKind::Function(Some(_)), TyKind::Function(None)) => true, (TyKind::Function(Some(sup)), TyKind::Function(Some(sub))) => { @@ -844,7 +407,9 @@ fn is_super_type_of_kind(superset: &TyKind, subset: &TyKind) -> bool { true } - (TyKind::Array(sup), TyKind::Array(sub)) => is_super_type_of(sup, sub), + (TyKind::Array(sup), TyKind::Array(sub)) => { + is_super_type_of_opt(sup.as_deref(), sub.as_deref()) + } (TyKind::Tuple(sup_tuple), TyKind::Tuple(sub_tuple)) => { let sup_has_wildcard = sup_tuple @@ -907,19 +472,6 @@ fn maybe_type_intersection(a: Option, b: Option) -> Option { pub fn type_intersection(a: Ty, b: Ty) -> Ty { match (a.kind, b.kind) { - (TyKind::Any, b_kind) => Ty { kind: b_kind, ..b }, - (a_kind, TyKind::Any) => Ty { kind: a_kind, ..a }, - - // union - (TyKind::Union(a_variants), b_kind) => { - let b = Ty { kind: b_kind, ..b }; - type_intersection_with_union(a_variants, b) - } - (a_kind, TyKind::Union(b_variants)) => { - let a = Ty { kind: a_kind, ..a }; - type_intersection_with_union(b_variants, a) - } - // difference (TyKind::Difference { base, exclude }, b_kind) => { let b = Ty { kind: b_kind, ..b }; @@ -940,25 +492,13 @@ pub fn type_intersection(a: Ty, b: Ty) -> Ty { } // array - (TyKind::Array(a), TyKind::Array(b)) => { - Ty::new(TyKind::Array(Box::new(type_intersection(*a, *b)))) + (TyKind::Array(Some(a)), TyKind::Array(Some(b))) => { + Ty::new(TyKind::Array(Some(Box::new(type_intersection(*a, *b))))) } - _ => Ty::never(), + _ => todo!(), } } -fn type_intersection_with_union(variants: Vec<(Option, Ty)>, b: Ty) -> Ty { - let variants = variants - .into_iter() - .map(|(name, variant)| { - let inter = type_intersection(variant, b.clone()); - - (name, inter) - }) - .collect_vec(); - - Ty::new(TyKind::Union(variants)) -} fn type_intersection_of_tuples(a: Vec, b: Vec) -> Ty { let a_has_other = a.iter().any(|f| f.is_wildcard()); @@ -974,14 +514,14 @@ fn type_intersection_of_tuples(a: Vec, b: Vec) -> Ty (None, None) => break, (None, Some(b_field)) => { if !a_has_other { - return Ty::never(); + todo!(); } has_other = true; fields.push(TyTupleField::Single(b_field.0, b_field.1)); } (Some(a_field), None) => { if !b_has_other { - return Ty::never(); + todo!(); } has_other = true; fields.push(TyTupleField::Single(a_field.0, a_field.1)); @@ -1004,29 +544,3 @@ fn type_intersection_of_tuples(a: Vec, b: Vec) -> Ty Ty::new(TyKind::Tuple(fields)) } - -/// Converts: -/// - A, B into A | B and -/// - A, B | C into A | B | C and -/// - A | B, C into A | B | C. -fn union_and_flatten(a: Ty, b: Ty) -> Ty { - let mut variants = Vec::with_capacity(2); - if let TyKind::Union(v) = a.kind { - variants.extend(v) - } else { - variants.push((None, a)); - } - if let TyKind::Union(v) = b.kind { - variants.extend(v) - } else { - variants.push((None, b)); - } - Ty::new(TyKind::Union(variants)) -} - -fn maybe_union(a: Option, b: Option) -> Option { - match (a, b) { - (Some(a), Some(b)) => Some(Ty::new(TyKind::Union(vec![(None, a), (None, b)]))), - (None, x) | (x, None) => x, - } -} diff --git a/prqlc/prqlc/src/semantic/std.prql b/prqlc/prqlc/src/semantic/std.prql index 2c60440de567..b1fed9947211 100644 --- a/prqlc/prqlc/src/semantic/std.prql +++ b/prqlc/prqlc/src/semantic/std.prql @@ -15,12 +15,12 @@ # Operators -let mul = left right -> internal std.mul -let div_i = left right -> internal std.div_i -let div_f = left right -> internal std.div_f -let mod = left right -> internal std.mod -let add = left right -> internal std.add -let sub = left right -> internal std.sub +let mul = left right -> internal std.mul +let div_i = left right -> internal std.div_i +let div_f = left right -> internal std.div_f +let mod = left right -> internal std.mod +let add = left right -> internal std.add +let sub = left right -> internal std.sub let eq = left right -> internal std.eq let ne = left right -> internal std.ne let gt = left right -> internal std.gt @@ -32,7 +32,7 @@ let or = left right -> internal std.or let coalesce = left right -> internal std.coalesce let regex_search = text pattern -> internal std.regex_search -let neg = expr -> internal std.neg +let neg = expr -> internal std.neg let not = expr -> internal std.not # Types @@ -46,21 +46,15 @@ type date = date type time = time type timestamp = timestamp type `func` = func -type anytype = anytype ## Generic array -# TODO: an array of anything, not just nulls -type array = [anytype] +type array = [] -## Scalar -type scalar = int || float || bool || text || date || time || timestamp || null -type tuple = {..anytype} +## Generic relation +type relation = [{..}] ## Range -type range = {start = scalar, end = scalar} - -## Relation (an array of tuples) -type relation = [tuple] +type range = {start = *, end = *} ## Transform type transform = func relation -> relation @@ -73,7 +67,7 @@ let from = func -> source let select = func - columns + columns tbl -> internal select @@ -83,22 +77,22 @@ let filter = func -> internal filter let derive = func - columns + columns tbl -> internal derive let aggregate = func - columns + columns tbl -> internal aggregate let sort = func - by + by tbl -> internal sort let take = func - expr + expr tbl -> internal take @@ -110,7 +104,7 @@ let join = func -> internal join let group = func - by + by pipeline tbl -> internal group @@ -144,15 +138,15 @@ let loop = func ## Aggregate functions # These return either a scalar when used within `aggregate`, or a column when used anywhere else. -let min = column -> internal std.min +let min = column -> internal std.min -let max = column -> internal std.max +let max = column -> internal std.max -let sum = column -> internal std.sum +let sum = column -> internal std.sum -let average = column -> internal std.average +let average = column -> internal std.average -let stddev = column -> internal std.stddev +let stddev = column -> internal std.stddev let all = column -> internal std.all @@ -179,29 +173,29 @@ let row_number = column -> internal row_number # Mathematical functions module math { - let abs = column -> internal std.math.abs + let abs = column -> internal std.math.abs let floor = column -> internal std.math.floor let ceil = column -> internal std.math.ceil let pi = -> internal std.math.pi - let exp = column -> internal std.math.exp - let ln = column -> internal std.math.ln - let log10 = column -> internal std.math.log10 - let log = base column -> internal std.math.log - let sqrt = column -> internal std.math.sqrt - let degrees = column -> internal std.math.degrees - let radians = column -> internal std.math.radians - let cos = column -> internal std.math.cos - let acos = column -> internal std.math.acos - let sin = column -> internal std.math.sin - let asin = column -> internal std.math.asin - let tan = column -> internal std.math.tan - let atan = column -> internal std.math.atan - let pow = exponent column -> internal std.math.pow - let round = n_digits column -> internal std.math.round + let exp = column -> internal std.math.exp + let ln = column -> internal std.math.ln + let log10 = column -> internal std.math.log10 + let log = func base column -> internal std.math.log + let sqrt = column -> internal std.math.sqrt + let degrees = column -> internal std.math.degrees + let radians = column -> internal std.math.radians + let cos = column -> internal std.math.cos + let acos = column -> internal std.math.acos + let sin = column -> internal std.math.sin + let asin = column -> internal std.math.asin + let tan = column -> internal std.math.tan + let atan = column -> internal std.math.atan + let pow = exponent column -> internal std.math.pow + let round = n_digits column -> internal std.math.round } ## Misc functions -let as = `noresolve.type` column -> internal std.as +let as = `noresolve.type` column -> internal std.as let in = pattern value -> internal in ## Tuple functions diff --git a/prqlc/prqlc/tests/integration/bad_error_messages.rs b/prqlc/prqlc/tests/integration/bad_error_messages.rs index 7c90bb141a9b..24a308303404 100644 --- a/prqlc/prqlc/tests/integration/bad_error_messages.rs +++ b/prqlc/prqlc/tests/integration/bad_error_messages.rs @@ -24,7 +24,7 @@ fn test_bad_error_messages() { assert_snapshot!(compile(r###" from film group - "###).unwrap_err(), @r" + "###).unwrap_err(), @r#" Error: ╭─[:3:5] │ @@ -34,9 +34,9 @@ fn test_bad_error_messages() { │ │ Help: Have you forgotten an argument to function std.group? │ - │ Note: Type `relation` expands to `[tuple]` + │ Note: Type `relation` expands to `[{..}]` ───╯ - "); + "#); // This should suggest parentheses (this might not be an easy one to solve) assert_snapshot!(compile(r#" diff --git a/prqlc/prqlc/tests/integration/error_messages.rs b/prqlc/prqlc/tests/integration/error_messages.rs index 970c7733c5db..0de9a941184d 100644 --- a/prqlc/prqlc/tests/integration/error_messages.rs +++ b/prqlc/prqlc/tests/integration/error_messages.rs @@ -158,17 +158,17 @@ fn test_bad_function_type() { group foo (take) "###, ) - .unwrap_err(), @r" + .unwrap_err(), @r#" Error: ╭─[:3:16] │ 3 │ group foo (take) │ ──┬─ - │ ╰─── function std.group, param `pipeline` expected type `transform`, but found type `func anytype relation -> relation` + │ ╰─── function std.group, param `pipeline` expected type `transform`, but found type `func ? relation -> relation` │ │ Help: Type `transform` expands to `func relation -> relation` ───╯ - "); + "#); } #[test] @@ -191,25 +191,6 @@ fn test_basic_type_checking() { "###); } -// See also test_bad_error_messages::misplaced_type_error -// Note that the ``` Help: Type `bool` expands to `bool` ``` is not that useful -#[test] -fn test_type_error_placement() { - assert_snapshot!(compile(r###" - let foo = x -> (x | as integer) - from t - select (true && (foo y)) - "###).unwrap_err(), @r" - Error: - ╭─[:4:22] - │ - 4 │ select (true && (foo y)) - │ ──┬── - │ ╰──── function std.and, param `right` expected type `bool`, but found type `scalar` - ───╯ - "); -} - #[test] fn test_ambiguous() { assert_snapshot!(compile(r#" diff --git a/prqlc/prqlc/tests/integration/resolving.rs b/prqlc/prqlc/tests/integration/resolving.rs index 91c2d3d44de3..8966c5743f94 100644 --- a/prqlc/prqlc/tests/integration/resolving.rs +++ b/prqlc/prqlc/tests/integration/resolving.rs @@ -46,46 +46,6 @@ fn resolve_function_01() { ") } -#[test] -fn resolve_types_01() { - assert_snapshot!(resolve(r#" - type A = int || int - "#).unwrap(), @"type A = int") -} - -#[test] -fn resolve_types_02() { - assert_snapshot!(resolve(r#" - type A = int || {} - "#).unwrap(), @"type A = int || {}") -} - -#[test] -fn resolve_types_03() { - assert_snapshot!(resolve(r#" - type A = {a = int, bool} || {b = text, float} - "#).unwrap(), @"type A = {a = int, bool, b = text, float}") -} - -#[test] -fn resolve_types_04() { - assert_snapshot!(resolve( - r#" - type Status = enum { - Paid = {}, - Unpaid = float, - Canceled = {reason = text, cancelled_at = timestamp}, - } - "#, - ) - .unwrap(), @r" - type Status = ( - Unpaid = float || - {reason = text, cancelled_at = timestamp} || - ) - "); -} - #[test] fn resolve_types_05() { // TODO: this is very strange, it should only be allowed in std diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__aggregation.snap b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__aggregation.snap index 10a3e821f8fd..7cae7d25990a 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__aggregation.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__aggregation.snap @@ -2,16 +2,15 @@ source: prqlc/prqlc/tests/integration/queries.rs expression: "# mysql:skip\n# clickhouse:skip\n# glaredb:skip (the string_agg function is not supported)\nfrom tracks\nfilter genre_id == 100\nderive empty_name = name == ''\naggregate {sum track_id, concat_array name, all empty_name, any empty_name}\n" input_file: prqlc/prqlc/tests/integration/queries/aggregation.prql -snapshot_kind: text --- frames: - - 1:101-123 - columns: - !All - input_id: 124 + input_id: 121 except: [] inputs: - - id: 124 + - id: 121 name: tracks table: - default_db @@ -19,15 +18,15 @@ frames: - - 1:124-154 - columns: - !All - input_id: 124 + input_id: 121 except: [] - !Single name: - empty_name - target_id: 131 + target_id: 128 target_name: null inputs: - - id: 124 + - id: 121 name: tracks table: - default_db @@ -36,42 +35,42 @@ frames: - columns: - !Single name: null - target_id: 137 + target_id: 134 target_name: null - !Single name: null - target_id: 140 + target_id: 137 target_name: null - !Single name: null - target_id: 143 + target_id: 140 target_name: null - !Single name: null - target_id: 146 + target_id: 143 target_name: null inputs: - - id: 124 + - id: 121 name: tracks table: - default_db - tracks nodes: -- id: 124 +- id: 121 kind: Ident span: 1:89-100 ident: !Ident - default_db - tracks - parent: 130 -- id: 126 + parent: 127 +- id: 123 kind: RqOperator span: 1:108-123 targets: - - 128 - - 129 - parent: 130 -- id: 128 + - 125 + - 126 + parent: 127 +- id: 125 kind: Ident span: 1:108-116 ident: !Ident @@ -79,26 +78,26 @@ nodes: - tracks - genre_id targets: - - 124 -- id: 129 + - 121 +- id: 126 kind: Literal span: 1:120-123 -- id: 130 +- id: 127 kind: 'TransformCall: Filter' span: 1:101-123 children: - - 124 - - 126 - parent: 136 -- id: 131 + - 121 + - 123 + parent: 133 +- id: 128 kind: RqOperator span: 1:144-154 alias: empty_name targets: - - 133 - - 134 - parent: 135 -- id: 133 + - 130 + - 131 + parent: 132 +- id: 130 kind: Ident span: 1:144-148 ident: !Ident @@ -106,30 +105,30 @@ nodes: - tracks - name targets: - - 124 -- id: 134 + - 121 +- id: 131 kind: Literal span: 1:152-154 -- id: 135 +- id: 132 kind: Tuple span: 1:144-154 children: - - 131 - parent: 136 -- id: 136 + - 128 + parent: 133 +- id: 133 kind: 'TransformCall: Derive' span: 1:124-154 children: - - 130 - - 135 - parent: 150 -- id: 137 + - 127 + - 132 + parent: 147 +- id: 134 kind: RqOperator span: 1:166-178 targets: - - 139 - parent: 149 -- id: 139 + - 136 + parent: 146 +- id: 136 kind: Ident span: 1:170-178 ident: !Ident @@ -137,14 +136,14 @@ nodes: - tracks - track_id targets: - - 124 -- id: 140 + - 121 +- id: 137 kind: RqOperator span: 1:180-197 targets: - - 142 - parent: 149 -- id: 142 + - 139 + parent: 146 +- id: 139 kind: Ident span: 1:193-197 ident: !Ident @@ -152,50 +151,50 @@ nodes: - tracks - name targets: - - 124 -- id: 143 + - 121 +- id: 140 kind: RqOperator span: 1:199-213 targets: - - 145 - parent: 149 -- id: 145 + - 142 + parent: 146 +- id: 142 kind: Ident span: 1:203-213 ident: !Ident - this - empty_name targets: - - 131 -- id: 146 + - 128 +- id: 143 kind: RqOperator span: 1:215-229 targets: - - 148 - parent: 149 -- id: 148 + - 145 + parent: 146 +- id: 145 kind: Ident span: 1:219-229 ident: !Ident - this - empty_name targets: - - 131 -- id: 149 + - 128 +- id: 146 kind: Tuple span: 1:165-230 children: + - 134 - 137 - 140 - 143 - - 146 - parent: 150 -- id: 150 + parent: 147 +- id: 147 kind: 'TransformCall: Aggregate' span: 1:155-230 children: - - 136 - - 149 + - 133 + - 146 ast: name: Project stmts: diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__arithmetic.snap b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__arithmetic.snap index 9de212bd542d..0536c3a7d46d 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__arithmetic.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__arithmetic.snap @@ -2,882 +2,881 @@ source: prqlc/prqlc/tests/integration/queries.rs expression: "# mssql:test\nfrom [\n { id = 1, x_int = 13, x_float = 13.0, k_int = 5, k_float = 5.0 },\n { id = 2, x_int = -13, x_float = -13.0, k_int = 5, k_float = 5.0 },\n { id = 3, x_int = 13, x_float = 13.0, k_int = -5, k_float = -5.0 },\n { id = 4, x_int = -13, x_float = -13.0, k_int = -5, k_float = -5.0 },\n]\nselect {\n id,\n\n x_int / k_int,\n x_int / k_float,\n x_float / k_int,\n x_float / k_float,\n\n q_ii = x_int // k_int,\n q_if = x_int // k_float,\n q_fi = x_float // k_int,\n q_ff = x_float // k_float,\n\n r_ii = x_int % k_int,\n r_if = x_int % k_float,\n r_fi = x_float % k_int,\n r_ff = x_float % k_float,\n\n (q_ii * k_int + r_ii | math.round 0),\n (q_if * k_float + r_if | math.round 0),\n (q_fi * k_int + r_fi | math.round 0),\n (q_ff * k_float + r_ff | math.round 0),\n}\nsort id\n" input_file: prqlc/prqlc/tests/integration/queries/arithmetic.prql -snapshot_kind: text --- frames: - - 1:318-824 - columns: - !Single name: - - _literal_121 + - _literal_118 - id - target_id: 163 + target_id: 160 target_name: null - !Single name: null - target_id: 164 + target_id: 161 target_name: null - !Single name: null - target_id: 168 + target_id: 165 target_name: null - !Single name: null - target_id: 172 + target_id: 169 target_name: null - !Single name: null - target_id: 176 + target_id: 173 target_name: null - !Single name: - q_ii - target_id: 180 + target_id: 177 target_name: null - !Single name: - q_if - target_id: 184 + target_id: 181 target_name: null - !Single name: - q_fi - target_id: 188 + target_id: 185 target_name: null - !Single name: - q_ff - target_id: 192 + target_id: 189 target_name: null - !Single name: - r_ii - target_id: 196 + target_id: 193 target_name: null - !Single name: - r_if - target_id: 200 + target_id: 197 target_name: null - !Single name: - r_fi - target_id: 204 + target_id: 201 target_name: null - !Single name: - r_ff - target_id: 208 + target_id: 205 target_name: null - !Single name: null - target_id: 212 + target_id: 209 target_name: null - !Single name: null - target_id: 223 + target_id: 220 target_name: null - !Single name: null - target_id: 234 + target_id: 231 target_name: null - !Single name: null - target_id: 245 + target_id: 242 target_name: null inputs: - - id: 121 - name: _literal_121 + - id: 118 + name: _literal_118 table: - default_db - - _literal_121 + - _literal_118 - - 1:825-832 - columns: - !Single name: - - _literal_121 + - _literal_118 - id - target_id: 163 + target_id: 160 target_name: null - !Single name: null - target_id: 164 + target_id: 161 target_name: null - !Single name: null - target_id: 168 + target_id: 165 target_name: null - !Single name: null - target_id: 172 + target_id: 169 target_name: null - !Single name: null - target_id: 176 + target_id: 173 target_name: null - !Single name: - q_ii - target_id: 180 + target_id: 177 target_name: null - !Single name: - q_if - target_id: 184 + target_id: 181 target_name: null - !Single name: - q_fi - target_id: 188 + target_id: 185 target_name: null - !Single name: - q_ff - target_id: 192 + target_id: 189 target_name: null - !Single name: - r_ii - target_id: 196 + target_id: 193 target_name: null - !Single name: - r_if - target_id: 200 + target_id: 197 target_name: null - !Single name: - r_fi - target_id: 204 + target_id: 201 target_name: null - !Single name: - r_ff - target_id: 208 + target_id: 205 target_name: null - !Single name: null - target_id: 212 + target_id: 209 target_name: null - !Single name: null - target_id: 223 + target_id: 220 target_name: null - !Single name: null - target_id: 234 + target_id: 231 target_name: null - !Single name: null - target_id: 245 + target_id: 242 target_name: null inputs: - - id: 121 - name: _literal_121 + - id: 118 + name: _literal_118 table: - default_db - - _literal_121 + - _literal_118 nodes: -- id: 121 +- id: 118 kind: Array span: 1:13-317 children: - - 122 - - 128 - - 138 - - 148 - parent: 257 -- id: 122 + - 119 + - 125 + - 135 + - 145 + parent: 254 +- id: 119 kind: Tuple span: 1:24-92 children: + - 120 + - 121 + - 122 - 123 - 124 - - 125 - - 126 - - 127 - parent: 121 -- id: 123 + parent: 118 +- id: 120 kind: Literal span: 1:31-32 alias: id - parent: 122 -- id: 124 + parent: 119 +- id: 121 kind: Literal span: 1:43-45 alias: x_int - parent: 122 -- id: 125 + parent: 119 +- id: 122 kind: Literal span: 1:58-62 alias: x_float - parent: 122 -- id: 126 + parent: 119 +- id: 123 kind: Literal span: 1:73-74 alias: k_int - parent: 122 -- id: 127 + parent: 119 +- id: 124 kind: Literal span: 1:87-90 alias: k_float - parent: 122 -- id: 128 + parent: 119 +- id: 125 kind: Tuple span: 1:98-166 children: - - 129 + - 126 + - 127 - 130 - 133 - - 136 - - 137 - parent: 121 -- id: 129 + - 134 + parent: 118 +- id: 126 kind: Literal span: 1:105-106 alias: id - parent: 128 -- id: 130 + parent: 125 +- id: 127 kind: Literal span: 1:116-119 alias: x_int - parent: 128 -- id: 133 + parent: 125 +- id: 130 kind: Literal span: 1:131-136 alias: x_float - parent: 128 -- id: 136 + parent: 125 +- id: 133 kind: Literal span: 1:147-148 alias: k_int - parent: 128 -- id: 137 + parent: 125 +- id: 134 kind: Literal span: 1:161-164 alias: k_float - parent: 128 -- id: 138 + parent: 125 +- id: 135 kind: Tuple span: 1:172-240 children: + - 136 + - 137 + - 138 - 139 - - 140 - - 141 - 142 - - 145 - parent: 121 -- id: 139 + parent: 118 +- id: 136 kind: Literal span: 1:179-180 alias: id - parent: 138 -- id: 140 + parent: 135 +- id: 137 kind: Literal span: 1:191-193 alias: x_int - parent: 138 -- id: 141 + parent: 135 +- id: 138 kind: Literal span: 1:206-210 alias: x_float - parent: 138 -- id: 142 + parent: 135 +- id: 139 kind: Literal span: 1:220-222 alias: k_int - parent: 138 -- id: 145 + parent: 135 +- id: 142 kind: Literal span: 1:234-238 alias: k_float - parent: 138 -- id: 148 + parent: 135 +- id: 145 kind: Tuple span: 1:246-314 children: - - 149 + - 146 + - 147 - 150 - 153 - 156 - - 159 - parent: 121 -- id: 149 + parent: 118 +- id: 146 kind: Literal span: 1:253-254 alias: id - parent: 148 -- id: 150 + parent: 145 +- id: 147 kind: Literal span: 1:264-267 alias: x_int - parent: 148 -- id: 153 + parent: 145 +- id: 150 kind: Literal span: 1:279-284 alias: x_float - parent: 148 -- id: 156 + parent: 145 +- id: 153 kind: Literal span: 1:294-296 alias: k_int - parent: 148 -- id: 159 + parent: 145 +- id: 156 kind: Literal span: 1:308-312 alias: k_float - parent: 148 -- id: 163 + parent: 145 +- id: 160 kind: Ident span: 1:331-333 ident: !Ident - this - - _literal_121 + - _literal_118 - id targets: - - 121 - parent: 256 -- id: 164 + - 118 + parent: 253 +- id: 161 kind: RqOperator span: 1:340-353 targets: - - 166 - - 167 - parent: 256 -- id: 166 + - 163 + - 164 + parent: 253 +- id: 163 kind: Ident span: 1:340-345 ident: !Ident - this - - _literal_121 + - _literal_118 - x_int targets: - - 121 -- id: 167 + - 118 +- id: 164 kind: Ident span: 1:348-353 ident: !Ident - this - - _literal_121 + - _literal_118 - k_int targets: - - 121 -- id: 168 + - 118 +- id: 165 kind: RqOperator span: 1:359-374 targets: - - 170 - - 171 - parent: 256 -- id: 170 + - 167 + - 168 + parent: 253 +- id: 167 kind: Ident span: 1:359-364 ident: !Ident - this - - _literal_121 + - _literal_118 - x_int targets: - - 121 -- id: 171 + - 118 +- id: 168 kind: Ident span: 1:367-374 ident: !Ident - this - - _literal_121 + - _literal_118 - k_float targets: - - 121 -- id: 172 + - 118 +- id: 169 kind: RqOperator span: 1:380-395 targets: - - 174 - - 175 - parent: 256 -- id: 174 + - 171 + - 172 + parent: 253 +- id: 171 kind: Ident span: 1:380-387 ident: !Ident - this - - _literal_121 + - _literal_118 - x_float targets: - - 121 -- id: 175 + - 118 +- id: 172 kind: Ident span: 1:390-395 ident: !Ident - this - - _literal_121 + - _literal_118 - k_int targets: - - 121 -- id: 176 + - 118 +- id: 173 kind: RqOperator span: 1:401-418 targets: - - 178 - - 179 - parent: 256 -- id: 178 + - 175 + - 176 + parent: 253 +- id: 175 kind: Ident span: 1:401-408 ident: !Ident - this - - _literal_121 + - _literal_118 - x_float targets: - - 121 -- id: 179 + - 118 +- id: 176 kind: Ident span: 1:411-418 ident: !Ident - this - - _literal_121 + - _literal_118 - k_float targets: - - 121 -- id: 180 + - 118 +- id: 177 kind: RqOperator span: 1:432-446 alias: q_ii targets: - - 182 - - 183 - parent: 256 -- id: 182 + - 179 + - 180 + parent: 253 +- id: 179 kind: Ident span: 1:432-437 ident: !Ident - this - - _literal_121 + - _literal_118 - x_int targets: - - 121 -- id: 183 + - 118 +- id: 180 kind: Ident span: 1:441-446 ident: !Ident - this - - _literal_121 + - _literal_118 - k_int targets: - - 121 -- id: 184 + - 118 +- id: 181 kind: RqOperator span: 1:459-475 alias: q_if targets: - - 186 - - 187 - parent: 256 -- id: 186 + - 183 + - 184 + parent: 253 +- id: 183 kind: Ident span: 1:459-464 ident: !Ident - this - - _literal_121 + - _literal_118 - x_int targets: - - 121 -- id: 187 + - 118 +- id: 184 kind: Ident span: 1:468-475 ident: !Ident - this - - _literal_121 + - _literal_118 - k_float targets: - - 121 -- id: 188 + - 118 +- id: 185 kind: RqOperator span: 1:488-504 alias: q_fi targets: - - 190 - - 191 - parent: 256 -- id: 190 + - 187 + - 188 + parent: 253 +- id: 187 kind: Ident span: 1:488-495 ident: !Ident - this - - _literal_121 + - _literal_118 - x_float targets: - - 121 -- id: 191 + - 118 +- id: 188 kind: Ident span: 1:499-504 ident: !Ident - this - - _literal_121 + - _literal_118 - k_int targets: - - 121 -- id: 192 + - 118 +- id: 189 kind: RqOperator span: 1:517-535 alias: q_ff targets: - - 194 - - 195 - parent: 256 -- id: 194 + - 191 + - 192 + parent: 253 +- id: 191 kind: Ident span: 1:517-524 ident: !Ident - this - - _literal_121 + - _literal_118 - x_float targets: - - 121 -- id: 195 + - 118 +- id: 192 kind: Ident span: 1:528-535 ident: !Ident - this - - _literal_121 + - _literal_118 - k_float targets: - - 121 -- id: 196 + - 118 +- id: 193 kind: RqOperator span: 1:549-562 alias: r_ii targets: - - 198 - - 199 - parent: 256 -- id: 198 + - 195 + - 196 + parent: 253 +- id: 195 kind: Ident span: 1:549-554 ident: !Ident - this - - _literal_121 + - _literal_118 - x_int targets: - - 121 -- id: 199 + - 118 +- id: 196 kind: Ident span: 1:557-562 ident: !Ident - this - - _literal_121 + - _literal_118 - k_int targets: - - 121 -- id: 200 + - 118 +- id: 197 kind: RqOperator span: 1:575-590 alias: r_if targets: - - 202 - - 203 - parent: 256 -- id: 202 + - 199 + - 200 + parent: 253 +- id: 199 kind: Ident span: 1:575-580 ident: !Ident - this - - _literal_121 + - _literal_118 - x_int targets: - - 121 -- id: 203 + - 118 +- id: 200 kind: Ident span: 1:583-590 ident: !Ident - this - - _literal_121 + - _literal_118 - k_float targets: - - 121 -- id: 204 + - 118 +- id: 201 kind: RqOperator span: 1:603-618 alias: r_fi targets: - - 206 - - 207 - parent: 256 -- id: 206 + - 203 + - 204 + parent: 253 +- id: 203 kind: Ident span: 1:603-610 ident: !Ident - this - - _literal_121 + - _literal_118 - x_float targets: - - 121 -- id: 207 + - 118 +- id: 204 kind: Ident span: 1:613-618 ident: !Ident - this - - _literal_121 + - _literal_118 - k_int targets: - - 121 -- id: 208 + - 118 +- id: 205 kind: RqOperator span: 1:631-648 alias: r_ff targets: - - 210 - - 211 - parent: 256 -- id: 210 + - 207 + - 208 + parent: 253 +- id: 207 kind: Ident span: 1:631-638 ident: !Ident - this - - _literal_121 + - _literal_118 - x_float targets: - - 121 -- id: 211 + - 118 +- id: 208 kind: Ident span: 1:641-648 ident: !Ident - this - - _literal_121 + - _literal_118 - k_float targets: - - 121 -- id: 212 + - 118 +- id: 209 kind: RqOperator span: 1:678-690 targets: - - 215 - - 216 - parent: 256 -- id: 215 + - 212 + - 213 + parent: 253 +- id: 212 kind: Literal span: 1:689-690 -- id: 216 +- id: 213 kind: RqOperator span: 1:656-675 targets: - - 218 - - 222 -- id: 218 + - 215 + - 219 +- id: 215 kind: RqOperator span: 1:656-668 targets: - - 220 - - 221 -- id: 220 + - 217 + - 218 +- id: 217 kind: Ident span: 1:656-660 ident: !Ident - this - q_ii targets: - - 180 -- id: 221 + - 177 +- id: 218 kind: Ident span: 1:663-668 ident: !Ident - this - - _literal_121 + - _literal_118 - k_int targets: - - 121 -- id: 222 + - 118 +- id: 219 kind: Ident span: 1:671-675 ident: !Ident - this - r_ii targets: - - 196 -- id: 223 + - 193 +- id: 220 kind: RqOperator span: 1:722-734 targets: - - 226 - - 227 - parent: 256 -- id: 226 + - 223 + - 224 + parent: 253 +- id: 223 kind: Literal span: 1:733-734 -- id: 227 +- id: 224 kind: RqOperator span: 1:698-719 targets: - - 229 - - 233 -- id: 229 + - 226 + - 230 +- id: 226 kind: RqOperator span: 1:698-712 targets: - - 231 - - 232 -- id: 231 + - 228 + - 229 +- id: 228 kind: Ident span: 1:698-702 ident: !Ident - this - q_if targets: - - 184 -- id: 232 + - 181 +- id: 229 kind: Ident span: 1:705-712 ident: !Ident - this - - _literal_121 + - _literal_118 - k_float targets: - - 121 -- id: 233 + - 118 +- id: 230 kind: Ident span: 1:715-719 ident: !Ident - this - r_if targets: - - 200 -- id: 234 + - 197 +- id: 231 kind: RqOperator span: 1:764-776 targets: - - 237 - - 238 - parent: 256 -- id: 237 + - 234 + - 235 + parent: 253 +- id: 234 kind: Literal span: 1:775-776 -- id: 238 +- id: 235 kind: RqOperator span: 1:742-761 targets: - - 240 - - 244 -- id: 240 + - 237 + - 241 +- id: 237 kind: RqOperator span: 1:742-754 targets: - - 242 - - 243 -- id: 242 + - 239 + - 240 +- id: 239 kind: Ident span: 1:742-746 ident: !Ident - this - q_fi targets: - - 188 -- id: 243 + - 185 +- id: 240 kind: Ident span: 1:749-754 ident: !Ident - this - - _literal_121 + - _literal_118 - k_int targets: - - 121 -- id: 244 + - 118 +- id: 241 kind: Ident span: 1:757-761 ident: !Ident - this - r_fi targets: - - 204 -- id: 245 + - 201 +- id: 242 kind: RqOperator span: 1:808-820 targets: - - 248 - - 249 - parent: 256 -- id: 248 + - 245 + - 246 + parent: 253 +- id: 245 kind: Literal span: 1:819-820 -- id: 249 +- id: 246 kind: RqOperator span: 1:784-805 targets: - - 251 - - 255 -- id: 251 + - 248 + - 252 +- id: 248 kind: RqOperator span: 1:784-798 targets: - - 253 - - 254 -- id: 253 + - 250 + - 251 +- id: 250 kind: Ident span: 1:784-788 ident: !Ident - this - q_ff targets: - - 192 -- id: 254 + - 189 +- id: 251 kind: Ident span: 1:791-798 ident: !Ident - this - - _literal_121 + - _literal_118 - k_float targets: - - 121 -- id: 255 + - 118 +- id: 252 kind: Ident span: 1:801-805 ident: !Ident - this - r_ff targets: - - 208 -- id: 256 + - 205 +- id: 253 kind: Tuple span: 1:325-824 children: - - 163 - - 164 - - 168 - - 172 - - 176 - - 180 - - 184 - - 188 - - 192 - - 196 - - 200 - - 204 - - 208 - - 212 - - 223 - - 234 - - 245 - parent: 257 -- id: 257 + - 160 + - 161 + - 165 + - 169 + - 173 + - 177 + - 181 + - 185 + - 189 + - 193 + - 197 + - 201 + - 205 + - 209 + - 220 + - 231 + - 242 + parent: 254 +- id: 254 kind: 'TransformCall: Select' span: 1:318-824 children: - - 121 - - 256 - parent: 260 -- id: 258 + - 118 + - 253 + parent: 257 +- id: 255 kind: Ident span: 1:830-832 ident: !Ident - this - - _literal_121 + - _literal_118 - id targets: - - 163 - parent: 260 -- id: 260 + - 160 + parent: 257 +- id: 257 kind: 'TransformCall: Sort' span: 1:825-832 children: - - 257 - - 258 + - 254 + - 255 ast: name: Project stmts: diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__cast.snap b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__cast.snap index 01f2ccabce3e..7b4a1888c16d 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__cast.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__cast.snap @@ -2,16 +2,15 @@ source: prqlc/prqlc/tests/integration/queries.rs expression: "# mssql:test\nfrom tracks\nsort {-bytes}\nselect {\n name,\n bin = ((album_id | as REAL) * 99)\n}\ntake 20\n" input_file: prqlc/prqlc/tests/integration/queries/cast.prql -snapshot_kind: text --- frames: - - 1:25-38 - columns: - !All - input_id: 124 + input_id: 121 except: [] inputs: - - id: 124 + - id: 121 name: tracks table: - default_db @@ -22,15 +21,15 @@ frames: name: - tracks - name - target_id: 131 + target_id: 128 target_name: null - !Single name: - bin - target_id: 132 + target_id: 129 target_name: null inputs: - - id: 124 + - id: 121 name: tracks table: - default_db @@ -41,28 +40,28 @@ frames: name: - tracks - name - target_id: 131 + target_id: 128 target_name: null - !Single name: - bin - target_id: 132 + target_id: 129 target_name: null inputs: - - id: 124 + - id: 121 name: tracks table: - default_db - tracks nodes: -- id: 124 +- id: 121 kind: Ident span: 1:13-24 ident: !Ident - default_db - tracks - parent: 130 -- id: 128 + parent: 127 +- id: 125 kind: Ident span: 1:32-37 ident: !Ident @@ -70,16 +69,16 @@ nodes: - tracks - bytes targets: - - 124 - parent: 130 -- id: 130 + - 121 + parent: 127 +- id: 127 kind: 'TransformCall: Sort' span: 1:25-38 children: - - 124 - - 128 - parent: 140 -- id: 131 + - 121 + - 125 + parent: 137 +- id: 128 kind: Ident span: 1:52-56 ident: !Ident @@ -87,22 +86,22 @@ nodes: - tracks - name targets: - - 124 - parent: 139 -- id: 132 + - 121 + parent: 136 +- id: 129 kind: RqOperator span: 1:68-95 alias: bin targets: - - 134 - - 138 - parent: 139 -- id: 134 + - 131 + - 135 + parent: 136 +- id: 131 kind: RqOperator span: 1:81-88 targets: - - 137 -- id: 137 + - 134 +- id: 134 kind: Ident span: 1:70-78 ident: !Ident @@ -110,33 +109,33 @@ nodes: - tracks - album_id targets: - - 124 -- id: 138 + - 121 +- id: 135 kind: Literal span: 1:92-94 -- id: 139 +- id: 136 kind: Tuple span: 1:46-97 children: - - 131 - - 132 - parent: 140 -- id: 140 + - 128 + - 129 + parent: 137 +- id: 137 kind: 'TransformCall: Select' span: 1:39-97 children: - - 130 - - 139 - parent: 142 -- id: 142 + - 127 + - 136 + parent: 139 +- id: 139 kind: 'TransformCall: Take' span: 1:98-105 children: + - 137 - 140 - - 143 -- id: 143 +- id: 140 kind: Literal - parent: 142 + parent: 139 ast: name: Project stmts: diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__constants_only.snap b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__constants_only.snap index cba01b0738dd..9fb391b33009 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__constants_only.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__constants_only.snap @@ -2,16 +2,15 @@ source: prqlc/prqlc/tests/integration/queries.rs expression: "from genres\ntake 10\nfilter true\ntake 20\nfilter true\nselect d = 10\n" input_file: prqlc/prqlc/tests/integration/queries/constants_only.prql -snapshot_kind: text --- frames: - - 1:12-19 - columns: - !All - input_id: 130 + input_id: 127 except: [] inputs: - - id: 130 + - id: 127 name: genres table: - default_db @@ -19,10 +18,10 @@ frames: - - 1:20-31 - columns: - !All - input_id: 130 + input_id: 127 except: [] inputs: - - id: 130 + - id: 127 name: genres table: - default_db @@ -30,10 +29,10 @@ frames: - - 1:32-39 - columns: - !All - input_id: 130 + input_id: 127 except: [] inputs: - - id: 130 + - id: 127 name: genres table: - default_db @@ -41,10 +40,10 @@ frames: - - 1:40-51 - columns: - !All - input_id: 130 + input_id: 127 except: [] inputs: - - id: 130 + - id: 127 name: genres table: - default_db @@ -54,81 +53,81 @@ frames: - !Single name: - d - target_id: 142 + target_id: 139 target_name: null inputs: - - id: 130 + - id: 127 name: genres table: - default_db - genres nodes: -- id: 130 +- id: 127 kind: Ident span: 1:0-11 ident: !Ident - default_db - genres - parent: 133 -- id: 133 + parent: 130 +- id: 130 kind: 'TransformCall: Take' span: 1:12-19 children: - - 130 - - 134 - parent: 136 -- id: 134 - kind: Literal + - 127 + - 131 parent: 133 -- id: 135 +- id: 131 + kind: Literal + parent: 130 +- id: 132 kind: Literal span: 1:27-31 - parent: 136 -- id: 136 + parent: 133 +- id: 133 kind: 'TransformCall: Filter' span: 1:20-31 children: - - 133 - - 135 - parent: 138 -- id: 138 + - 130 + - 132 + parent: 135 +- id: 135 kind: 'TransformCall: Take' span: 1:32-39 children: + - 133 - 136 - - 139 - parent: 141 -- id: 139 - kind: Literal parent: 138 -- id: 140 +- id: 136 + kind: Literal + parent: 135 +- id: 137 kind: Literal span: 1:47-51 - parent: 141 -- id: 141 + parent: 138 +- id: 138 kind: 'TransformCall: Filter' span: 1:40-51 children: - - 138 - - 140 - parent: 144 -- id: 142 + - 135 + - 137 + parent: 141 +- id: 139 kind: Literal span: 1:63-65 alias: d - parent: 143 -- id: 143 + parent: 140 +- id: 140 kind: Tuple span: 1:63-65 children: - - 142 - parent: 144 -- id: 144 + - 139 + parent: 141 +- id: 141 kind: 'TransformCall: Select' span: 1:52-65 children: - - 141 - - 143 + - 138 + - 140 ast: name: Project stmts: diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__date_to_text.snap b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__date_to_text.snap index e3f941ff4a0a..b9fdce705e61 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__date_to_text.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__date_to_text.snap @@ -2,16 +2,15 @@ source: prqlc/prqlc/tests/integration/queries.rs expression: "# generic:skip\n# glaredb:skip\n# sqlite:skip\n# mssql:test\nfrom invoices\ntake 20\nselect {\n d1 = (invoice_date | date.to_text \"%Y/%m/%d\"),\n d2 = (invoice_date | date.to_text \"%F\"),\n d3 = (invoice_date | date.to_text \"%D\"),\n d4 = (invoice_date | date.to_text \"%H:%M:%S.%f\"),\n d5 = (invoice_date | date.to_text \"%r\"),\n d6 = (invoice_date | date.to_text \"%A %B %-d %Y\"),\n d7 = (invoice_date | date.to_text \"%a, %-d %b %Y at %I:%M:%S %p\"),\n d8 = (invoice_date | date.to_text \"%+\"),\n d9 = (invoice_date | date.to_text \"%-d/%-m/%y\"),\n d10 = (invoice_date | date.to_text \"%-Hh %Mmin\"),\n d11 = (invoice_date | date.to_text \"%M'%S\\\"\"),\n d12 = (invoice_date | date.to_text \"100%% in %d days\"),\n}\n" input_file: prqlc/prqlc/tests/integration/queries/date_to_text.prql -snapshot_kind: text --- frames: - - 1:71-78 - columns: - !All - input_id: 121 + input_id: 118 except: [] inputs: - - id: 121 + - id: 118 name: invoices table: - default_db @@ -21,99 +20,99 @@ frames: - !Single name: - d1 - target_id: 126 + target_id: 123 target_name: null - !Single name: - d2 - target_id: 131 + target_id: 128 target_name: null - !Single name: - d3 - target_id: 136 + target_id: 133 target_name: null - !Single name: - d4 - target_id: 141 + target_id: 138 target_name: null - !Single name: - d5 - target_id: 146 + target_id: 143 target_name: null - !Single name: - d6 - target_id: 151 + target_id: 148 target_name: null - !Single name: - d7 - target_id: 156 + target_id: 153 target_name: null - !Single name: - d8 - target_id: 161 + target_id: 158 target_name: null - !Single name: - d9 - target_id: 166 + target_id: 163 target_name: null - !Single name: - d10 - target_id: 171 + target_id: 168 target_name: null - !Single name: - d11 - target_id: 176 + target_id: 173 target_name: null - !Single name: - d12 - target_id: 181 + target_id: 178 target_name: null inputs: - - id: 121 + - id: 118 name: invoices table: - default_db - invoices nodes: -- id: 121 +- id: 118 kind: Ident span: 1:57-70 ident: !Ident - default_db - invoices - parent: 124 -- id: 124 + parent: 121 +- id: 121 kind: 'TransformCall: Take' span: 1:71-78 children: - - 121 - - 125 - parent: 187 -- id: 125 + - 118 + - 122 + parent: 184 +- id: 122 kind: Literal - parent: 124 -- id: 126 + parent: 121 +- id: 123 kind: RqOperator span: 1:113-136 alias: d1 targets: - - 129 - - 130 - parent: 186 -- id: 129 + - 126 + - 127 + parent: 183 +- id: 126 kind: Literal span: 1:126-136 -- id: 130 +- id: 127 kind: Ident span: 1:98-110 ident: !Ident @@ -121,19 +120,19 @@ nodes: - invoices - invoice_date targets: - - 121 -- id: 131 + - 118 +- id: 128 kind: RqOperator span: 1:164-181 alias: d2 targets: - - 134 - - 135 - parent: 186 -- id: 134 + - 131 + - 132 + parent: 183 +- id: 131 kind: Literal span: 1:177-181 -- id: 135 +- id: 132 kind: Ident span: 1:149-161 ident: !Ident @@ -141,19 +140,19 @@ nodes: - invoices - invoice_date targets: - - 121 -- id: 136 + - 118 +- id: 133 kind: RqOperator span: 1:209-226 alias: d3 targets: - - 139 - - 140 - parent: 186 -- id: 139 + - 136 + - 137 + parent: 183 +- id: 136 kind: Literal span: 1:222-226 -- id: 140 +- id: 137 kind: Ident span: 1:194-206 ident: !Ident @@ -161,19 +160,19 @@ nodes: - invoices - invoice_date targets: - - 121 -- id: 141 + - 118 +- id: 138 kind: RqOperator span: 1:254-280 alias: d4 targets: - - 144 - - 145 - parent: 186 -- id: 144 + - 141 + - 142 + parent: 183 +- id: 141 kind: Literal span: 1:267-280 -- id: 145 +- id: 142 kind: Ident span: 1:239-251 ident: !Ident @@ -181,19 +180,19 @@ nodes: - invoices - invoice_date targets: - - 121 -- id: 146 + - 118 +- id: 143 kind: RqOperator span: 1:308-325 alias: d5 targets: - - 149 - - 150 - parent: 186 -- id: 149 + - 146 + - 147 + parent: 183 +- id: 146 kind: Literal span: 1:321-325 -- id: 150 +- id: 147 kind: Ident span: 1:293-305 ident: !Ident @@ -201,19 +200,19 @@ nodes: - invoices - invoice_date targets: - - 121 -- id: 151 + - 118 +- id: 148 kind: RqOperator span: 1:353-380 alias: d6 targets: - - 154 - - 155 - parent: 186 -- id: 154 + - 151 + - 152 + parent: 183 +- id: 151 kind: Literal span: 1:366-380 -- id: 155 +- id: 152 kind: Ident span: 1:338-350 ident: !Ident @@ -221,19 +220,19 @@ nodes: - invoices - invoice_date targets: - - 121 -- id: 156 + - 118 +- id: 153 kind: RqOperator span: 1:408-451 alias: d7 targets: - - 159 - - 160 - parent: 186 -- id: 159 + - 156 + - 157 + parent: 183 +- id: 156 kind: Literal span: 1:421-451 -- id: 160 +- id: 157 kind: Ident span: 1:393-405 ident: !Ident @@ -241,19 +240,19 @@ nodes: - invoices - invoice_date targets: - - 121 -- id: 161 + - 118 +- id: 158 kind: RqOperator span: 1:479-496 alias: d8 targets: - - 164 - - 165 - parent: 186 -- id: 164 + - 161 + - 162 + parent: 183 +- id: 161 kind: Literal span: 1:492-496 -- id: 165 +- id: 162 kind: Ident span: 1:464-476 ident: !Ident @@ -261,19 +260,19 @@ nodes: - invoices - invoice_date targets: - - 121 -- id: 166 + - 118 +- id: 163 kind: RqOperator span: 1:524-549 alias: d9 targets: - - 169 - - 170 - parent: 186 -- id: 169 + - 166 + - 167 + parent: 183 +- id: 166 kind: Literal span: 1:537-549 -- id: 170 +- id: 167 kind: Ident span: 1:509-521 ident: !Ident @@ -281,19 +280,19 @@ nodes: - invoices - invoice_date targets: - - 121 -- id: 171 + - 118 +- id: 168 kind: RqOperator span: 1:578-603 alias: d10 targets: - - 174 - - 175 - parent: 186 -- id: 174 + - 171 + - 172 + parent: 183 +- id: 171 kind: Literal span: 1:591-603 -- id: 175 +- id: 172 kind: Ident span: 1:563-575 ident: !Ident @@ -301,19 +300,19 @@ nodes: - invoices - invoice_date targets: - - 121 -- id: 176 + - 118 +- id: 173 kind: RqOperator span: 1:632-654 alias: d11 targets: - - 179 - - 180 - parent: 186 -- id: 179 + - 176 + - 177 + parent: 183 +- id: 176 kind: Literal span: 1:645-654 -- id: 180 +- id: 177 kind: Ident span: 1:617-629 ident: !Ident @@ -321,19 +320,19 @@ nodes: - invoices - invoice_date targets: - - 121 -- id: 181 + - 118 +- id: 178 kind: RqOperator span: 1:683-714 alias: d12 targets: - - 184 - - 185 - parent: 186 -- id: 184 + - 181 + - 182 + parent: 183 +- id: 181 kind: Literal span: 1:696-714 -- id: 185 +- id: 182 kind: Ident span: 1:668-680 ident: !Ident @@ -341,30 +340,30 @@ nodes: - invoices - invoice_date targets: - - 121 -- id: 186 + - 118 +- id: 183 kind: Tuple span: 1:86-718 children: - - 126 - - 131 - - 136 - - 141 - - 146 - - 151 - - 156 - - 161 - - 166 - - 171 - - 176 - - 181 - parent: 187 -- id: 187 + - 123 + - 128 + - 133 + - 138 + - 143 + - 148 + - 153 + - 158 + - 163 + - 168 + - 173 + - 178 + parent: 184 +- id: 184 kind: 'TransformCall: Select' span: 1:79-718 children: - - 124 - - 186 + - 121 + - 183 ast: name: Project stmts: diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__distinct.snap b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__distinct.snap index 75a87b7226af..5540fd1b1a45 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__distinct.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__distinct.snap @@ -2,7 +2,6 @@ source: prqlc/prqlc/tests/integration/queries.rs expression: "# mssql:test\nfrom tracks\nselect {album_id, genre_id}\ngroup tracks.* (take 1)\nsort tracks.*\n" input_file: prqlc/prqlc/tests/integration/queries/distinct.prql -snapshot_kind: text --- frames: - - 1:25-52 @@ -11,16 +10,16 @@ frames: name: - tracks - album_id - target_id: 126 + target_id: 123 target_name: null - !Single name: - tracks - genre_id - target_id: 127 + target_id: 124 target_name: null inputs: - - id: 124 + - id: 121 name: tracks table: - default_db @@ -31,16 +30,16 @@ frames: name: - tracks - album_id - target_id: 131 + target_id: 128 target_name: null - !Single name: - tracks - genre_id - target_id: 132 + target_id: 129 target_name: null inputs: - - id: 124 + - id: 121 name: tracks table: - default_db @@ -51,29 +50,29 @@ frames: name: - tracks - album_id - target_id: 131 + target_id: 128 target_name: null - !Single name: - tracks - genre_id - target_id: 132 + target_id: 129 target_name: null inputs: - - id: 124 + - id: 121 name: tracks table: - default_db - tracks nodes: -- id: 124 +- id: 121 kind: Ident span: 1:13-24 ident: !Ident - default_db - tracks - parent: 129 -- id: 126 + parent: 126 +- id: 123 kind: Ident span: 1:33-41 ident: !Ident @@ -81,9 +80,9 @@ nodes: - tracks - album_id targets: - - 124 - parent: 128 -- id: 127 + - 121 + parent: 125 +- id: 124 kind: Ident span: 1:43-51 ident: !Ident @@ -91,81 +90,81 @@ nodes: - tracks - genre_id targets: - - 124 - parent: 128 -- id: 128 + - 121 + parent: 125 +- id: 125 kind: Tuple span: 1:32-52 children: - - 126 - - 127 - parent: 129 -- id: 129 + - 123 + - 124 + parent: 126 +- id: 126 kind: 'TransformCall: Select' span: 1:25-52 children: - - 124 - - 128 - parent: 150 -- id: 131 + - 121 + - 125 + parent: 147 +- id: 128 kind: Ident ident: !Ident - this - tracks - album_id targets: - - 126 - parent: 133 -- id: 132 + - 123 + parent: 130 +- id: 129 kind: Ident ident: !Ident - this - tracks - genre_id targets: - - 127 - parent: 133 -- id: 133 + - 124 + parent: 130 +- id: 130 kind: Tuple span: 1:65-67 children: - - 131 - - 132 -- id: 150 + - 128 + - 129 +- id: 147 kind: 'TransformCall: Take' span: 1:69-75 children: - - 129 - - 151 - parent: 158 -- id: 151 + - 126 + - 148 + parent: 155 +- id: 148 kind: Literal - parent: 150 -- id: 155 + parent: 147 +- id: 152 kind: Ident ident: !Ident - this - tracks - album_id targets: - - 131 - parent: 158 -- id: 156 + - 128 + parent: 155 +- id: 153 kind: Ident ident: !Ident - this - tracks - genre_id targets: - - 132 - parent: 158 -- id: 158 + - 129 + parent: 155 +- id: 155 kind: 'TransformCall: Sort' span: 1:77-90 children: - - 150 - - 155 - - 156 + - 147 + - 152 + - 153 ast: name: Project stmts: diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__distinct_on.snap b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__distinct_on.snap index e9641e36762c..fe8e7ae4e36e 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__distinct_on.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__distinct_on.snap @@ -2,7 +2,6 @@ source: prqlc/prqlc/tests/integration/queries.rs expression: "# mssql:test\nfrom tracks\nselect {genre_id, media_type_id, album_id}\ngroup {genre_id, media_type_id} (sort {-album_id} | take 1)\nsort {-genre_id, media_type_id}\n" input_file: prqlc/prqlc/tests/integration/queries/distinct_on.prql -snapshot_kind: text --- frames: - - 1:25-67 @@ -11,22 +10,22 @@ frames: name: - tracks - genre_id - target_id: 126 + target_id: 123 target_name: null - !Single name: - tracks - media_type_id - target_id: 127 + target_id: 124 target_name: null - !Single name: - tracks - album_id - target_id: 128 + target_id: 125 target_name: null inputs: - - id: 124 + - id: 121 name: tracks table: - default_db @@ -37,22 +36,22 @@ frames: name: - tracks - genre_id - target_id: 131 + target_id: 128 target_name: null - !Single name: - tracks - media_type_id - target_id: 132 + target_id: 129 target_name: null - !Single name: - tracks - album_id - target_id: 128 + target_id: 125 target_name: null inputs: - - id: 124 + - id: 121 name: tracks table: - default_db @@ -63,35 +62,35 @@ frames: name: - tracks - genre_id - target_id: 131 + target_id: 128 target_name: null - !Single name: - tracks - media_type_id - target_id: 132 + target_id: 129 target_name: null - !Single name: - tracks - album_id - target_id: 128 + target_id: 125 target_name: null inputs: - - id: 124 + - id: 121 name: tracks table: - default_db - tracks nodes: -- id: 124 +- id: 121 kind: Ident span: 1:13-24 ident: !Ident - default_db - tracks - parent: 130 -- id: 126 + parent: 127 +- id: 123 kind: Ident span: 1:33-41 ident: !Ident @@ -99,9 +98,9 @@ nodes: - tracks - genre_id targets: - - 124 - parent: 129 -- id: 127 + - 121 + parent: 126 +- id: 124 kind: Ident span: 1:43-56 ident: !Ident @@ -109,9 +108,9 @@ nodes: - tracks - media_type_id targets: - - 124 - parent: 129 -- id: 128 + - 121 + parent: 126 +- id: 125 kind: Ident span: 1:58-66 ident: !Ident @@ -119,24 +118,24 @@ nodes: - tracks - album_id targets: - - 124 - parent: 129 -- id: 129 + - 121 + parent: 126 +- id: 126 kind: Tuple span: 1:32-67 children: - - 126 - - 127 - - 128 - parent: 130 -- id: 130 + - 123 + - 124 + - 125 + parent: 127 +- id: 127 kind: 'TransformCall: Select' span: 1:25-67 children: - - 124 - - 129 - parent: 162 -- id: 131 + - 121 + - 126 + parent: 159 +- id: 128 kind: Ident span: 1:75-83 ident: !Ident @@ -144,9 +143,9 @@ nodes: - tracks - genre_id targets: - - 126 - parent: 133 -- id: 132 + - 123 + parent: 130 +- id: 129 kind: Ident span: 1:85-98 ident: !Ident @@ -154,15 +153,15 @@ nodes: - tracks - media_type_id targets: - - 127 - parent: 133 -- id: 133 + - 124 + parent: 130 +- id: 130 kind: Tuple span: 1:74-99 children: - - 131 - - 132 -- id: 158 + - 128 + - 129 +- id: 155 kind: Ident span: 1:108-116 ident: !Ident @@ -170,18 +169,18 @@ nodes: - tracks - album_id targets: - - 128 -- id: 162 + - 125 +- id: 159 kind: 'TransformCall: Take' span: 1:120-126 children: - - 130 - - 163 - parent: 171 -- id: 163 + - 127 + - 160 + parent: 168 +- id: 160 kind: Literal - parent: 162 -- id: 168 + parent: 159 +- id: 165 kind: Ident span: 1:135-143 ident: !Ident @@ -189,9 +188,9 @@ nodes: - tracks - genre_id targets: - - 131 - parent: 171 -- id: 169 + - 128 + parent: 168 +- id: 166 kind: Ident span: 1:145-158 ident: !Ident @@ -199,15 +198,15 @@ nodes: - tracks - media_type_id targets: - - 132 - parent: 171 -- id: 171 + - 129 + parent: 168 +- id: 168 kind: 'TransformCall: Sort' span: 1:128-159 children: - - 162 - - 168 - - 169 + - 159 + - 165 + - 166 ast: name: Project stmts: diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__genre_counts.snap b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__genre_counts.snap index 15c2d35ef4bd..1da376b85627 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__genre_counts.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__genre_counts.snap @@ -2,7 +2,6 @@ source: prqlc/prqlc/tests/integration/queries.rs expression: "# clickhouse:skip (ClickHouse prefers aliases to column names https://github.com/PRQL/prql/issues/2827)\n# mssql:test\nlet genre_count = (\n from genres\n aggregate {a = count name}\n)\n\nfrom genre_count\nfilter a > 0\nselect a = -a\n" input_file: prqlc/prqlc/tests/integration/queries/genre_counts.prql -snapshot_kind: text --- frames: - - 1:204-216 @@ -11,10 +10,10 @@ frames: name: - genre_count - a - target_id: 136 + target_id: 133 target_name: a inputs: - - id: 136 + - id: 133 name: genre_count table: - genre_count @@ -23,28 +22,28 @@ frames: - !Single name: - a - target_id: 143 + target_id: 140 target_name: null inputs: - - id: 136 + - id: 133 name: genre_count table: - genre_count nodes: -- id: 136 +- id: 133 kind: Ident span: 1:187-203 ident: !Ident - genre_count - parent: 142 -- id: 138 + parent: 139 +- id: 135 kind: RqOperator span: 1:211-216 targets: - - 140 - - 141 - parent: 142 -- id: 140 + - 137 + - 138 + parent: 139 +- id: 137 kind: Ident span: 1:211-212 ident: !Ident @@ -52,25 +51,25 @@ nodes: - genre_count - a targets: - - 136 -- id: 141 + - 133 +- id: 138 kind: Literal span: 1:215-216 -- id: 142 +- id: 139 kind: 'TransformCall: Filter' span: 1:204-216 children: - - 136 - - 138 - parent: 147 -- id: 143 + - 133 + - 135 + parent: 144 +- id: 140 kind: RqOperator span: 1:228-230 alias: a targets: - - 145 - parent: 146 -- id: 145 + - 142 + parent: 143 +- id: 142 kind: Ident span: 1:229-230 ident: !Ident @@ -78,19 +77,19 @@ nodes: - genre_count - a targets: - - 136 -- id: 146 + - 133 +- id: 143 kind: Tuple span: 1:228-230 children: - - 143 - parent: 147 -- id: 147 + - 140 + parent: 144 +- id: 144 kind: 'TransformCall: Select' span: 1:217-230 children: - - 142 - - 146 + - 139 + - 143 ast: name: Project stmts: diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__group_all.snap b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__group_all.snap index ab7df7f33f4e..79f5f34134b2 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__group_all.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__group_all.snap @@ -2,16 +2,15 @@ source: prqlc/prqlc/tests/integration/queries.rs expression: "# mssql:test\nfrom a=albums\ntake 10\njoin tracks (==album_id)\ngroup {a.album_id, a.title} (aggregate price = (sum tracks.unit_price | math.round 2))\nsort album_id\n" input_file: prqlc/prqlc/tests/integration/queries/group_all.prql -snapshot_kind: text --- frames: - - 1:27-34 - columns: - !All - input_id: 128 + input_id: 125 except: [] inputs: - - id: 128 + - id: 125 name: a table: - default_db @@ -19,18 +18,18 @@ frames: - - 1:35-59 - columns: - !All - input_id: 128 + input_id: 125 except: [] - !All - input_id: 122 + input_id: 119 except: [] inputs: - - id: 128 + - id: 125 name: a table: - default_db - albums - - id: 122 + - id: 119 name: tracks table: - default_db @@ -41,26 +40,26 @@ frames: name: - a - album_id - target_id: 138 + target_id: 135 target_name: null - !Single name: - a - title - target_id: 139 + target_id: 136 target_name: null - !Single name: - price - target_id: 157 + target_id: 154 target_name: null inputs: - - id: 128 + - id: 125 name: a table: - default_db - albums - - id: 122 + - id: 119 name: tracks table: - default_db @@ -71,63 +70,63 @@ frames: name: - a - album_id - target_id: 138 + target_id: 135 target_name: null - !Single name: - a - title - target_id: 139 + target_id: 136 target_name: null - !Single name: - price - target_id: 157 + target_id: 154 target_name: null inputs: - - id: 128 + - id: 125 name: a table: - default_db - albums - - id: 122 + - id: 119 name: tracks table: - default_db - tracks nodes: -- id: 122 +- id: 119 kind: Ident span: 1:40-46 ident: !Ident - default_db - tracks - parent: 137 -- id: 128 + parent: 134 +- id: 125 kind: Ident span: 1:13-26 ident: !Ident - default_db - albums - parent: 131 -- id: 131 + parent: 128 +- id: 128 kind: 'TransformCall: Take' span: 1:27-34 children: - - 128 - - 132 - parent: 137 -- id: 132 + - 125 + - 129 + parent: 134 +- id: 129 kind: Literal - parent: 131 -- id: 133 + parent: 128 +- id: 130 kind: RqOperator span: 1:48-58 targets: - - 135 - - 136 - parent: 137 -- id: 135 + - 132 + - 133 + parent: 134 +- id: 132 kind: Ident span: 1:50-58 ident: !Ident @@ -135,8 +134,8 @@ nodes: - a - album_id targets: - - 128 -- id: 136 + - 125 +- id: 133 kind: Ident span: 1:50-58 ident: !Ident @@ -144,16 +143,16 @@ nodes: - tracks - album_id targets: - - 122 -- id: 137 + - 119 +- id: 134 kind: 'TransformCall: Join' span: 1:35-59 children: - - 131 - - 122 - - 133 - parent: 165 -- id: 138 + - 128 + - 119 + - 130 + parent: 162 +- id: 135 kind: Ident span: 1:67-77 ident: !Ident @@ -161,9 +160,9 @@ nodes: - a - album_id targets: - - 128 - parent: 140 -- id: 139 + - 125 + parent: 137 +- id: 136 kind: Ident span: 1:79-86 ident: !Ident @@ -171,32 +170,32 @@ nodes: - a - title targets: - - 128 - parent: 140 -- id: 140 + - 125 + parent: 137 +- id: 137 kind: Tuple span: 1:66-87 children: - - 138 - - 139 - parent: 165 -- id: 157 + - 135 + - 136 + parent: 162 +- id: 154 kind: RqOperator span: 1:132-144 alias: price targets: - - 160 - - 161 - parent: 164 -- id: 160 + - 157 + - 158 + parent: 161 +- id: 157 kind: Literal span: 1:143-144 -- id: 161 +- id: 158 kind: RqOperator span: 1:108-129 targets: - - 163 -- id: 163 + - 160 +- id: 160 kind: Ident span: 1:118-129 ident: !Ident @@ -204,22 +203,22 @@ nodes: - tracks - unit_price targets: - - 122 -- id: 164 + - 119 +- id: 161 kind: Tuple span: 1:132-144 children: - - 157 - parent: 165 -- id: 165 + - 154 + parent: 162 +- id: 162 kind: 'TransformCall: Aggregate' span: 1:89-145 children: + - 134 + - 161 - 137 - - 164 - - 140 - parent: 170 -- id: 168 + parent: 167 +- id: 165 kind: Ident span: 1:152-160 ident: !Ident @@ -227,14 +226,14 @@ nodes: - a - album_id targets: - - 138 - parent: 170 -- id: 170 + - 135 + parent: 167 +- id: 167 kind: 'TransformCall: Sort' span: 1:147-160 children: + - 162 - 165 - - 168 ast: name: Project stmts: diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__group_sort.snap b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__group_sort.snap index 073fc82ee010..ec8c4c14b0d0 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__group_sort.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__group_sort.snap @@ -2,21 +2,20 @@ source: prqlc/prqlc/tests/integration/queries.rs expression: "# mssql:test\nfrom tracks\nderive d = album_id + 1\ngroup d (\n aggregate {\n n1 = (track_id | sum),\n }\n)\nsort d\ntake 10\nselect { d1 = d, n1 }\n" input_file: prqlc/prqlc/tests/integration/queries/group_sort.prql -snapshot_kind: text --- frames: - - 1:25-48 - columns: - !All - input_id: 130 + input_id: 127 except: [] - !Single name: - d - target_id: 132 + target_id: 129 target_name: null inputs: - - id: 130 + - id: 127 name: tracks table: - default_db @@ -26,15 +25,15 @@ frames: - !Single name: - d - target_id: 138 + target_id: 135 target_name: null - !Single name: - n1 - target_id: 155 + target_id: 152 target_name: null inputs: - - id: 130 + - id: 127 name: tracks table: - default_db @@ -44,15 +43,15 @@ frames: - !Single name: - d - target_id: 138 + target_id: 135 target_name: null - !Single name: - n1 - target_id: 155 + target_id: 152 target_name: null inputs: - - id: 130 + - id: 127 name: tracks table: - default_db @@ -62,15 +61,15 @@ frames: - !Single name: - d - target_id: 138 + target_id: 135 target_name: null - !Single name: - n1 - target_id: 155 + target_id: 152 target_name: null inputs: - - id: 130 + - id: 127 name: tracks table: - default_db @@ -80,36 +79,36 @@ frames: - !Single name: - d1 - target_id: 168 + target_id: 165 target_name: null - !Single name: - n1 - target_id: 169 + target_id: 166 target_name: null inputs: - - id: 130 + - id: 127 name: tracks table: - default_db - tracks nodes: -- id: 130 +- id: 127 kind: Ident span: 1:13-24 ident: !Ident - default_db - tracks - parent: 137 -- id: 132 + parent: 134 +- id: 129 kind: RqOperator span: 1:36-48 alias: d targets: - - 134 - - 135 - parent: 136 -- id: 134 + - 131 + - 132 + parent: 133 +- id: 131 kind: Ident span: 1:36-44 ident: !Ident @@ -117,46 +116,46 @@ nodes: - tracks - album_id targets: - - 130 -- id: 135 + - 127 +- id: 132 kind: Literal span: 1:47-48 -- id: 136 +- id: 133 kind: Tuple span: 1:36-48 children: - - 132 - parent: 137 -- id: 137 + - 129 + parent: 134 +- id: 134 kind: 'TransformCall: Derive' span: 1:25-48 children: - - 130 - - 136 - parent: 159 -- id: 138 + - 127 + - 133 + parent: 156 +- id: 135 kind: Ident span: 1:55-56 ident: !Ident - this - d targets: - - 132 - parent: 141 -- id: 141 + - 129 + parent: 138 +- id: 138 kind: Tuple span: 1:55-56 children: - - 138 - parent: 159 -- id: 155 + - 135 + parent: 156 +- id: 152 kind: RqOperator span: 1:100-103 alias: n1 targets: - - 157 - parent: 158 -- id: 157 + - 154 + parent: 155 +- id: 154 kind: Ident span: 1:89-97 ident: !Ident @@ -164,48 +163,48 @@ nodes: - tracks - track_id targets: - - 130 -- id: 158 + - 127 +- id: 155 kind: Tuple span: 1:73-111 children: - - 155 - parent: 159 -- id: 159 + - 152 + parent: 156 +- id: 156 kind: 'TransformCall: Aggregate' span: 1:63-111 children: - - 137 - - 158 - - 141 - parent: 164 -- id: 162 + - 134 + - 155 + - 138 + parent: 161 +- id: 159 kind: Ident span: 1:119-120 ident: !Ident - this - d targets: - - 138 - parent: 164 -- id: 164 + - 135 + parent: 161 +- id: 161 kind: 'TransformCall: Sort' span: 1:114-120 children: + - 156 - 159 - - 162 - parent: 166 -- id: 166 + parent: 163 +- id: 163 kind: 'TransformCall: Take' span: 1:121-128 children: + - 161 - 164 - - 167 - parent: 171 -- id: 167 + parent: 168 +- id: 164 kind: Literal - parent: 166 -- id: 168 + parent: 163 +- id: 165 kind: Ident span: 1:143-144 alias: d1 @@ -213,30 +212,30 @@ nodes: - this - d targets: - - 138 - parent: 170 -- id: 169 + - 135 + parent: 167 +- id: 166 kind: Ident span: 1:146-148 ident: !Ident - this - n1 targets: - - 155 - parent: 170 -- id: 170 + - 152 + parent: 167 +- id: 167 kind: Tuple span: 1:136-150 children: - - 168 - - 169 - parent: 171 -- id: 171 + - 165 + - 166 + parent: 168 +- id: 168 kind: 'TransformCall: Select' span: 1:129-150 children: - - 166 - - 170 + - 163 + - 167 ast: name: Project stmts: diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__group_sort_limit_take.snap b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__group_sort_limit_take.snap index dc3f777e0b70..992925309d47 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__group_sort_limit_take.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__group_sort_limit_take.snap @@ -2,7 +2,6 @@ source: prqlc/prqlc/tests/integration/queries.rs expression: "# Compute the 3 longest songs for each genre and sort by genre\n# mssql:test\nfrom tracks\nselect {genre_id,milliseconds}\ngroup {genre_id} (\n sort {-milliseconds}\n take 3\n)\njoin genres (==genre_id)\nselect {name, milliseconds}\nsort {+name,-milliseconds}\n" input_file: prqlc/prqlc/tests/integration/queries/group_sort_limit_take.prql -snapshot_kind: text --- frames: - - 1:88-118 @@ -11,16 +10,16 @@ frames: name: - tracks - genre_id - target_id: 133 + target_id: 130 target_name: null - !Single name: - tracks - milliseconds - target_id: 134 + target_id: 131 target_name: null inputs: - - id: 131 + - id: 128 name: tracks table: - default_db @@ -31,16 +30,16 @@ frames: name: - tracks - genre_id - target_id: 137 + target_id: 134 target_name: null - !Single name: - tracks - milliseconds - target_id: 134 + target_id: 131 target_name: null inputs: - - id: 131 + - id: 128 name: tracks table: - default_db @@ -51,24 +50,24 @@ frames: name: - tracks - genre_id - target_id: 137 + target_id: 134 target_name: null - !Single name: - tracks - milliseconds - target_id: 134 + target_id: 131 target_name: null - !All - input_id: 122 + input_id: 119 except: [] inputs: - - id: 131 + - id: 128 name: tracks table: - default_db - tracks - - id: 122 + - id: 119 name: genres table: - default_db @@ -79,21 +78,21 @@ frames: name: - genres - name - target_id: 175 + target_id: 172 target_name: null - !Single name: - tracks - milliseconds - target_id: 176 + target_id: 173 target_name: null inputs: - - id: 131 + - id: 128 name: tracks table: - default_db - tracks - - id: 122 + - id: 119 name: genres table: - default_db @@ -104,41 +103,41 @@ frames: name: - genres - name - target_id: 175 + target_id: 172 target_name: null - !Single name: - tracks - milliseconds - target_id: 176 + target_id: 173 target_name: null inputs: - - id: 131 + - id: 128 name: tracks table: - default_db - tracks - - id: 122 + - id: 119 name: genres table: - default_db - genres nodes: -- id: 122 +- id: 119 kind: Ident span: 1:177-183 ident: !Ident - default_db - genres - parent: 174 -- id: 131 + parent: 171 +- id: 128 kind: Ident span: 1:76-87 ident: !Ident - default_db - tracks - parent: 136 -- id: 133 + parent: 133 +- id: 130 kind: Ident span: 1:96-104 ident: !Ident @@ -146,9 +145,9 @@ nodes: - tracks - genre_id targets: - - 131 - parent: 135 -- id: 134 + - 128 + parent: 132 +- id: 131 kind: Ident span: 1:105-117 ident: !Ident @@ -156,23 +155,23 @@ nodes: - tracks - milliseconds targets: - - 131 - parent: 135 -- id: 135 + - 128 + parent: 132 +- id: 132 kind: Tuple span: 1:95-118 children: - - 133 - - 134 - parent: 136 -- id: 136 + - 130 + - 131 + parent: 133 +- id: 133 kind: 'TransformCall: Select' span: 1:88-118 children: - - 131 - - 135 - parent: 166 -- id: 137 + - 128 + - 132 + parent: 163 +- id: 134 kind: Ident span: 1:126-134 ident: !Ident @@ -180,14 +179,14 @@ nodes: - tracks - genre_id targets: - - 133 - parent: 138 -- id: 138 + - 130 + parent: 135 +- id: 135 kind: Tuple span: 1:125-135 children: - - 137 -- id: 162 + - 134 +- id: 159 kind: Ident span: 1:147-159 ident: !Ident @@ -195,25 +194,25 @@ nodes: - tracks - milliseconds targets: - - 134 -- id: 166 + - 131 +- id: 163 kind: 'TransformCall: Take' span: 1:163-169 children: - - 136 - - 167 - parent: 174 -- id: 167 + - 133 + - 164 + parent: 171 +- id: 164 kind: Literal - parent: 166 -- id: 170 + parent: 163 +- id: 167 kind: RqOperator span: 1:185-195 targets: - - 172 - - 173 - parent: 174 -- id: 172 + - 169 + - 170 + parent: 171 +- id: 169 kind: Ident span: 1:187-195 ident: !Ident @@ -221,8 +220,8 @@ nodes: - tracks - genre_id targets: - - 137 -- id: 173 + - 134 +- id: 170 kind: Ident span: 1:187-195 ident: !Ident @@ -230,16 +229,16 @@ nodes: - genres - genre_id targets: - - 122 -- id: 174 + - 119 +- id: 171 kind: 'TransformCall: Join' span: 1:172-196 children: - - 166 - - 122 - - 170 - parent: 178 -- id: 175 + - 163 + - 119 + - 167 + parent: 175 +- id: 172 kind: Ident span: 1:205-209 ident: !Ident @@ -247,9 +246,9 @@ nodes: - genres - name targets: - - 122 - parent: 177 -- id: 176 + - 119 + parent: 174 +- id: 173 kind: Ident span: 1:211-223 ident: !Ident @@ -257,23 +256,23 @@ nodes: - tracks - milliseconds targets: - - 134 - parent: 177 -- id: 177 + - 131 + parent: 174 +- id: 174 kind: Tuple span: 1:204-224 children: - - 175 - - 176 - parent: 178 -- id: 178 + - 172 + - 173 + parent: 175 +- id: 175 kind: 'TransformCall: Select' span: 1:197-224 children: + - 171 - 174 - - 177 - parent: 184 -- id: 179 + parent: 181 +- id: 176 kind: Ident span: 1:231-236 ident: !Ident @@ -281,9 +280,9 @@ nodes: - genres - name targets: - - 175 - parent: 184 -- id: 182 + - 172 + parent: 181 +- id: 179 kind: Ident span: 1:238-250 ident: !Ident @@ -291,15 +290,15 @@ nodes: - tracks - milliseconds targets: - - 176 - parent: 184 -- id: 184 + - 173 + parent: 181 +- id: 181 kind: 'TransformCall: Sort' span: 1:225-251 children: - - 178 + - 175 + - 176 - 179 - - 182 ast: name: Project stmts: diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__invoice_totals.snap b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__invoice_totals.snap index ad6df19c473f..805ea9e7f310 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__invoice_totals.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__invoice_totals.snap @@ -2,24 +2,23 @@ source: prqlc/prqlc/tests/integration/queries.rs expression: "# clickhouse:skip (clickhouse doesn't have lag function)\n\n#! Calculate a number of metrics about the sales of tracks in each city.\nfrom i=invoices\njoin ii=invoice_items (==invoice_id)\nderive {\n city = i.billing_city,\n street = i.billing_address,\n}\ngroup {city, street} (\n derive total = ii.unit_price * ii.quantity\n aggregate {\n num_orders = count_distinct i.invoice_id,\n num_tracks = sum ii.quantity,\n total_price = sum total,\n }\n)\ngroup {city} (\n sort street\n window expanding:true (\n derive {running_total_num_tracks = sum num_tracks}\n )\n)\nsort {city, street}\nderive {num_tracks_last_week = lag 7 num_tracks}\nselect {\n city,\n street,\n num_orders,\n num_tracks,\n running_total_num_tracks,\n num_tracks_last_week\n}\ntake 20\n" input_file: prqlc/prqlc/tests/integration/queries/invoice_totals.prql -snapshot_kind: text --- frames: - - 1:147-183 - columns: - !All - input_id: 140 + input_id: 137 except: [] - !All - input_id: 137 + input_id: 134 except: [] inputs: - - id: 140 + - id: 137 name: i table: - default_db - invoices - - id: 137 + - id: 134 name: ii table: - default_db @@ -27,28 +26,28 @@ frames: - - 1:184-253 - columns: - !All - input_id: 140 + input_id: 137 except: [] - !All - input_id: 137 + input_id: 134 except: [] - !Single name: - city - target_id: 147 + target_id: 144 target_name: null - !Single name: - street - target_id: 148 + target_id: 145 target_name: null inputs: - - id: 140 + - id: 137 name: i table: - default_db - invoices - - id: 137 + - id: 134 name: ii table: - default_db @@ -56,23 +55,23 @@ frames: - - 1:281-323 - columns: - !All - input_id: 140 + input_id: 137 except: [] - !All - input_id: 137 + input_id: 134 except: [] - !Single name: - total - target_id: 178 + target_id: 175 target_name: null inputs: - - id: 140 + - id: 137 name: i table: - default_db - invoices - - id: 137 + - id: 134 name: ii table: - default_db @@ -82,35 +81,35 @@ frames: - !Single name: - city - target_id: 151 + target_id: 148 target_name: null - !Single name: - street - target_id: 152 + target_id: 149 target_name: null - !Single name: - num_orders - target_id: 184 + target_id: 181 target_name: null - !Single name: - num_tracks - target_id: 187 + target_id: 184 target_name: null - !Single name: - total_price - target_id: 190 + target_id: 187 target_name: null inputs: - - id: 140 + - id: 137 name: i table: - default_db - invoices - - id: 137 + - id: 134 name: ii table: - default_db @@ -120,40 +119,40 @@ frames: - !Single name: - city - target_id: 197 + target_id: 194 target_name: null - !Single name: - street - target_id: 152 + target_id: 149 target_name: null - !Single name: - num_orders - target_id: 184 + target_id: 181 target_name: null - !Single name: - num_tracks - target_id: 187 + target_id: 184 target_name: null - !Single name: - total_price - target_id: 190 + target_id: 187 target_name: null - !Single name: - running_total_num_tracks - target_id: 243 + target_id: 240 target_name: null inputs: - - id: 140 + - id: 137 name: i table: - default_db - invoices - - id: 137 + - id: 134 name: ii table: - default_db @@ -163,40 +162,40 @@ frames: - !Single name: - city - target_id: 197 + target_id: 194 target_name: null - !Single name: - street - target_id: 152 + target_id: 149 target_name: null - !Single name: - num_orders - target_id: 184 + target_id: 181 target_name: null - !Single name: - num_tracks - target_id: 187 + target_id: 184 target_name: null - !Single name: - total_price - target_id: 190 + target_id: 187 target_name: null - !Single name: - running_total_num_tracks - target_id: 243 + target_id: 240 target_name: null inputs: - - id: 140 + - id: 137 name: i table: - default_db - invoices - - id: 137 + - id: 134 name: ii table: - default_db @@ -206,45 +205,45 @@ frames: - !Single name: - city - target_id: 197 + target_id: 194 target_name: null - !Single name: - street - target_id: 152 + target_id: 149 target_name: null - !Single name: - num_orders - target_id: 184 + target_id: 181 target_name: null - !Single name: - num_tracks - target_id: 187 + target_id: 184 target_name: null - !Single name: - total_price - target_id: 190 + target_id: 187 target_name: null - !Single name: - running_total_num_tracks - target_id: 243 + target_id: 240 target_name: null - !Single name: - num_tracks_last_week - target_id: 257 + target_id: 254 target_name: null inputs: - - id: 140 + - id: 137 name: i table: - default_db - invoices - - id: 137 + - id: 134 name: ii table: - default_db @@ -254,40 +253,40 @@ frames: - !Single name: - city - target_id: 263 + target_id: 260 target_name: null - !Single name: - street - target_id: 264 + target_id: 261 target_name: null - !Single name: - num_orders - target_id: 265 + target_id: 262 target_name: null - !Single name: - num_tracks - target_id: 266 + target_id: 263 target_name: null - !Single name: - running_total_num_tracks - target_id: 267 + target_id: 264 target_name: null - !Single name: - num_tracks_last_week - target_id: 268 + target_id: 265 target_name: null inputs: - - id: 140 + - id: 137 name: i table: - default_db - invoices - - id: 137 + - id: 134 name: ii table: - default_db @@ -297,67 +296,67 @@ frames: - !Single name: - city - target_id: 263 + target_id: 260 target_name: null - !Single name: - street - target_id: 264 + target_id: 261 target_name: null - !Single name: - num_orders - target_id: 265 + target_id: 262 target_name: null - !Single name: - num_tracks - target_id: 266 + target_id: 263 target_name: null - !Single name: - running_total_num_tracks - target_id: 267 + target_id: 264 target_name: null - !Single name: - num_tracks_last_week - target_id: 268 + target_id: 265 target_name: null inputs: - - id: 140 + - id: 137 name: i table: - default_db - invoices - - id: 137 + - id: 134 name: ii table: - default_db - invoice_items nodes: -- id: 137 +- id: 134 kind: Ident span: 1:155-168 ident: !Ident - default_db - invoice_items - parent: 146 -- id: 140 + parent: 143 +- id: 137 kind: Ident span: 1:131-146 ident: !Ident - default_db - invoices - parent: 146 -- id: 142 + parent: 143 +- id: 139 kind: RqOperator span: 1:170-182 targets: - - 144 - - 145 - parent: 146 -- id: 144 + - 141 + - 142 + parent: 143 +- id: 141 kind: Ident span: 1:172-182 ident: !Ident @@ -365,8 +364,8 @@ nodes: - i - invoice_id targets: - - 140 -- id: 145 + - 137 +- id: 142 kind: Ident span: 1:172-182 ident: !Ident @@ -374,16 +373,16 @@ nodes: - ii - invoice_id targets: - - 137 -- id: 146 + - 134 +- id: 143 kind: 'TransformCall: Join' span: 1:147-183 children: - - 140 - 137 - - 142 - parent: 150 -- id: 147 + - 134 + - 139 + parent: 147 +- id: 144 kind: Ident span: 1:204-218 alias: city @@ -392,9 +391,9 @@ nodes: - i - billing_city targets: - - 140 - parent: 149 -- id: 148 + - 137 + parent: 146 +- id: 145 kind: Ident span: 1:233-250 alias: street @@ -403,56 +402,56 @@ nodes: - i - billing_address targets: - - 140 - parent: 149 -- id: 149 + - 137 + parent: 146 +- id: 146 kind: Tuple span: 1:191-253 children: - - 147 - - 148 - parent: 150 -- id: 150 + - 144 + - 145 + parent: 147 +- id: 147 kind: 'TransformCall: Derive' span: 1:184-253 children: + - 143 - 146 - - 149 - parent: 183 -- id: 151 + parent: 180 +- id: 148 kind: Ident span: 1:261-265 ident: !Ident - this - city targets: - - 147 - parent: 153 -- id: 152 + - 144 + parent: 150 +- id: 149 kind: Ident span: 1:267-273 ident: !Ident - this - street targets: - - 148 - parent: 153 -- id: 153 + - 145 + parent: 150 +- id: 150 kind: Tuple span: 1:260-274 children: - - 151 - - 152 - parent: 194 -- id: 178 + - 148 + - 149 + parent: 191 +- id: 175 kind: RqOperator span: 1:296-323 alias: total targets: - - 180 - - 181 - parent: 182 -- id: 180 + - 177 + - 178 + parent: 179 +- id: 177 kind: Ident span: 1:298-309 ident: !Ident @@ -460,8 +459,8 @@ nodes: - ii - unit_price targets: - - 137 -- id: 181 + - 134 +- id: 178 kind: Ident span: 1:314-323 ident: !Ident @@ -469,28 +468,28 @@ nodes: - ii - quantity targets: - - 137 -- id: 182 + - 134 +- id: 179 kind: Tuple span: 1:296-323 children: - - 178 - parent: 183 -- id: 183 + - 175 + parent: 180 +- id: 180 kind: 'TransformCall: Derive' span: 1:281-323 children: - - 150 - - 182 - parent: 194 -- id: 184 + - 147 + - 179 + parent: 191 +- id: 181 kind: RqOperator span: 1:361-388 alias: num_orders targets: - - 186 - parent: 193 -- id: 186 + - 183 + parent: 190 +- id: 183 kind: Ident span: 1:377-388 ident: !Ident @@ -498,15 +497,15 @@ nodes: - i - invoice_id targets: - - 140 -- id: 187 + - 137 +- id: 184 kind: RqOperator span: 1:411-426 alias: num_tracks targets: - - 189 - parent: 193 -- id: 189 + - 186 + parent: 190 +- id: 186 kind: Ident span: 1:417-426 ident: !Ident @@ -514,229 +513,229 @@ nodes: - ii - quantity targets: - - 137 -- id: 190 + - 134 +- id: 187 kind: RqOperator span: 1:450-459 alias: total_price targets: - - 192 - parent: 193 -- id: 192 + - 189 + parent: 190 +- id: 189 kind: Ident span: 1:454-459 ident: !Ident - this - total targets: - - 178 -- id: 193 + - 175 +- id: 190 kind: Tuple span: 1:338-466 children: + - 181 - 184 - 187 - - 190 - parent: 194 -- id: 194 + parent: 191 +- id: 191 kind: 'TransformCall: Aggregate' span: 1:328-466 children: - - 183 - - 193 - - 153 - parent: 247 -- id: 197 + - 180 + - 190 + - 150 + parent: 244 +- id: 194 kind: Ident span: 1:476-480 ident: !Ident - this - city targets: - - 151 - parent: 198 -- id: 198 + - 148 + parent: 195 +- id: 195 kind: Tuple span: 1:475-481 children: - - 197 -- id: 222 + - 194 +- id: 219 kind: Ident span: 1:493-499 ident: !Ident - this - street targets: - - 152 -- id: 243 + - 149 +- id: 240 kind: RqOperator span: 1:571-585 alias: running_total_num_tracks targets: - - 245 - parent: 246 -- id: 245 + - 242 + parent: 243 +- id: 242 kind: Ident span: 1:575-585 ident: !Ident - this - num_tracks targets: - - 187 -- id: 246 + - 184 +- id: 243 kind: Tuple span: 1:543-586 children: - - 243 - parent: 247 -- id: 247 + - 240 + parent: 244 +- id: 244 kind: 'TransformCall: Derive' span: 1:536-586 children: - - 194 - - 246 - parent: 256 -- id: 249 + - 191 + - 243 + parent: 253 +- id: 246 kind: Literal -- id: 253 +- id: 250 kind: Ident span: 1:601-605 ident: !Ident - this - city targets: - - 197 - parent: 256 -- id: 254 + - 194 + parent: 253 +- id: 251 kind: Ident span: 1:607-613 ident: !Ident - this - street targets: - - 152 - parent: 256 -- id: 256 + - 149 + parent: 253 +- id: 253 kind: 'TransformCall: Sort' span: 1:595-614 children: - - 247 - - 253 - - 254 - parent: 262 -- id: 257 + - 244 + - 250 + - 251 + parent: 259 +- id: 254 kind: RqOperator span: 1:646-662 alias: num_tracks_last_week targets: - - 259 - - 260 - parent: 261 -- id: 259 + - 256 + - 257 + parent: 258 +- id: 256 kind: Literal span: 1:650-651 -- id: 260 +- id: 257 kind: Ident span: 1:652-662 ident: !Ident - this - num_tracks targets: - - 187 -- id: 261 + - 184 +- id: 258 kind: Tuple span: 1:622-663 children: - - 257 - parent: 262 -- id: 262 + - 254 + parent: 259 +- id: 259 kind: 'TransformCall: Derive' span: 1:615-663 children: - - 256 - - 261 - parent: 270 -- id: 263 + - 253 + - 258 + parent: 267 +- id: 260 kind: Ident span: 1:677-681 ident: !Ident - this - city targets: - - 197 - parent: 269 -- id: 264 + - 194 + parent: 266 +- id: 261 kind: Ident span: 1:687-693 ident: !Ident - this - street targets: - - 152 - parent: 269 -- id: 265 + - 149 + parent: 266 +- id: 262 kind: Ident span: 1:699-709 ident: !Ident - this - num_orders targets: - - 184 - parent: 269 -- id: 266 + - 181 + parent: 266 +- id: 263 kind: Ident span: 1:715-725 ident: !Ident - this - num_tracks targets: - - 187 - parent: 269 -- id: 267 + - 184 + parent: 266 +- id: 264 kind: Ident span: 1:731-755 ident: !Ident - this - running_total_num_tracks targets: - - 243 - parent: 269 -- id: 268 + - 240 + parent: 266 +- id: 265 kind: Ident span: 1:761-781 ident: !Ident - this - num_tracks_last_week targets: - - 257 - parent: 269 -- id: 269 + - 254 + parent: 266 +- id: 266 kind: Tuple span: 1:671-783 children: + - 260 + - 261 + - 262 - 263 - 264 - 265 - - 266 - - 267 - - 268 - parent: 270 -- id: 270 + parent: 267 +- id: 267 kind: 'TransformCall: Select' span: 1:664-783 children: - - 262 - - 269 - parent: 272 -- id: 272 + - 259 + - 266 + parent: 269 +- id: 269 kind: 'TransformCall: Take' span: 1:784-791 children: + - 267 - 270 - - 273 -- id: 273 +- id: 270 kind: Literal - parent: 272 + parent: 269 ast: name: Project stmts: diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__loop_01.snap b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__loop_01.snap index 014e1ca6fc39..abaf658e789d 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__loop_01.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__loop_01.snap @@ -2,7 +2,6 @@ source: prqlc/prqlc/tests/integration/queries.rs expression: "# clickhouse:skip (DB::Exception: Syntax error)\n# glaredb:skip (DataFusion does not support recursive CTEs https://github.com/apache/arrow-datafusion/issues/462)\nfrom [{n = 1}]\nselect n = n - 2\nloop (filter n < 4 | select n = n + 1)\nselect n = n * 2\nsort n\n" input_file: prqlc/prqlc/tests/integration/queries/loop_01.prql -snapshot_kind: text --- frames: - - 1:177-193 @@ -10,252 +9,252 @@ frames: - !Single name: - n - target_id: 131 + target_id: 128 target_name: null inputs: - - id: 127 - name: _literal_127 + - id: 124 + name: _literal_124 table: - default_db - - _literal_127 + - _literal_124 - - 1:200-212 - columns: - !Single name: - n - target_id: 131 + target_id: 128 target_name: null inputs: - - id: 127 - name: _literal_127 + - id: 124 + name: _literal_124 table: - default_db - - _literal_127 + - _literal_124 - - 1:215-231 - columns: - !Single name: - n - target_id: 154 + target_id: 151 target_name: null inputs: - - id: 127 - name: _literal_127 + - id: 124 + name: _literal_124 table: - default_db - - _literal_127 + - _literal_124 - - 1:194-232 - columns: - !Single name: - n - target_id: 131 + target_id: 128 target_name: null inputs: - - id: 127 - name: _literal_127 + - id: 124 + name: _literal_124 table: - default_db - - _literal_127 + - _literal_124 - - 1:233-249 - columns: - !Single name: - n - target_id: 162 + target_id: 159 target_name: null inputs: - - id: 127 - name: _literal_127 + - id: 124 + name: _literal_124 table: - default_db - - _literal_127 + - _literal_124 - - 1:250-256 - columns: - !Single name: - n - target_id: 162 + target_id: 159 target_name: null inputs: - - id: 127 - name: _literal_127 + - id: 124 + name: _literal_124 table: - default_db - - _literal_127 + - _literal_124 nodes: -- id: 127 +- id: 124 kind: Array span: 1:162-176 children: - - 128 - parent: 136 -- id: 128 + - 125 + parent: 133 +- id: 125 kind: Tuple span: 1:168-175 children: - - 129 - parent: 127 -- id: 129 + - 126 + parent: 124 +- id: 126 kind: Literal span: 1:173-174 alias: n - parent: 128 -- id: 131 + parent: 125 +- id: 128 kind: RqOperator span: 1:188-193 alias: n targets: - - 133 - - 134 - parent: 135 -- id: 133 + - 130 + - 131 + parent: 132 +- id: 130 kind: Ident span: 1:188-189 ident: !Ident - this - - _literal_127 + - _literal_124 - n targets: - - 127 -- id: 134 + - 124 +- id: 131 kind: Literal span: 1:192-193 -- id: 135 +- id: 132 kind: Tuple span: 1:188-193 children: - - 131 - parent: 136 -- id: 136 + - 128 + parent: 133 +- id: 133 kind: 'TransformCall: Select' span: 1:177-193 children: - - 127 - - 135 - parent: 160 -- id: 145 + - 124 + - 132 + parent: 157 +- id: 142 kind: Ident ident: !Ident - _param - _tbl targets: - - 142 - parent: 153 -- id: 149 + - 139 + parent: 150 +- id: 146 kind: RqOperator span: 1:207-212 targets: - - 151 - - 152 - parent: 153 -- id: 151 + - 148 + - 149 + parent: 150 +- id: 148 kind: Ident span: 1:207-208 ident: !Ident - this - n targets: - - 131 -- id: 152 + - 128 +- id: 149 kind: Literal span: 1:211-212 -- id: 153 +- id: 150 kind: 'TransformCall: Filter' span: 1:200-212 children: - - 145 - - 149 - parent: 159 -- id: 154 + - 142 + - 146 + parent: 156 +- id: 151 kind: RqOperator span: 1:226-231 alias: n targets: - - 156 - - 157 - parent: 158 -- id: 156 + - 153 + - 154 + parent: 155 +- id: 153 kind: Ident span: 1:226-227 ident: !Ident - this - n targets: - - 131 -- id: 157 + - 128 +- id: 154 kind: Literal span: 1:230-231 -- id: 158 +- id: 155 kind: Tuple span: 1:226-231 children: - - 154 - parent: 159 -- id: 159 + - 151 + parent: 156 +- id: 156 kind: 'TransformCall: Select' span: 1:215-231 children: - - 153 - - 158 -- id: 160 + - 150 + - 155 +- id: 157 kind: 'TransformCall: Loop' span: 1:194-232 children: - - 136 - - 161 - parent: 167 -- id: 161 + - 133 + - 158 + parent: 164 +- id: 158 kind: Func span: 1:215-231 - parent: 160 -- id: 162 + parent: 157 +- id: 159 kind: RqOperator span: 1:244-249 alias: n targets: - - 164 - - 165 - parent: 166 -- id: 164 + - 161 + - 162 + parent: 163 +- id: 161 kind: Ident span: 1:244-245 ident: !Ident - this - n targets: - - 131 -- id: 165 + - 128 +- id: 162 kind: Literal span: 1:248-249 -- id: 166 +- id: 163 kind: Tuple span: 1:244-249 children: - - 162 - parent: 167 -- id: 167 + - 159 + parent: 164 +- id: 164 kind: 'TransformCall: Select' span: 1:233-249 children: - - 160 - - 166 - parent: 170 -- id: 168 + - 157 + - 163 + parent: 167 +- id: 165 kind: Ident span: 1:255-256 ident: !Ident - this - n targets: - - 162 - parent: 170 -- id: 170 + - 159 + parent: 167 +- id: 167 kind: 'TransformCall: Sort' span: 1:250-256 children: - - 167 - - 168 + - 164 + - 165 ast: name: Project stmts: diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__math_module.snap b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__math_module.snap index b395e8d3975f..d1c6cbd6b5f3 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__math_module.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__math_module.snap @@ -2,16 +2,15 @@ source: prqlc/prqlc/tests/integration/queries.rs expression: "# mssql:test\n# sqlite:skip (see https://github.com/rusqlite/rusqlite/issues/1211)\nfrom invoices\ntake 5\nselect {\n total_original = (total | math.round 2),\n total_x = (math.pi - total | math.round 2 | math.abs),\n total_floor = (math.floor total),\n total_ceil = (math.ceil total),\n total_log10 = (math.log10 total | math.round 3),\n total_log2 = (math.log 2 total | math.round 3),\n total_sqrt = (math.sqrt total | math.round 3),\n total_ln = (math.ln total | math.exp | math.round 2),\n total_cos = (math.cos total | math.acos | math.round 2),\n total_sin = (math.sin total | math.asin | math.round 2),\n total_tan = (math.tan total | math.atan | math.round 2),\n total_deg = (total | math.degrees | math.radians | math.round 2),\n total_square = (total | math.pow 2 | math.round 2),\n total_square_op = ((total ** 2) | math.round 2),\n}\n" input_file: prqlc/prqlc/tests/integration/queries/math_module.prql -snapshot_kind: text --- frames: - - 1:96-102 - columns: - !All - input_id: 121 + input_id: 118 except: [] inputs: - - id: 121 + - id: 118 name: invoices table: - default_db @@ -21,109 +20,109 @@ frames: - !Single name: - total_original - target_id: 126 + target_id: 123 target_name: null - !Single name: - total_x - target_id: 131 + target_id: 128 target_name: null - !Single name: - total_floor - target_id: 142 + target_id: 139 target_name: null - !Single name: - total_ceil - target_id: 145 + target_id: 142 target_name: null - !Single name: - total_log10 - target_id: 148 + target_id: 145 target_name: null - !Single name: - total_log2 - target_id: 155 + target_id: 152 target_name: null - !Single name: - total_sqrt - target_id: 163 + target_id: 160 target_name: null - !Single name: - total_ln - target_id: 170 + target_id: 167 target_name: null - !Single name: - total_cos - target_id: 179 + target_id: 176 target_name: null - !Single name: - total_sin - target_id: 188 + target_id: 185 target_name: null - !Single name: - total_tan - target_id: 197 + target_id: 194 target_name: null - !Single name: - total_deg - target_id: 206 + target_id: 203 target_name: null - !Single name: - total_square - target_id: 215 + target_id: 212 target_name: null - !Single name: - total_square_op - target_id: 224 + target_id: 221 target_name: null inputs: - - id: 121 + - id: 118 name: invoices table: - default_db - invoices nodes: -- id: 121 +- id: 118 kind: Ident span: 1:82-95 ident: !Ident - default_db - invoices - parent: 124 -- id: 124 + parent: 121 +- id: 121 kind: 'TransformCall: Take' span: 1:96-102 children: - - 121 - - 125 - parent: 233 -- id: 125 + - 118 + - 122 + parent: 230 +- id: 122 kind: Literal - parent: 124 -- id: 126 + parent: 121 +- id: 123 kind: RqOperator span: 1:142-154 alias: total_original targets: - - 129 - - 130 - parent: 232 -- id: 129 + - 126 + - 127 + parent: 229 +- id: 126 kind: Literal span: 1:153-154 -- id: 130 +- id: 127 kind: Ident span: 1:134-139 ident: !Ident @@ -131,33 +130,33 @@ nodes: - invoices - total targets: - - 121 -- id: 131 + - 118 +- id: 128 kind: RqOperator span: 1:205-213 alias: total_x targets: - - 133 - parent: 232 -- id: 133 + - 130 + parent: 229 +- id: 130 kind: RqOperator span: 1:190-202 targets: - - 136 - - 137 -- id: 136 + - 133 + - 134 +- id: 133 kind: Literal span: 1:201-202 -- id: 137 +- id: 134 kind: RqOperator span: 1:172-187 targets: - - 140 - - 141 -- id: 140 + - 137 + - 138 +- id: 137 kind: RqOperator span: 1:176-179 -- id: 141 +- id: 138 kind: Ident span: 1:182-187 ident: !Ident @@ -165,15 +164,15 @@ nodes: - invoices - total targets: - - 121 -- id: 142 + - 118 +- id: 139 kind: RqOperator span: 1:234-252 alias: total_floor targets: - - 144 - parent: 232 -- id: 144 + - 141 + parent: 229 +- id: 141 kind: Ident span: 1:246-251 ident: !Ident @@ -181,15 +180,15 @@ nodes: - invoices - total targets: - - 121 -- id: 145 + - 118 +- id: 142 kind: RqOperator span: 1:271-288 alias: total_ceil targets: - - 147 - parent: 232 -- id: 147 + - 144 + parent: 229 +- id: 144 kind: Ident span: 1:282-287 ident: !Ident @@ -197,24 +196,24 @@ nodes: - invoices - total targets: - - 121 -- id: 148 + - 118 +- id: 145 kind: RqOperator span: 1:328-340 alias: total_log10 targets: - - 151 - - 152 - parent: 232 -- id: 151 + - 148 + - 149 + parent: 229 +- id: 148 kind: Literal span: 1:339-340 -- id: 152 +- id: 149 kind: RqOperator span: 1:309-325 targets: - - 154 -- id: 154 + - 151 +- id: 151 kind: Ident span: 1:320-325 ident: !Ident @@ -222,28 +221,28 @@ nodes: - invoices - total targets: - - 121 -- id: 155 + - 118 +- id: 152 kind: RqOperator span: 1:380-392 alias: total_log2 targets: - - 158 - - 159 - parent: 232 -- id: 158 + - 155 + - 156 + parent: 229 +- id: 155 kind: Literal span: 1:391-392 -- id: 159 +- id: 156 kind: RqOperator span: 1:361-377 targets: - - 161 - - 162 -- id: 161 + - 158 + - 159 +- id: 158 kind: Literal span: 1:370-371 -- id: 162 +- id: 159 kind: Ident span: 1:372-377 ident: !Ident @@ -251,24 +250,24 @@ nodes: - invoices - total targets: - - 121 -- id: 163 + - 118 +- id: 160 kind: RqOperator span: 1:431-443 alias: total_sqrt targets: - - 166 - - 167 - parent: 232 -- id: 166 + - 163 + - 164 + parent: 229 +- id: 163 kind: Literal span: 1:442-443 -- id: 167 +- id: 164 kind: RqOperator span: 1:413-428 targets: - - 169 -- id: 169 + - 166 +- id: 166 kind: Ident span: 1:423-428 ident: !Ident @@ -276,29 +275,29 @@ nodes: - invoices - total targets: - - 121 -- id: 170 + - 118 +- id: 167 kind: RqOperator span: 1:489-501 alias: total_ln targets: - - 173 - - 174 - parent: 232 -- id: 173 + - 170 + - 171 + parent: 229 +- id: 170 kind: Literal span: 1:500-501 -- id: 174 +- id: 171 kind: RqOperator span: 1:478-486 targets: - - 176 -- id: 176 + - 173 +- id: 173 kind: RqOperator span: 1:462-475 targets: - - 178 -- id: 178 + - 175 +- id: 175 kind: Ident span: 1:470-475 ident: !Ident @@ -306,29 +305,29 @@ nodes: - invoices - total targets: - - 121 -- id: 179 + - 118 +- id: 176 kind: RqOperator span: 1:550-562 alias: total_cos targets: - - 182 - - 183 - parent: 232 -- id: 182 + - 179 + - 180 + parent: 229 +- id: 179 kind: Literal span: 1:561-562 -- id: 183 +- id: 180 kind: RqOperator span: 1:538-547 targets: - - 185 -- id: 185 + - 182 +- id: 182 kind: RqOperator span: 1:521-535 targets: - - 187 -- id: 187 + - 184 +- id: 184 kind: Ident span: 1:530-535 ident: !Ident @@ -336,29 +335,29 @@ nodes: - invoices - total targets: - - 121 -- id: 188 + - 118 +- id: 185 kind: RqOperator span: 1:611-623 alias: total_sin targets: - - 191 - - 192 - parent: 232 -- id: 191 + - 188 + - 189 + parent: 229 +- id: 188 kind: Literal span: 1:622-623 -- id: 192 +- id: 189 kind: RqOperator span: 1:599-608 targets: - - 194 -- id: 194 + - 191 +- id: 191 kind: RqOperator span: 1:582-596 targets: - - 196 -- id: 196 + - 193 +- id: 193 kind: Ident span: 1:591-596 ident: !Ident @@ -366,29 +365,29 @@ nodes: - invoices - total targets: - - 121 -- id: 197 + - 118 +- id: 194 kind: RqOperator span: 1:672-684 alias: total_tan targets: - - 200 - - 201 - parent: 232 -- id: 200 + - 197 + - 198 + parent: 229 +- id: 197 kind: Literal span: 1:683-684 -- id: 201 +- id: 198 kind: RqOperator span: 1:660-669 targets: - - 203 -- id: 203 + - 200 +- id: 200 kind: RqOperator span: 1:643-657 targets: - - 205 -- id: 205 + - 202 +- id: 202 kind: Ident span: 1:652-657 ident: !Ident @@ -396,29 +395,29 @@ nodes: - invoices - total targets: - - 121 -- id: 206 + - 118 +- id: 203 kind: RqOperator span: 1:742-754 alias: total_deg targets: - - 209 - - 210 - parent: 232 -- id: 209 + - 206 + - 207 + parent: 229 +- id: 206 kind: Literal span: 1:753-754 -- id: 210 +- id: 207 kind: RqOperator span: 1:727-739 targets: - - 212 -- id: 212 + - 209 +- id: 209 kind: RqOperator span: 1:712-724 targets: - - 214 -- id: 214 + - 211 +- id: 211 kind: Ident span: 1:704-709 ident: !Ident @@ -426,28 +425,28 @@ nodes: - invoices - total targets: - - 121 -- id: 215 + - 118 +- id: 212 kind: RqOperator span: 1:798-810 alias: total_square targets: - - 218 - - 219 - parent: 232 -- id: 218 + - 215 + - 216 + parent: 229 +- id: 215 kind: Literal span: 1:809-810 -- id: 219 +- id: 216 kind: RqOperator span: 1:785-795 targets: - - 222 - - 223 -- id: 222 + - 219 + - 220 +- id: 219 kind: Literal span: 1:794-795 -- id: 223 +- id: 220 kind: Ident span: 1:777-782 ident: !Ident @@ -455,28 +454,28 @@ nodes: - invoices - total targets: - - 121 -- id: 224 + - 118 +- id: 221 kind: RqOperator span: 1:851-863 alias: total_square_op targets: - - 227 - - 228 - parent: 232 -- id: 227 + - 224 + - 225 + parent: 229 +- id: 224 kind: Literal span: 1:862-863 -- id: 228 +- id: 225 kind: RqOperator span: 1:836-848 targets: - - 230 - - 231 -- id: 230 + - 227 + - 228 +- id: 227 kind: Literal span: 1:846-847 -- id: 231 +- id: 228 kind: Ident span: 1:837-842 ident: !Ident @@ -484,32 +483,32 @@ nodes: - invoices - total targets: - - 121 -- id: 232 + - 118 +- id: 229 kind: Tuple span: 1:110-867 children: - - 126 - - 131 + - 123 + - 128 + - 139 - 142 - 145 - - 148 - - 155 - - 163 - - 170 - - 179 - - 188 - - 197 - - 206 - - 215 - - 224 - parent: 233 -- id: 233 + - 152 + - 160 + - 167 + - 176 + - 185 + - 194 + - 203 + - 212 + - 221 + parent: 230 +- id: 230 kind: 'TransformCall: Select' span: 1:103-867 children: - - 124 - - 232 + - 121 + - 229 ast: name: Project stmts: diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__pipelines.snap b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__pipelines.snap index 82e773f63ecb..9b351874a8a5 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__pipelines.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__pipelines.snap @@ -2,16 +2,15 @@ source: prqlc/prqlc/tests/integration/queries.rs expression: "# sqlite:skip (Only works on Sqlite implementations which have the extension\n# installed\n# https://stackoverflow.com/questions/24037982/how-to-use-regexp-in-sqlite)\n\nfrom tracks\n\nfilter (name ~= \"Love\")\nfilter ((milliseconds / 1000 / 60) | in 3..4)\nsort track_id\ntake 1..15\nselect {name, composer}\n" input_file: prqlc/prqlc/tests/integration/queries/pipelines.prql -snapshot_kind: text --- frames: - - 1:179-202 - columns: - !All - input_id: 130 + input_id: 127 except: [] inputs: - - id: 130 + - id: 127 name: tracks table: - default_db @@ -19,10 +18,10 @@ frames: - - 1:203-248 - columns: - !All - input_id: 130 + input_id: 127 except: [] inputs: - - id: 130 + - id: 127 name: tracks table: - default_db @@ -30,10 +29,10 @@ frames: - - 1:249-262 - columns: - !All - input_id: 130 + input_id: 127 except: [] inputs: - - id: 130 + - id: 127 name: tracks table: - default_db @@ -41,10 +40,10 @@ frames: - - 1:263-273 - columns: - !All - input_id: 130 + input_id: 127 except: [] inputs: - - id: 130 + - id: 127 name: tracks table: - default_db @@ -55,36 +54,36 @@ frames: name: - tracks - name - target_id: 164 + target_id: 161 target_name: null - !Single name: - tracks - composer - target_id: 165 + target_id: 162 target_name: null inputs: - - id: 130 + - id: 127 name: tracks table: - default_db - tracks nodes: -- id: 130 +- id: 127 kind: Ident span: 1:166-177 ident: !Ident - default_db - tracks - parent: 136 -- id: 132 + parent: 133 +- id: 129 kind: RqOperator span: 1:187-201 targets: - - 134 - - 135 - parent: 136 -- id: 134 + - 131 + - 132 + parent: 133 +- id: 131 kind: Ident span: 1:187-191 ident: !Ident @@ -92,38 +91,38 @@ nodes: - tracks - name targets: - - 130 -- id: 135 + - 127 +- id: 132 kind: Literal span: 1:195-201 -- id: 136 +- id: 133 kind: 'TransformCall: Filter' span: 1:179-202 children: - - 130 - - 132 - parent: 156 -- id: 140 + - 127 + - 129 + parent: 153 +- id: 137 kind: Literal span: 1:243-244 alias: start -- id: 141 +- id: 138 kind: Literal span: 1:246-247 alias: end -- id: 143 +- id: 140 kind: RqOperator span: 1:211-237 targets: - - 145 - - 149 -- id: 145 + - 142 + - 146 +- id: 142 kind: RqOperator span: 1:212-231 targets: - - 147 - - 148 -- id: 147 + - 144 + - 145 +- id: 144 kind: Ident span: 1:212-224 ident: !Ident @@ -131,38 +130,38 @@ nodes: - tracks - milliseconds targets: - - 130 -- id: 148 + - 127 +- id: 145 kind: Literal span: 1:227-231 -- id: 149 +- id: 146 kind: Literal span: 1:234-236 -- id: 150 +- id: 147 kind: RqOperator span: 1:240-247 targets: - - 152 - - 154 - parent: 156 -- id: 152 + - 149 + - 151 + parent: 153 +- id: 149 kind: RqOperator targets: - - 143 - 140 -- id: 154 + - 137 +- id: 151 kind: RqOperator targets: - - 143 - - 141 -- id: 156 + - 140 + - 138 +- id: 153 kind: 'TransformCall: Filter' span: 1:203-248 children: - - 136 - - 150 - parent: 159 -- id: 157 + - 133 + - 147 + parent: 156 +- id: 154 kind: Ident span: 1:254-262 ident: !Ident @@ -170,34 +169,34 @@ nodes: - tracks - track_id targets: - - 130 - parent: 159 -- id: 159 + - 127 + parent: 156 +- id: 156 kind: 'TransformCall: Sort' span: 1:249-262 children: - - 156 - - 157 - parent: 163 -- id: 160 + - 153 + - 154 + parent: 160 +- id: 157 kind: Literal span: 1:268-269 alias: start - parent: 163 -- id: 161 + parent: 160 +- id: 158 kind: Literal span: 1:271-273 alias: end - parent: 163 -- id: 163 + parent: 160 +- id: 160 kind: 'TransformCall: Take' span: 1:263-273 children: - - 159 - - 160 - - 161 - parent: 167 -- id: 164 + - 156 + - 157 + - 158 + parent: 164 +- id: 161 kind: Ident span: 1:282-286 ident: !Ident @@ -205,9 +204,9 @@ nodes: - tracks - name targets: - - 130 - parent: 166 -- id: 165 + - 127 + parent: 163 +- id: 162 kind: Ident span: 1:288-296 ident: !Ident @@ -215,21 +214,21 @@ nodes: - tracks - composer targets: - - 130 - parent: 166 -- id: 166 + - 127 + parent: 163 +- id: 163 kind: Tuple span: 1:281-297 children: - - 164 - - 165 - parent: 167 -- id: 167 + - 161 + - 162 + parent: 164 +- id: 164 kind: 'TransformCall: Select' span: 1:274-297 children: + - 160 - 163 - - 166 ast: name: Project stmts: diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__read_csv.snap b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__read_csv.snap index 3d5904d16e09..634491b28551 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__read_csv.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__read_csv.snap @@ -2,46 +2,45 @@ source: prqlc/prqlc/tests/integration/queries.rs expression: "# sqlite:skip\n# postgres:skip\n# mysql:skip\nfrom (read_csv \"data_file_root/media_types.csv\")\nsort media_type_id\n" input_file: prqlc/prqlc/tests/integration/queries/read_csv.prql -snapshot_kind: text --- frames: - - 1:92-110 - columns: - !All - input_id: 118 + input_id: 115 except: [] inputs: - - id: 118 - name: _literal_118 + - id: 115 + name: _literal_115 table: - default_db - - _literal_118 + - _literal_115 nodes: -- id: 118 +- id: 115 kind: RqOperator span: 1:43-91 targets: - - 120 - parent: 124 -- id: 120 + - 117 + parent: 121 +- id: 117 kind: Literal span: 1:58-90 -- id: 122 +- id: 119 kind: Ident span: 1:97-110 ident: !Ident - this - - _literal_118 + - _literal_115 - media_type_id targets: - - 118 - parent: 124 -- id: 124 + - 115 + parent: 121 +- id: 121 kind: 'TransformCall: Sort' span: 1:92-110 children: - - 118 - - 122 + - 115 + - 119 ast: name: Project stmts: diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__set_ops_remove.snap b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__set_ops_remove.snap index 65efa04f5543..2e548bca832b 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__set_ops_remove.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__set_ops_remove.snap @@ -2,7 +2,6 @@ source: prqlc/prqlc/tests/integration/queries.rs expression: "# mssql:test\nlet distinct = rel -> (from t = _param.rel | group {t.*} (take 1))\n\nfrom_text format:json '{ \"columns\": [\"a\"], \"data\": [[1], [2], [2], [3]] }'\ndistinct\nremove (from_text format:json '{ \"columns\": [\"a\"], \"data\": [[1], [2]] }')\nsort a\n" input_file: prqlc/prqlc/tests/integration/queries/set_ops_remove.prql -snapshot_kind: text --- frames: - - 1:71-77 @@ -11,215 +10,215 @@ frames: name: - t - a - target_id: 136 + target_id: 133 target_name: null inputs: - - id: 127 + - id: 124 name: t table: - default_db - - _literal_127 -- - 0:3606-3683 + - _literal_124 +- - 0:3163-3240 - columns: - !Single name: - t - a - target_id: 136 + target_id: 133 target_name: null - !Single name: - b - a - target_id: 122 + target_id: 119 target_name: a inputs: - - id: 127 + - id: 124 name: t table: - default_db - - _literal_127 - - id: 122 + - _literal_124 + - id: 119 name: b table: - default_db - - _literal_122 -- - 0:3686-3731 + - _literal_119 +- - 0:3243-3288 - columns: - !Single name: - t - a - target_id: 136 + target_id: 133 target_name: null - !Single name: - b - a - target_id: 122 + target_id: 119 target_name: a inputs: - - id: 127 + - id: 124 name: t table: - default_db - - _literal_127 - - id: 122 + - _literal_124 + - id: 119 name: b table: - default_db - - _literal_122 + - _literal_119 - - 1:165-238 - columns: - !Single name: - t - a - target_id: 207 + target_id: 204 target_name: null inputs: - - id: 127 + - id: 124 name: t table: - default_db - - _literal_127 - - id: 122 + - _literal_124 + - id: 119 name: b table: - default_db - - _literal_122 + - _literal_119 - - 1:239-245 - columns: - !Single name: - t - a - target_id: 207 + target_id: 204 target_name: null inputs: - - id: 127 + - id: 124 name: t table: - default_db - - _literal_127 - - id: 122 + - _literal_124 + - id: 119 name: b table: - default_db - - _literal_122 + - _literal_119 nodes: -- id: 122 +- id: 119 kind: Array span: 1:173-237 - parent: 189 -- id: 127 + parent: 186 +- id: 124 kind: Array span: 1:36-55 - parent: 154 -- id: 136 + parent: 151 +- id: 133 kind: Ident ident: !Ident - this - t - a targets: - - 127 - parent: 138 -- id: 138 + - 124 + parent: 135 +- id: 135 kind: Tuple span: 1:64-69 children: - - 136 -- id: 154 + - 133 +- id: 151 kind: 'TransformCall: Take' span: 1:71-77 children: - - 127 - - 155 - parent: 189 -- id: 155 + - 124 + - 152 + parent: 186 +- id: 152 kind: Literal - parent: 154 -- id: 178 + parent: 151 +- id: 175 kind: Ident ident: !Ident - this - t - a targets: - - 136 -- id: 181 + - 133 +- id: 178 kind: Ident ident: !Ident - that - b - a targets: - - 122 -- id: 187 + - 119 +- id: 184 kind: RqOperator - span: 0:3635-3682 + span: 0:3192-3239 targets: + - 175 - 178 - - 181 - parent: 189 -- id: 189 + parent: 186 +- id: 186 kind: 'TransformCall: Join' - span: 0:3606-3683 + span: 0:3163-3240 children: - - 154 - - 122 - - 187 - parent: 205 -- id: 197 + - 151 + - 119 + - 184 + parent: 202 +- id: 194 kind: Ident - span: 0:6789-6791 + span: 0:5987-5989 ident: !Ident - this - b - a targets: - - 122 -- id: 201 + - 119 +- id: 198 kind: RqOperator - span: 0:3694-3730 + span: 0:3251-3287 targets: - - 197 - - 204 - parent: 205 -- id: 204 + - 194 + - 201 + parent: 202 +- id: 201 kind: Literal - span: 0:6795-6799 -- id: 205 + span: 0:5993-5997 +- id: 202 kind: 'TransformCall: Filter' - span: 0:3686-3731 + span: 0:3243-3288 children: - - 189 - - 201 - parent: 209 -- id: 207 + - 186 + - 198 + parent: 206 +- id: 204 kind: Ident ident: !Ident - this - t - a targets: - - 136 - parent: 208 -- id: 208 + - 133 + parent: 205 +- id: 205 kind: Tuple - span: 0:3742-3744 + span: 0:3299-3301 children: - - 207 - parent: 209 -- id: 209 + - 204 + parent: 206 +- id: 206 kind: 'TransformCall: Select' span: 1:165-238 children: + - 202 - 205 - - 208 - parent: 212 -- id: 210 + parent: 209 +- id: 207 kind: Ident span: 1:244-245 ident: !Ident @@ -227,14 +226,14 @@ nodes: - t - a targets: - - 207 - parent: 212 -- id: 212 + - 204 + parent: 209 +- id: 209 kind: 'TransformCall: Sort' span: 1:239-245 children: - - 209 - - 210 + - 206 + - 207 ast: name: Project stmts: diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__sort.snap b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__sort.snap index 57e2f049bf64..5023412d7b6c 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__sort.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__sort.snap @@ -2,16 +2,15 @@ source: prqlc/prqlc/tests/integration/queries.rs expression: "# mssql:test\nfrom e=employees\nfilter first_name != \"Mitchell\"\nsort {first_name, last_name}\n\n# joining may use HashMerge, which can undo ORDER BY\njoin manager=employees side:left (e.reports_to == manager.employee_id)\n\nselect {e.first_name, e.last_name, manager.first_name}\n" input_file: prqlc/prqlc/tests/integration/queries/sort.prql -snapshot_kind: text --- frames: - - 1:30-61 - columns: - !All - input_id: 128 + input_id: 125 except: [] inputs: - - id: 128 + - id: 125 name: e table: - default_db @@ -19,10 +18,10 @@ frames: - - 1:62-90 - columns: - !All - input_id: 128 + input_id: 125 except: [] inputs: - - id: 128 + - id: 125 name: e table: - default_db @@ -30,18 +29,18 @@ frames: - - 1:145-215 - columns: - !All - input_id: 128 + input_id: 125 except: [] - !All - input_id: 119 + input_id: 116 except: [] inputs: - - id: 128 + - id: 125 name: e table: - default_db - employees - - id: 119 + - id: 116 name: manager table: - default_db @@ -50,54 +49,54 @@ frames: - columns: - !Single name: null - target_id: 144 + target_id: 141 target_name: null - !Single name: - e - last_name - target_id: 145 + target_id: 142 target_name: null - !Single name: - manager - first_name - target_id: 146 + target_id: 143 target_name: null inputs: - - id: 128 + - id: 125 name: e table: - default_db - employees - - id: 119 + - id: 116 name: manager table: - default_db - employees nodes: -- id: 119 +- id: 116 kind: Ident span: 1:158-167 ident: !Ident - default_db - employees - parent: 143 -- id: 128 + parent: 140 +- id: 125 kind: Ident span: 1:13-29 ident: !Ident - default_db - employees - parent: 134 -- id: 130 + parent: 131 +- id: 127 kind: RqOperator span: 1:37-61 targets: - - 132 - - 133 - parent: 134 -- id: 132 + - 129 + - 130 + parent: 131 +- id: 129 kind: Ident span: 1:37-47 ident: !Ident @@ -105,18 +104,18 @@ nodes: - e - first_name targets: - - 128 -- id: 133 + - 125 +- id: 130 kind: Literal span: 1:51-61 -- id: 134 +- id: 131 kind: 'TransformCall: Filter' span: 1:30-61 children: - - 128 - - 130 - parent: 138 -- id: 135 + - 125 + - 127 + parent: 135 +- id: 132 kind: Ident span: 1:68-78 ident: !Ident @@ -124,9 +123,9 @@ nodes: - e - first_name targets: - - 128 - parent: 138 -- id: 136 + - 125 + parent: 135 +- id: 133 kind: Ident span: 1:80-89 ident: !Ident @@ -134,24 +133,24 @@ nodes: - e - last_name targets: - - 128 - parent: 138 -- id: 138 + - 125 + parent: 135 +- id: 135 kind: 'TransformCall: Sort' span: 1:62-90 children: - - 134 - - 135 - - 136 - parent: 143 -- id: 139 + - 131 + - 132 + - 133 + parent: 140 +- id: 136 kind: RqOperator span: 1:179-214 targets: - - 141 - - 142 - parent: 143 -- id: 141 + - 138 + - 139 + parent: 140 +- id: 138 kind: Ident span: 1:180-191 ident: !Ident @@ -159,8 +158,8 @@ nodes: - e - reports_to targets: - - 128 -- id: 142 + - 125 +- id: 139 kind: Ident span: 1:202-214 ident: !Ident @@ -168,16 +167,16 @@ nodes: - manager - employee_id targets: - - 119 -- id: 143 + - 116 +- id: 140 kind: 'TransformCall: Join' span: 1:145-215 children: - - 138 - - 119 - - 139 - parent: 148 -- id: 144 + - 135 + - 116 + - 136 + parent: 145 +- id: 141 kind: Ident span: 1:225-237 ident: !Ident @@ -185,9 +184,9 @@ nodes: - e - first_name targets: - - 128 - parent: 147 -- id: 145 + - 125 + parent: 144 +- id: 142 kind: Ident span: 1:239-250 ident: !Ident @@ -195,9 +194,9 @@ nodes: - e - last_name targets: - - 128 - parent: 147 -- id: 146 + - 125 + parent: 144 +- id: 143 kind: Ident span: 1:252-270 ident: !Ident @@ -205,22 +204,22 @@ nodes: - manager - first_name targets: - - 119 - parent: 147 -- id: 147 + - 116 + parent: 144 +- id: 144 kind: Tuple span: 1:224-271 children: - - 144 - - 145 - - 146 - parent: 148 -- id: 148 + - 141 + - 142 + - 143 + parent: 145 +- id: 145 kind: 'TransformCall: Select' span: 1:217-271 children: - - 143 - - 147 + - 140 + - 144 ast: name: Project stmts: diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__sort_2.snap b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__sort_2.snap index d82e10428bda..9fff45e182ca 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__sort_2.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__sort_2.snap @@ -9,16 +9,16 @@ frames: - !Single name: - AA - target_id: 130 + target_id: 127 target_name: null - !Single name: - albums - artist_id - target_id: 131 + target_id: 128 target_name: null inputs: - - id: 128 + - id: 125 name: albums table: - default_db @@ -28,16 +28,16 @@ frames: - !Single name: - AA - target_id: 130 + target_id: 127 target_name: null - !Single name: - albums - artist_id - target_id: 131 + target_id: 128 target_name: null inputs: - - id: 128 + - id: 125 name: albums table: - default_db @@ -47,16 +47,16 @@ frames: - !Single name: - AA - target_id: 130 + target_id: 127 target_name: null - !Single name: - albums - artist_id - target_id: 131 + target_id: 128 target_name: null inputs: - - id: 128 + - id: 125 name: albums table: - default_db @@ -66,44 +66,44 @@ frames: - !Single name: - AA - target_id: 130 + target_id: 127 target_name: null - !Single name: - albums - artist_id - target_id: 131 + target_id: 128 target_name: null - !All - input_id: 116 + input_id: 113 except: [] inputs: - - id: 128 + - id: 125 name: albums table: - default_db - albums - - id: 116 + - id: 113 name: artists table: - default_db - artists nodes: -- id: 116 +- id: 113 kind: Ident span: 1:75-82 ident: !Ident - default_db - artists - parent: 146 -- id: 128 + parent: 143 +- id: 125 kind: Ident span: 1:0-11 ident: !Ident - default_db - albums - parent: 133 -- id: 130 + parent: 130 +- id: 127 kind: Ident span: 1:24-32 alias: AA @@ -112,9 +112,9 @@ nodes: - albums - album_id targets: - - 128 - parent: 132 -- id: 131 + - 125 + parent: 129 +- id: 128 kind: Ident span: 1:34-43 ident: !Ident @@ -122,71 +122,71 @@ nodes: - albums - artist_id targets: - - 128 - parent: 132 -- id: 132 + - 125 + parent: 129 +- id: 129 kind: Tuple span: 1:19-45 children: - - 130 - - 131 - parent: 133 -- id: 133 + - 127 + - 128 + parent: 130 +- id: 130 kind: 'TransformCall: Select' span: 1:12-45 children: - - 128 - - 132 - parent: 136 -- id: 134 + - 125 + - 129 + parent: 133 +- id: 131 kind: Ident span: 1:51-53 ident: !Ident - this - AA targets: - - 130 - parent: 136 -- id: 136 + - 127 + parent: 133 +- id: 133 kind: 'TransformCall: Sort' span: 1:46-53 children: - - 133 - - 134 - parent: 141 -- id: 137 + - 130 + - 131 + parent: 138 +- id: 134 kind: RqOperator span: 1:61-69 targets: - - 139 - - 140 - parent: 141 -- id: 139 + - 136 + - 137 + parent: 138 +- id: 136 kind: Ident span: 1:61-63 ident: !Ident - this - AA targets: - - 130 -- id: 140 + - 127 +- id: 137 kind: Literal span: 1:67-69 -- id: 141 +- id: 138 kind: 'TransformCall: Filter' span: 1:54-69 children: - - 136 - - 137 - parent: 146 -- id: 142 + - 133 + - 134 + parent: 143 +- id: 139 kind: RqOperator span: 1:84-95 targets: - - 144 - - 145 - parent: 146 -- id: 144 + - 141 + - 142 + parent: 143 +- id: 141 kind: Ident span: 1:86-95 ident: !Ident @@ -194,8 +194,8 @@ nodes: - albums - artist_id targets: - - 131 -- id: 145 + - 128 +- id: 142 kind: Ident span: 1:86-95 ident: !Ident @@ -203,14 +203,14 @@ nodes: - artists - artist_id targets: - - 116 -- id: 146 + - 113 +- id: 143 kind: 'TransformCall: Join' span: 1:70-96 children: - - 141 - - 116 - - 142 + - 138 + - 113 + - 139 ast: name: Project stmts: diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__switch.snap b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__switch.snap index 891285113096..db00f014cb6e 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__switch.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__switch.snap @@ -2,16 +2,15 @@ source: prqlc/prqlc/tests/integration/queries.rs expression: "# glaredb:skip (May be a bag of String type conversion for Postgres Client)\n# mssql:test\nfrom tracks\nsort milliseconds\nselect display = case [\n composer != null => composer,\n genre_id < 17 => 'no composer',\n true => f'unknown composer'\n]\ntake 10\n" input_file: prqlc/prqlc/tests/integration/queries/switch.prql -snapshot_kind: text --- frames: - - 1:101-118 - columns: - !All - input_id: 124 + input_id: 121 except: [] inputs: - - id: 124 + - id: 121 name: tracks table: - default_db @@ -21,10 +20,10 @@ frames: - !Single name: - display - target_id: 129 + target_id: 126 target_name: null inputs: - - id: 124 + - id: 121 name: tracks table: - default_db @@ -34,23 +33,23 @@ frames: - !Single name: - display - target_id: 129 + target_id: 126 target_name: null inputs: - - id: 124 + - id: 121 name: tracks table: - default_db - tracks nodes: -- id: 124 +- id: 121 kind: Ident span: 1:89-100 ident: !Ident - default_db - tracks - parent: 128 -- id: 126 + parent: 125 +- id: 123 kind: Ident span: 1:106-118 ident: !Ident @@ -58,34 +57,34 @@ nodes: - tracks - milliseconds targets: - - 124 - parent: 128 -- id: 128 + - 121 + parent: 125 +- id: 125 kind: 'TransformCall: Sort' span: 1:101-118 children: - - 124 - - 126 - parent: 143 -- id: 129 + - 121 + - 123 + parent: 140 +- id: 126 kind: Case span: 1:136-246 alias: display targets: - - 130 - - 134 - - 135 - - 139 - - 140 - - 141 - parent: 142 -- id: 130 + - 127 + - 131 + - 132 + - 136 + - 137 + - 138 + parent: 139 +- id: 127 kind: RqOperator span: 1:147-163 targets: - - 132 - - 133 -- id: 132 + - 129 + - 130 +- id: 129 kind: Ident span: 1:147-155 ident: !Ident @@ -93,11 +92,11 @@ nodes: - tracks - composer targets: - - 124 -- id: 133 + - 121 +- id: 130 kind: Literal span: 1:159-163 -- id: 134 +- id: 131 kind: Ident span: 1:167-175 ident: !Ident @@ -105,14 +104,14 @@ nodes: - tracks - composer targets: - - 124 -- id: 135 + - 121 +- id: 132 kind: RqOperator span: 1:181-194 targets: - - 137 - - 138 -- id: 137 + - 134 + - 135 +- id: 134 kind: Ident span: 1:181-189 ident: !Ident @@ -120,41 +119,41 @@ nodes: - tracks - genre_id targets: - - 124 -- id: 138 + - 121 +- id: 135 kind: Literal span: 1:192-194 -- id: 139 +- id: 136 kind: Literal span: 1:198-211 -- id: 140 +- id: 137 kind: Literal span: 1:217-221 -- id: 141 +- id: 138 kind: FString span: 1:225-244 -- id: 142 +- id: 139 kind: Tuple span: 1:136-246 children: - - 129 - parent: 143 -- id: 143 + - 126 + parent: 140 +- id: 140 kind: 'TransformCall: Select' span: 1:119-246 children: - - 128 - - 142 - parent: 145 -- id: 145 + - 125 + - 139 + parent: 142 +- id: 142 kind: 'TransformCall: Take' span: 1:247-254 children: + - 140 - 143 - - 146 -- id: 146 +- id: 143 kind: Literal - parent: 145 + parent: 142 ast: name: Project stmts: diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__take.snap b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__take.snap index 93135944f5f1..1a26c4cb9b17 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__take.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__take.snap @@ -2,16 +2,15 @@ source: prqlc/prqlc/tests/integration/queries.rs expression: "# mssql:test\nfrom tracks\nsort {+track_id}\ntake 3..5\n" input_file: prqlc/prqlc/tests/integration/queries/take.prql -snapshot_kind: text --- frames: - - 1:25-41 - columns: - !All - input_id: 121 + input_id: 118 except: [] inputs: - - id: 121 + - id: 118 name: tracks table: - default_db @@ -19,23 +18,23 @@ frames: - - 1:42-51 - columns: - !All - input_id: 121 + input_id: 118 except: [] inputs: - - id: 121 + - id: 118 name: tracks table: - default_db - tracks nodes: -- id: 121 +- id: 118 kind: Ident span: 1:13-24 ident: !Ident - default_db - tracks - parent: 125 -- id: 123 + parent: 122 +- id: 120 kind: Ident span: 1:31-40 ident: !Ident @@ -43,32 +42,32 @@ nodes: - tracks - track_id targets: - - 121 - parent: 125 -- id: 125 + - 118 + parent: 122 +- id: 122 kind: 'TransformCall: Sort' span: 1:25-41 children: - - 121 - - 123 - parent: 129 -- id: 126 + - 118 + - 120 + parent: 126 +- id: 123 kind: Literal span: 1:47-48 alias: start - parent: 129 -- id: 127 + parent: 126 +- id: 124 kind: Literal span: 1:50-51 alias: end - parent: 129 -- id: 129 + parent: 126 +- id: 126 kind: 'TransformCall: Take' span: 1:42-51 children: - - 125 - - 126 - - 127 + - 122 + - 123 + - 124 ast: name: Project stmts: diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__text_module.snap b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__text_module.snap index 241537e8be3c..1aa0c0af1c1b 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__text_module.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__text_module.snap @@ -2,7 +2,6 @@ source: prqlc/prqlc/tests/integration/queries.rs expression: "# mssql:test\n# glaredb:skip — TODO: started raising an error on 2024-05-20; see `window.prql`\n# for more details\nfrom albums\nselect {\n title,\n title_and_spaces = f\" {title} \",\n low = (title | text.lower),\n up = (title | text.upper),\n ltrimmed = (title | text.ltrim),\n rtrimmed = (title | text.rtrim),\n trimmed = (title | text.trim),\n len = (title | text.length),\n subs = (title | text.extract 2 5),\n replace = (title | text.replace \"al\" \"PIKA\"),\n}\nsort {title}\nfilter (title | text.starts_with \"Black\") || (title | text.contains \"Sabbath\") || (title | text.ends_with \"os\")\n" input_file: prqlc/prqlc/tests/integration/queries/text_module.prql -snapshot_kind: text --- frames: - - 1:125-479 @@ -11,55 +10,55 @@ frames: name: - albums - title - target_id: 126 + target_id: 123 target_name: null - !Single name: - title_and_spaces - target_id: 127 + target_id: 124 target_name: null - !Single name: - low - target_id: 129 + target_id: 126 target_name: null - !Single name: - up - target_id: 132 + target_id: 129 target_name: null - !Single name: - ltrimmed - target_id: 135 + target_id: 132 target_name: null - !Single name: - rtrimmed - target_id: 138 + target_id: 135 target_name: null - !Single name: - trimmed - target_id: 141 + target_id: 138 target_name: null - !Single name: - len - target_id: 144 + target_id: 141 target_name: null - !Single name: - subs - target_id: 147 + target_id: 144 target_name: null - !Single name: - replace - target_id: 153 + target_id: 150 target_name: null inputs: - - id: 124 + - id: 121 name: albums table: - default_db @@ -70,55 +69,55 @@ frames: name: - albums - title - target_id: 126 + target_id: 123 target_name: null - !Single name: - title_and_spaces - target_id: 127 + target_id: 124 target_name: null - !Single name: - low - target_id: 129 + target_id: 126 target_name: null - !Single name: - up - target_id: 132 + target_id: 129 target_name: null - !Single name: - ltrimmed - target_id: 135 + target_id: 132 target_name: null - !Single name: - rtrimmed - target_id: 138 + target_id: 135 target_name: null - !Single name: - trimmed - target_id: 141 + target_id: 138 target_name: null - !Single name: - len - target_id: 144 + target_id: 141 target_name: null - !Single name: - subs - target_id: 147 + target_id: 144 target_name: null - !Single name: - replace - target_id: 153 + target_id: 150 target_name: null inputs: - - id: 124 + - id: 121 name: albums table: - default_db @@ -129,68 +128,68 @@ frames: name: - albums - title - target_id: 126 + target_id: 123 target_name: null - !Single name: - title_and_spaces - target_id: 127 + target_id: 124 target_name: null - !Single name: - low - target_id: 129 + target_id: 126 target_name: null - !Single name: - up - target_id: 132 + target_id: 129 target_name: null - !Single name: - ltrimmed - target_id: 135 + target_id: 132 target_name: null - !Single name: - rtrimmed - target_id: 138 + target_id: 135 target_name: null - !Single name: - trimmed - target_id: 141 + target_id: 138 target_name: null - !Single name: - len - target_id: 144 + target_id: 141 target_name: null - !Single name: - subs - target_id: 147 + target_id: 144 target_name: null - !Single name: - replace - target_id: 153 + target_id: 150 target_name: null inputs: - - id: 124 + - id: 121 name: albums table: - default_db - albums nodes: -- id: 124 +- id: 121 kind: Ident span: 1:113-124 ident: !Ident - default_db - albums - parent: 160 -- id: 126 + parent: 157 +- id: 123 kind: Ident span: 1:138-143 ident: !Ident @@ -198,16 +197,16 @@ nodes: - albums - title targets: - - 124 - parent: 159 -- id: 127 + - 121 + parent: 156 +- id: 124 kind: FString span: 1:168-182 alias: title_and_spaces targets: - - 128 - parent: 159 -- id: 128 + - 125 + parent: 156 +- id: 125 kind: Ident span: 1:173-178 ident: !Ident @@ -215,15 +214,15 @@ nodes: - albums - title targets: - - 124 -- id: 129 + - 121 +- id: 126 kind: RqOperator span: 1:203-213 alias: low targets: - - 131 - parent: 159 -- id: 131 + - 128 + parent: 156 +- id: 128 kind: Ident span: 1:195-200 ident: !Ident @@ -231,15 +230,15 @@ nodes: - albums - title targets: - - 124 -- id: 132 + - 121 +- id: 129 kind: RqOperator span: 1:234-244 alias: up targets: - - 134 - parent: 159 -- id: 134 + - 131 + parent: 156 +- id: 131 kind: Ident span: 1:226-231 ident: !Ident @@ -247,15 +246,15 @@ nodes: - albums - title targets: - - 124 -- id: 135 + - 121 +- id: 132 kind: RqOperator span: 1:271-281 alias: ltrimmed targets: - - 137 - parent: 159 -- id: 137 + - 134 + parent: 156 +- id: 134 kind: Ident span: 1:263-268 ident: !Ident @@ -263,15 +262,15 @@ nodes: - albums - title targets: - - 124 -- id: 138 + - 121 +- id: 135 kind: RqOperator span: 1:308-318 alias: rtrimmed targets: - - 140 - parent: 159 -- id: 140 + - 137 + parent: 156 +- id: 137 kind: Ident span: 1:300-305 ident: !Ident @@ -279,15 +278,15 @@ nodes: - albums - title targets: - - 124 -- id: 141 + - 121 +- id: 138 kind: RqOperator span: 1:344-353 alias: trimmed targets: - - 143 - parent: 159 -- id: 143 + - 140 + parent: 156 +- id: 140 kind: Ident span: 1:336-341 ident: !Ident @@ -295,15 +294,15 @@ nodes: - albums - title targets: - - 124 -- id: 144 + - 121 +- id: 141 kind: RqOperator span: 1:375-386 alias: len targets: - - 146 - parent: 159 -- id: 146 + - 143 + parent: 156 +- id: 143 kind: Ident span: 1:367-372 ident: !Ident @@ -311,23 +310,23 @@ nodes: - albums - title targets: - - 124 -- id: 147 + - 121 +- id: 144 kind: RqOperator span: 1:409-425 alias: subs targets: - - 150 - - 151 - - 152 - parent: 159 -- id: 150 + - 147 + - 148 + - 149 + parent: 156 +- id: 147 kind: Literal span: 1:422-423 -- id: 151 +- id: 148 kind: Literal span: 1:424-425 -- id: 152 +- id: 149 kind: Ident span: 1:401-406 ident: !Ident @@ -335,23 +334,23 @@ nodes: - albums - title targets: - - 124 -- id: 153 + - 121 +- id: 150 kind: RqOperator span: 1:451-475 alias: replace targets: - - 156 - - 157 - - 158 - parent: 159 -- id: 156 + - 153 + - 154 + - 155 + parent: 156 +- id: 153 kind: Literal span: 1:464-468 -- id: 157 +- id: 154 kind: Literal span: 1:469-475 -- id: 158 +- id: 155 kind: Ident span: 1:443-448 ident: !Ident @@ -359,30 +358,30 @@ nodes: - albums - title targets: - - 124 -- id: 159 + - 121 +- id: 156 kind: Tuple span: 1:132-479 children: + - 123 + - 124 - 126 - - 127 - 129 - 132 - 135 - 138 - 141 - 144 - - 147 - - 153 - parent: 160 -- id: 160 + - 150 + parent: 157 +- id: 157 kind: 'TransformCall: Select' span: 1:125-479 children: - - 124 - - 159 - parent: 163 -- id: 161 + - 121 + - 156 + parent: 160 +- id: 158 kind: Ident span: 1:486-491 ident: !Ident @@ -390,38 +389,38 @@ nodes: - albums - title targets: - - 126 - parent: 163 -- id: 163 + - 123 + parent: 160 +- id: 160 kind: 'TransformCall: Sort' span: 1:480-492 children: - - 160 - - 161 - parent: 183 -- id: 164 + - 157 + - 158 + parent: 180 +- id: 161 kind: RqOperator span: 1:500-604 targets: - - 166 - - 178 - parent: 183 -- id: 166 + - 163 + - 175 + parent: 180 +- id: 163 kind: RqOperator span: 1:500-571 targets: - - 168 - - 173 -- id: 168 + - 165 + - 170 +- id: 165 kind: RqOperator span: 1:509-533 targets: - - 171 - - 172 -- id: 171 + - 168 + - 169 +- id: 168 kind: Literal span: 1:526-533 -- id: 172 +- id: 169 kind: Ident span: 1:501-506 ident: !Ident @@ -429,17 +428,17 @@ nodes: - albums - title targets: - - 126 -- id: 173 + - 123 +- id: 170 kind: RqOperator span: 1:547-570 targets: - - 176 - - 177 -- id: 176 + - 173 + - 174 +- id: 173 kind: Literal span: 1:561-570 -- id: 177 +- id: 174 kind: Ident span: 1:539-544 ident: !Ident @@ -447,17 +446,17 @@ nodes: - albums - title targets: - - 126 -- id: 178 + - 123 +- id: 175 kind: RqOperator span: 1:584-603 targets: - - 181 - - 182 -- id: 181 + - 178 + - 179 +- id: 178 kind: Literal span: 1:599-603 -- id: 182 +- id: 179 kind: Ident span: 1:576-581 ident: !Ident @@ -465,13 +464,13 @@ nodes: - albums - title targets: - - 126 -- id: 183 + - 123 +- id: 180 kind: 'TransformCall: Filter' span: 1:493-604 children: - - 163 - - 164 + - 160 + - 161 ast: name: Project stmts: diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__window.snap b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__window.snap index f79934ec92cd..0b58b9d7bd95 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__window.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__window.snap @@ -2,32 +2,31 @@ source: prqlc/prqlc/tests/integration/queries.rs expression: "# clickhouse:skip problems with DISTINCT ON\n# glaredb:skip — TODO: started raising an error on 2024-05-20, from https://github.com/PRQL/prql/actions/runs/9154902656/job/25198160283:\n # ERROR: This feature is not implemented: Unsupported ast node in sqltorel:\n # Substring { expr: Identifier(Ident { value: \"title\", quote_style: None }),\n # substring_from: Some(Value(Number(\"2\", false))), substring_for:\n # Some(Value(Number(\"5\", false))), special: true }\nfrom tracks\ngroup genre_id (\n sort milliseconds\n derive {\n num = row_number this,\n total = count this,\n last_val = last track_id,\n }\n take 10\n)\nsort {genre_id, milliseconds}\nselect {track_id, genre_id, num, total, last_val}\nfilter genre_id >= 22\n" input_file: prqlc/prqlc/tests/integration/queries/window.prql -snapshot_kind: text --- frames: - - 1:519-612 - columns: - !All - input_id: 127 + input_id: 124 except: - genre_id - !Single name: - num - target_id: 165 + target_id: 162 target_name: null - !Single name: - total - target_id: 173 + target_id: 170 target_name: null - !Single name: - last_val - target_id: 175 + target_id: 172 target_name: null inputs: - - id: 127 + - id: 124 name: tracks table: - default_db @@ -38,29 +37,29 @@ frames: name: - tracks - genre_id - target_id: 129 + target_id: 126 target_name: null - !All - input_id: 127 + input_id: 124 except: - genre_id - !Single name: - num - target_id: 165 + target_id: 162 target_name: null - !Single name: - total - target_id: 173 + target_id: 170 target_name: null - !Single name: - last_val - target_id: 175 + target_id: 172 target_name: null inputs: - - id: 127 + - id: 124 name: tracks table: - default_db @@ -71,29 +70,29 @@ frames: name: - tracks - genre_id - target_id: 129 + target_id: 126 target_name: null - !All - input_id: 127 + input_id: 124 except: - genre_id - !Single name: - num - target_id: 165 + target_id: 162 target_name: null - !Single name: - total - target_id: 173 + target_id: 170 target_name: null - !Single name: - last_val - target_id: 175 + target_id: 172 target_name: null inputs: - - id: 127 + - id: 124 name: tracks table: - default_db @@ -104,31 +103,31 @@ frames: name: - tracks - track_id - target_id: 189 + target_id: 186 target_name: null - !Single name: - tracks - genre_id - target_id: 190 + target_id: 187 target_name: null - !Single name: - num - target_id: 191 + target_id: 188 target_name: null - !Single name: - total - target_id: 192 + target_id: 189 target_name: null - !Single name: - last_val - target_id: 193 + target_id: 190 target_name: null inputs: - - id: 127 + - id: 124 name: tracks table: - default_db @@ -139,44 +138,44 @@ frames: name: - tracks - track_id - target_id: 189 + target_id: 186 target_name: null - !Single name: - tracks - genre_id - target_id: 190 + target_id: 187 target_name: null - !Single name: - num - target_id: 191 + target_id: 188 target_name: null - !Single name: - total - target_id: 192 + target_id: 189 target_name: null - !Single name: - last_val - target_id: 193 + target_id: 190 target_name: null inputs: - - id: 127 + - id: 124 name: tracks table: - default_db - tracks nodes: -- id: 127 +- id: 124 kind: Ident span: 1:468-479 ident: !Ident - default_db - tracks - parent: 179 -- id: 129 + parent: 176 +- id: 126 kind: Ident span: 1:486-494 ident: !Ident @@ -184,14 +183,14 @@ nodes: - tracks - genre_id targets: - - 127 - parent: 138 -- id: 138 + - 124 + parent: 135 +- id: 135 kind: Tuple span: 1:486-494 children: - - 129 -- id: 157 + - 126 +- id: 154 kind: Ident span: 1:504-516 ident: !Ident @@ -199,33 +198,33 @@ nodes: - tracks - milliseconds targets: - - 127 -- id: 165 + - 124 +- id: 162 kind: RqOperator span: 1:538-553 alias: num targets: - - 166 - parent: 178 -- id: 166 + - 163 + parent: 175 +- id: 163 kind: Literal -- id: 173 +- id: 170 kind: RqOperator span: 1:567-577 alias: total targets: - - 174 - parent: 178 -- id: 174 + - 171 + parent: 175 +- id: 171 kind: Literal -- id: 175 +- id: 172 kind: RqOperator span: 1:594-607 alias: last_val targets: - - 177 - parent: 178 -- id: 177 + - 174 + parent: 175 +- id: 174 kind: Ident span: 1:599-607 ident: !Ident @@ -233,33 +232,33 @@ nodes: - tracks - track_id targets: - - 127 -- id: 178 + - 124 +- id: 175 kind: Tuple span: 1:526-612 children: - - 165 - - 173 - - 175 - parent: 179 -- id: 179 + - 162 + - 170 + - 172 + parent: 176 +- id: 176 kind: 'TransformCall: Derive' span: 1:519-612 children: - - 127 - - 178 - parent: 181 -- id: 181 + - 124 + - 175 + parent: 178 +- id: 178 kind: 'TransformCall: Take' span: 1:615-622 children: + - 176 - 179 - - 182 - parent: 188 -- id: 182 + parent: 185 +- id: 179 kind: Literal - parent: 181 -- id: 185 + parent: 178 +- id: 182 kind: Ident span: 1:631-639 ident: !Ident @@ -267,9 +266,9 @@ nodes: - tracks - genre_id targets: - - 129 - parent: 188 -- id: 186 + - 126 + parent: 185 +- id: 183 kind: Ident span: 1:641-653 ident: !Ident @@ -277,17 +276,17 @@ nodes: - tracks - milliseconds targets: - - 127 - parent: 188 -- id: 188 + - 124 + parent: 185 +- id: 185 kind: 'TransformCall: Sort' span: 1:625-654 children: - - 181 - - 185 - - 186 - parent: 195 -- id: 189 + - 178 + - 182 + - 183 + parent: 192 +- id: 186 kind: Ident span: 1:663-671 ident: !Ident @@ -295,9 +294,9 @@ nodes: - tracks - track_id targets: - - 127 - parent: 194 -- id: 190 + - 124 + parent: 191 +- id: 187 kind: Ident span: 1:673-681 ident: !Ident @@ -305,60 +304,60 @@ nodes: - tracks - genre_id targets: - - 129 - parent: 194 -- id: 191 + - 126 + parent: 191 +- id: 188 kind: Ident span: 1:683-686 ident: !Ident - this - num targets: - - 165 - parent: 194 -- id: 192 + - 162 + parent: 191 +- id: 189 kind: Ident span: 1:688-693 ident: !Ident - this - total targets: - - 173 - parent: 194 -- id: 193 + - 170 + parent: 191 +- id: 190 kind: Ident span: 1:695-703 ident: !Ident - this - last_val targets: - - 175 - parent: 194 -- id: 194 + - 172 + parent: 191 +- id: 191 kind: Tuple span: 1:662-704 children: + - 186 + - 187 + - 188 - 189 - 190 - - 191 - - 192 - - 193 - parent: 195 -- id: 195 + parent: 192 +- id: 192 kind: 'TransformCall: Select' span: 1:655-704 children: - - 188 - - 194 - parent: 200 -- id: 196 + - 185 + - 191 + parent: 197 +- id: 193 kind: RqOperator span: 1:712-726 targets: - - 198 - - 199 - parent: 200 -- id: 198 + - 195 + - 196 + parent: 197 +- id: 195 kind: Ident span: 1:712-720 ident: !Ident @@ -366,16 +365,16 @@ nodes: - tracks - genre_id targets: - - 190 -- id: 199 + - 187 +- id: 196 kind: Literal span: 1:724-726 -- id: 200 +- id: 197 kind: 'TransformCall: Filter' span: 1:705-726 children: - - 195 - - 196 + - 192 + - 193 ast: name: Project stmts: diff --git a/prqlc/prqlc/tests/integration/sql.rs b/prqlc/prqlc/tests/integration/sql.rs index 901b6305678c..0f0938602ab4 100644 --- a/prqlc/prqlc/tests/integration/sql.rs +++ b/prqlc/prqlc/tests/integration/sql.rs @@ -2551,7 +2551,7 @@ fn test_join_side_literal_err() { #[test] fn test_join_side_literal_via_func() { assert_snapshot!((compile(r###" - let my_join = func m c s :"right" tbl -> ( + let my_join = func m c s :"right" tbl -> ( join side:_param.s m (c == that.k) tbl ) @@ -2570,7 +2570,7 @@ fn test_join_side_literal_via_func() { #[test] fn test_join_side_literal_via_func_err() { assert_snapshot!((compile(r###" - let my_join = func m c s :"right" tbl -> ( + let my_join = func m c s :"right" tbl -> ( join side:_param.s m (c == that.k) tbl ) @@ -5504,3 +5504,18 @@ sort { d }"###).unwrap(), @r#" d "#); } + +#[test] +fn test_type_error_placement() { + assert_snapshot!(compile(r###" + let foo = x -> (x | as integer) + from t + select (true && (foo y)) + "###).unwrap(), @r#" + SELECT + true + AND CAST(y AS integer) + FROM + t + "#); +}