diff --git a/prqlc/prqlc-parser/src/lib.rs b/prqlc/prqlc-parser/src/lib.rs index 2945349d0106..93cf32d6abb7 100644 --- a/prqlc/prqlc-parser/src/lib.rs +++ b/prqlc/prqlc-parser/src/lib.rs @@ -9,12 +9,14 @@ pub use self::lexer::TokenVec; use crate::error::Error; use crate::lexer::lr::TokenKind; use crate::parser::pr::Stmt; +use crate::parser::prepare_stream; /// Build PRQL AST from a PRQL query string. pub fn parse_source(source: &str, source_id: u16) -> Result, Vec> { let mut errors = Vec::new(); let (tokens, lex_errors) = ::chumsky::Parser::parse_recovery(&lexer::lexer(), source); + // let (tokens, lex_errors) = ::chumsky::Parser::parse_recovery_verbose(&lexer::lexer(), source); log::debug!("Lex errors: {:?}", lex_errors); errors.extend( @@ -23,20 +25,13 @@ pub fn parse_source(source: &str, source_id: u16) -> Result, Vec = tokens.map(|tokens| { - tokens.into_iter().filter(|token| { - !matches!( - token.kind, - TokenKind::Comment(_) | TokenKind::LineWrap(_) | TokenKind::DocComment(_) - ) - }) - }); + let ast = if let Some(tokens) = tokens { + let stream = prepare_stream(tokens.into_iter(), source, source_id); - let ast = if let Some(semantic_tokens) = semantic_tokens { - let stream = parser::prepare_stream(semantic_tokens, source, source_id); + // let ast = if let Some(semantic_tokens) = semantic_tokens { + // let stream = parser::prepare_stream(semantic_tokens, source, source_id); + // ::chumsky::Parser::parse_recovery_verbose(&stmt::source(), stream); let (ast, parse_errors) = ::chumsky::Parser::parse_recovery(&parser::stmt::source(), stream); diff --git a/prqlc/prqlc-parser/src/parser/common.rs b/prqlc/prqlc-parser/src/parser/common.rs index 0b0848838949..6f1162d529df 100644 --- a/prqlc/prqlc-parser/src/parser/common.rs +++ b/prqlc/prqlc-parser/src/parser/common.rs @@ -3,6 +3,7 @@ use chumsky::prelude::*; use crate::error::parse_error::PError; use crate::lexer::lr::TokenKind; use crate::parser::pr::{Annotation, Expr, ExprKind, Stmt, StmtKind, Ty, TyKind}; +use crate::parser::WithAesthetics; use crate::span::Span; pub fn ident_part() -> impl Parser + Clone { @@ -36,6 +37,8 @@ pub fn into_stmt((annotations, kind): (Vec, StmtKind), span: Span) - kind, span: Some(span), annotations, + aesthetics_before: Vec::new(), + aesthetics_after: Vec::new(), } } @@ -52,3 +55,40 @@ pub fn into_ty(kind: TyKind, span: Span) -> Ty { ..Ty::new(kind) } } + +pub fn aesthetic() -> impl Parser + Clone { + select! { + TokenKind::Comment(comment) => TokenKind::Comment(comment), + TokenKind::LineWrap(lw) => TokenKind::LineWrap(lw), + TokenKind::DocComment(dc) => TokenKind::DocComment(dc), + } +} + +pub fn with_aesthetics(parser: P) -> impl Parser + Clone +where + P: Parser + Clone, + O: WithAesthetics, +{ + // We can safely remove newlines following the `aesthetics_before`, to cover + // a case like `# foo` here: + // + // ```prql + // # foo + // + // from bar + // # baz + // select artists + // ``` + // + // ...but not following the `aesthetics_after`; since that would eat all + // newlines between `from_bar` and `select_artists`. + // + let aesthetics_before = aesthetic().then_ignore(new_line().repeated()).repeated(); + let aesthetics_after = aesthetic().separated_by(new_line()); + + aesthetics_before.then(parser).then(aesthetics_after).map( + |((aesthetics_before, inner), aesthetics_after)| { + inner.with_aesthetics(aesthetics_before, aesthetics_after) + }, + ) +} diff --git a/prqlc/prqlc-parser/src/parser/expr.rs b/prqlc/prqlc-parser/src/parser/expr.rs index f99135365e82..1408b9c58b1d 100644 --- a/prqlc/prqlc-parser/src/parser/expr.rs +++ b/prqlc/prqlc-parser/src/parser/expr.rs @@ -5,7 +5,7 @@ use chumsky::prelude::*; use super::interpolation; use crate::error::parse_error::PError; use crate::lexer::lr::{Literal, TokenKind}; -use crate::parser::common::{ctrl, ident_part, into_expr, keyword, new_line}; +use crate::parser::common::{ctrl, ident_part, into_expr, keyword, new_line, with_aesthetics}; use crate::parser::pr::ident::Ident; use crate::parser::pr::ops::{BinOp, UnOp}; use crate::parser::pr::*; @@ -29,7 +29,9 @@ pub fn expr() -> impl Parser + Clone { .map(|x| x.to_string()) .map(ExprKind::Internal); - let nested_expr = pipeline(lambda_func(expr.clone()).or(func_call(expr.clone()))).boxed(); + let nested_expr = with_aesthetics( + pipeline(lambda_func(expr.clone()).or(func_call(expr.clone()))).boxed(), + ); let tuple = ident_part() .then_ignore(ctrl('=')) @@ -124,18 +126,20 @@ pub fn expr() -> impl Parser + Clone { let param = select! { TokenKind::Param(id) => ExprKind::Param(id) }; - let term = choice(( - literal, - internal, - tuple, - array, - interpolation, - ident_kind, - case, - param, - )) - .map_with_span(into_expr) - .or(pipeline) + let term = with_aesthetics( + choice(( + literal, + internal, + tuple, + array, + interpolation, + ident_kind, + case, + param, + )) + .map_with_span(into_expr) + .or(pipeline), + ) .boxed(); // indirections diff --git a/prqlc/prqlc-parser/src/parser/interpolation.rs b/prqlc/prqlc-parser/src/parser/interpolation.rs index d29d573f06f9..4d29cd17bb01 100644 --- a/prqlc/prqlc-parser/src/parser/interpolation.rs +++ b/prqlc/prqlc-parser/src/parser/interpolation.rs @@ -98,6 +98,8 @@ fn parse_interpolate() { 0:8-9, ), alias: None, + aesthetics_before: [], + aesthetics_after: [], }, format: None, }, @@ -143,6 +145,8 @@ fn parse_interpolate() { 0:14-15, ), alias: None, + aesthetics_before: [], + aesthetics_after: [], }, format: None, }, diff --git a/prqlc/prqlc-parser/src/parser/mod.rs b/prqlc/prqlc-parser/src/parser/mod.rs index ea82047d1c9d..34bb09f8a2af 100644 --- a/prqlc/prqlc-parser/src/parser/mod.rs +++ b/prqlc/prqlc-parser/src/parser/mod.rs @@ -46,3 +46,11 @@ pub fn prepare_stream( }; Stream::from_iter(eoi, tokens) } + +pub trait WithAesthetics { + fn with_aesthetics( + self, + aesthetics_before: Vec, + aethetics_after: Vec, + ) -> Self; +} diff --git a/prqlc/prqlc-parser/src/parser/pr/expr.rs b/prqlc/prqlc-parser/src/parser/pr/expr.rs index ac2e4402ea4b..dbfb2117ff52 100644 --- a/prqlc/prqlc-parser/src/parser/pr/expr.rs +++ b/prqlc/prqlc-parser/src/parser/pr/expr.rs @@ -7,7 +7,9 @@ use crate::lexer::lr::Literal; use crate::parser::generic; use crate::parser::pr::ops::{BinOp, UnOp}; use crate::parser::pr::Ty; +use crate::parser::WithAesthetics; use crate::span::Span; +use crate::TokenKind; impl Expr { pub fn new>(kind: K) -> Self { @@ -15,6 +17,8 @@ impl Expr { kind: kind.into(), span: None, alias: None, + aesthetics_before: Vec::new(), + aesthetics_after: Vec::new(), } } } @@ -33,6 +37,24 @@ pub struct Expr { #[serde(skip_serializing_if = "Option::is_none")] pub alias: Option, + + // Maybe should be Token? + #[serde(skip_serializing_if = "Vec::is_empty")] + pub aesthetics_before: Vec, + #[serde(skip_serializing_if = "Vec::is_empty")] + pub aesthetics_after: Vec, +} + +impl WithAesthetics for Expr { + fn with_aesthetics( + mut self, + aesthetics_before: Vec, + aesthetics_after: Vec, + ) -> Self { + self.aesthetics_before = aesthetics_before; + self.aesthetics_after = aesthetics_after; + self + } } #[derive(Debug, EnumAsInner, PartialEq, Clone, Serialize, Deserialize, strum::AsRefStr)] diff --git a/prqlc/prqlc-parser/src/parser/pr/stmt.rs b/prqlc/prqlc-parser/src/parser/pr/stmt.rs index a4f1685ca37a..2347584ebe0c 100644 --- a/prqlc/prqlc-parser/src/parser/pr/stmt.rs +++ b/prqlc/prqlc-parser/src/parser/pr/stmt.rs @@ -6,7 +6,9 @@ use serde::{Deserialize, Serialize}; use crate::parser::pr::ident::Ident; use crate::parser::pr::{Expr, Ty}; +use crate::parser::WithAesthetics; use crate::span::Span; +use crate::TokenKind; #[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, Default)] pub struct QueryDef { @@ -33,6 +35,26 @@ pub struct Stmt { #[serde(skip_serializing_if = "Vec::is_empty", default)] pub annotations: Vec, + + // Maybe should be Token? + #[serde(skip_serializing_if = "Vec::is_empty")] + pub aesthetics_before: Vec, + #[serde(skip_serializing_if = "Vec::is_empty")] + pub aesthetics_after: Vec, +} + +impl WithAesthetics for Stmt { + fn with_aesthetics( + self, + aesthetics_before: Vec, + aesthetics_after: Vec, + ) -> Self { + Stmt { + aesthetics_before, + aesthetics_after, + ..self + } + } } #[derive(Debug, EnumAsInner, PartialEq, Clone, Serialize, Deserialize)] @@ -75,6 +97,24 @@ pub struct ImportDef { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct Annotation { pub expr: Box, + #[serde(skip_serializing_if = "Vec::is_empty")] + pub aesthetics_before: Vec, + #[serde(skip_serializing_if = "Vec::is_empty")] + pub aesthetics_after: Vec, +} + +impl WithAesthetics for Annotation { + fn with_aesthetics( + self, + aesthetics_before: Vec, + aesthetics_after: Vec, + ) -> Self { + Annotation { + aesthetics_before, + aesthetics_after, + ..self + } + } } impl Stmt { @@ -83,6 +123,8 @@ impl Stmt { kind, span: None, annotations: Vec::new(), + aesthetics_before: Vec::new(), + aesthetics_after: Vec::new(), } } } diff --git a/prqlc/prqlc-parser/src/parser/stmt.rs b/prqlc/prqlc-parser/src/parser/stmt.rs index 16ca656a468d..87de5ed6e30e 100644 --- a/prqlc/prqlc-parser/src/parser/stmt.rs +++ b/prqlc/prqlc-parser/src/parser/stmt.rs @@ -8,11 +8,12 @@ use super::common::{ctrl, ident_part, into_stmt, keyword, new_line}; use super::expr::{expr, expr_call, ident, pipeline}; use crate::error::parse_error::PError; use crate::lexer::lr::{Literal, TokenKind}; +use crate::parser::common::with_aesthetics; use crate::parser::pr::*; use crate::parser::types::type_expr; pub fn source() -> impl Parser, Error = PError> { - query_def() + with_aesthetics(query_def()) .or_not() .chain(module_contents()) .then_ignore(end()) @@ -31,15 +32,36 @@ fn module_contents() -> impl Parser, Error = PError> { .then_ignore(new_line().repeated()) .map(|expr| Annotation { expr: Box::new(expr), + aesthetics_before: Vec::new(), + aesthetics_after: Vec::new(), }); - annotation - .repeated() - .then(choice((module_def, type_def(), import_def(), var_def()))) - .map_with_span(into_stmt) - .separated_by(new_line().repeated().at_least(1)) - .allow_leading() - .allow_trailing() + // TODO: I think some duplication here; we allow for potential + // newlines before each item here, but then also have `.allow_leading` + // below — since now we can get newlines after a comment between the + // aesthetic item and the stmt... So a bit messy + let stmt_kind = new_line().repeated().ignore_then(choice(( + module_def, + type_def(), + import_def(), + var_def(), + ))); + + // Two wrapping of `with_aesthetics` — the first for the whole block, + // and the second for just the annotation; if there's a comment between + // the annotation and the code. + with_aesthetics( + with_aesthetics(annotation) + .repeated() + // TODO: do we need this? I think possibly we get an additional + // error when we remove it; check (because it seems redundant...). + .then_ignore(new_line().repeated()) + .then(stmt_kind) + .map_with_span(into_stmt), + ) + .separated_by(new_line().repeated().at_least(1)) + .allow_leading() + .allow_trailing() }) } @@ -113,7 +135,9 @@ fn query_def() -> impl Parser + Clone { } fn var_def() -> impl Parser + Clone { - let let_ = keyword("let") + let let_ = new_line() + .repeated() + .ignore_then(keyword("let")) .ignore_then(ident_part()) .then(type_expr().delimited_by(ctrl('<'), ctrl('>')).or_not()) .then(ctrl('=').ignore_then(expr_call()).map(Box::new).or_not()) diff --git a/prqlc/prqlc-parser/src/snapshots/prqlc_parser__test__pipeline_parse_tree.snap b/prqlc/prqlc-parser/src/snapshots/prqlc_parser__test__pipeline_parse_tree.snap index 6d6d8c6c3c77..f3b9a1d1fc86 100644 --- a/prqlc/prqlc-parser/src/snapshots/prqlc_parser__test__pipeline_parse_tree.snap +++ b/prqlc/prqlc-parser/src/snapshots/prqlc_parser__test__pipeline_parse_tree.snap @@ -24,6 +24,8 @@ expression: "parse_single(r#\"\nfrom employees\nfilter country == \"USA\" right: Literal: String: USA + aesthetics_after: + - Comment: " Each line transforms the previous result." - FuncCall: name: Ident: derive @@ -36,12 +38,16 @@ expression: "parse_single(r#\"\nfrom employees\nfilter country == \"USA\" right: Ident: payroll_tax alias: gross_salary + aesthetics_before: + - Comment: " This adds columns / variables." - Binary: left: Ident: gross_salary op: Add right: Ident: benefits_cost + aesthetics_after: + - Comment: " Variables can use other variables." alias: gross_cost - FuncCall: name: @@ -71,6 +77,8 @@ expression: "parse_single(r#\"\nfrom employees\nfilter country == \"USA\" Ident: average args: - Ident: salary + aesthetics_before: + - Comment: " Aggregate each group to a single row" - FuncCall: name: Ident: average diff --git a/prqlc/prqlc-parser/src/test.rs b/prqlc/prqlc-parser/src/test.rs index b130e10c71fb..08ce33bfa3c3 100644 --- a/prqlc/prqlc-parser/src/test.rs +++ b/prqlc/prqlc-parser/src/test.rs @@ -401,6 +401,8 @@ fn test_basic_exprs() { args: - Ident: a span: "0:28-36" + aesthetics_before: + - Comment: " this is a comment" "###); assert_yaml_snapshot!(parse_expr( "join side:left country (id==employee_id)" @@ -1926,6 +1928,8 @@ fn test_allowed_idents() { op: EqSelf expr: Ident: employee_id + aesthetics_after: + - Comment: " table with leading underscore" - FuncCall: name: Ident: filter diff --git a/prqlc/prqlc/src/semantic/ast_expand.rs b/prqlc/prqlc/src/semantic/ast_expand.rs index fea53752de7a..73b899f8ce25 100644 --- a/prqlc/prqlc/src/semantic/ast_expand.rs +++ b/prqlc/prqlc/src/semantic/ast_expand.rs @@ -292,6 +292,8 @@ pub fn restrict_expr(expr: pl::Expr) -> ast::Expr { kind: restrict_expr_kind(expr.kind), span: expr.span, alias: expr.alias, + aesthetics_before: vec![], + aesthetics_after: vec![], } } @@ -455,12 +457,16 @@ fn restrict_stmt(stmt: pl::Stmt) -> ast::Stmt { .into_iter() .map(restrict_annotation) .collect(), + aesthetics_before: vec![], + aesthetics_after: vec![], } } pub fn restrict_annotation(value: pl::Annotation) -> ast::Annotation { ast::Annotation { expr: restrict_expr_box(value.expr), + aesthetics_before: vec![], + aesthetics_after: vec![], } } 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 56eb48f37e81..930c9963253c 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 @@ -258,3 +258,8 @@ ast: args: - Ident: empty_name span: 1:102-244 + aesthetics_before: + - !Comment ' mssql:skip' + - !Comment ' mysql:skip' + - !Comment ' clickhouse:skip' + - !Comment ' glaredb:skip (the string_agg function is not supported)' 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 29fd7ffed5bf..145276b511f4 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 @@ -1159,3 +1159,5 @@ ast: args: - Ident: id span: 1:13-833 + aesthetics_before: + - !Comment ' mssql:test' 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 673866095522..0e090ab209a3 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 @@ -187,3 +187,5 @@ ast: - Literal: Integer: 20 span: 1:13-106 + aesthetics_before: + - !Comment ' mssql:test' 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 a2423ce4dc50..8de3ba831ddd 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 @@ -546,3 +546,8 @@ ast: String: 100%% in %d days alias: d12 span: 1:57-719 + aesthetics_before: + - !Comment ' generic:skip' + - !Comment ' glaredb:skip' + - !Comment ' sqlite:skip' + - !Comment ' mssql:test' 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 d2c9f6f98c33..efc1d91446a0 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 @@ -209,3 +209,5 @@ ast: Ident: tracks field: Star span: 1:13-91 + aesthetics_before: + - !Comment ' mssql:test' 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 5b1eb4ad31d4..109c88863b91 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 @@ -264,3 +264,5 @@ ast: Ident: genre_id - Ident: media_type_id span: 1:13-160 + aesthetics_before: + - !Comment ' mssql:test' 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 d8a39e5b9d1c..960ab255aa48 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 @@ -116,6 +116,9 @@ ast: - Ident: name alias: a span: 1:117-185 + aesthetics_before: + - !Comment ' clickhouse:skip (ClickHouse prefers aliases to column names https://github.com/PRQL/prql/issues/2827)' + - !Comment ' mssql:test' - VarDef: kind: Main name: main 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 a664ec8a01f4..67750c5dc693 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 @@ -307,3 +307,5 @@ ast: args: - Ident: album_id span: 1:13-161 + aesthetics_before: + - !Comment ' mssql:test' 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 69119a7b38af..6b1bb688413a 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 @@ -297,3 +297,5 @@ ast: alias: d1 - Ident: n1 span: 1:13-151 + aesthetics_before: + - !Comment ' mssql:test' 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 b6d9be2bc15f..a4a91ab9f0b2 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 @@ -373,3 +373,6 @@ ast: expr: Ident: milliseconds span: 1:76-252 + aesthetics_before: + - !Comment ' Compute the 3 longest songs for each genre and sort by genre' + - !Comment ' mssql:test' 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 4054030d0bb4..8cebc7fa91b2 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 @@ -901,3 +901,6 @@ ast: - Literal: Integer: 20 span: 1:131-792 + aesthetics_before: + - !Comment ' clickhouse:skip (clickhouse doesn''t have lag function)' + - !DocComment ' Calculate a number of metrics about the sales of tracks in each city.' 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 96f527899b53..29e8542c9e12 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 @@ -332,3 +332,6 @@ ast: args: - Ident: n span: 1:162-257 + aesthetics_before: + - !Comment ' clickhouse:skip (DB::Exception: Syntax error)' + - !Comment ' glaredb:skip (DataFusion does not support recursive CTEs https://github.com/apache/arrow-datafusion/issues/462)' 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 da55144526c2..3d6cbcffc293 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 @@ -757,3 +757,6 @@ ast: Integer: 2 alias: total_square span: 1:82-788 + aesthetics_before: + - !Comment ' mssql:test' + - !Comment ' sqlite:skip (see https://github.com/rusqlite/rusqlite/issues/1211)' 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 db6ae5f060e6..2e193153c425 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 @@ -308,3 +308,7 @@ ast: - Ident: name - Ident: composer span: 1:166-298 + aesthetics_before: + - !Comment ' sqlite:skip (Only works on Sqlite implementations which have the extension' + - !Comment ' installed' + - !Comment ' https://stackoverflow.com/questions/24037982/how-to-use-regexp-in-sqlite)' 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 009ebf55c985..961711aa69c0 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 @@ -66,3 +66,7 @@ ast: args: - Ident: media_type_id span: 1:43-111 + aesthetics_before: + - !Comment ' sqlite:skip' + - !Comment ' postgres:skip' + - !Comment ' mysql:skip' 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 a36f100dd7fb..32c9c55189d5 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 @@ -276,6 +276,8 @@ ast: named_params: [] generic_type_params: [] span: 1:13-79 + aesthetics_before: + - !Comment ' mssql:test' - VarDef: kind: Main name: main 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 4f92fb305d05..48ab859dc5a0 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 @@ -26,7 +26,7 @@ frames: table: - default_db - employees -- - 1:145-215 +- - 1:92-215 - columns: - !All input_id: 128 @@ -170,7 +170,7 @@ nodes: - 119 - id: 143 kind: 'TransformCall: Join' - span: 1:145-215 + span: 1:92-215 children: - 138 - 119 @@ -256,6 +256,8 @@ ast: - FuncCall: name: Ident: join + aesthetics_before: + - !Comment ' joining may use HashMerge, which can undo ORDER BY' args: - Ident: employees alias: manager @@ -292,3 +294,5 @@ ast: Ident: manager field: !Name first_name span: 1:13-272 + aesthetics_before: + - !Comment ' mssql:test' 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 7af6fc2334b6..c4057740161f 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 @@ -212,3 +212,6 @@ ast: - Literal: Integer: 10 span: 1:89-255 + aesthetics_before: + - !Comment ' glaredb:skip (May be a bag of String type conversion for Postgres Client)' + - !Comment ' mssql:test' 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 f2d9b74335bb..cba8322bda57 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 @@ -103,3 +103,5 @@ ast: Literal: Integer: 5 span: 1:13-52 + aesthetics_before: + - !Comment ' mssql:test' 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 a298ce5786ab..37394d37b0ff 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 @@ -632,3 +632,7 @@ ast: - Literal: String: os span: 1:113-589 + aesthetics_before: + - !Comment ' mssql:test' + - !Comment ' glaredb:skip — TODO: started raising an error on 2024-05-20; see `window.prql`' + - !Comment ' for more details' 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 665a6da67969..f01c9ddba58e 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 @@ -459,3 +459,13 @@ ast: Literal: Integer: 22 span: 1:762-1021 + aesthetics_before: + - !Comment ' mssql:skip Conversion("cannot interpret I64(Some(1)) as an i32 value")'', connection.rs:200:34' + - !Comment ' duckdb:skip problems with DISTINCT ON (duckdb internal error: [with INPUT_TYPE = int; RESULT_TYPE = unsigned char]: Assertion `min_val <= input'' failed.)' + - !Comment ' clickhouse:skip problems with DISTINCT ON' + - !Comment ' postgres:skip problems with DISTINCT ON' + - !Comment ' glaredb:skip — TODO: started raising an error on 2024-05-20, from https://github.com/PRQL/prql/actions/runs/9154902656/job/25198160283:' + - !Comment ' ERROR: This feature is not implemented: Unsupported ast node in sqltorel:' + - !Comment ' Substring { expr: Identifier(Ident { value: "title", quote_style: None }),' + - !Comment ' substring_from: Some(Value(Number("2", false))), substring_for:' + - !Comment ' Some(Value(Number("5", false))), special: true }'