From ae6ba75557cdc2b8a778d8f1587b65ed2b1bb105 Mon Sep 17 00:00:00 2001 From: prql-bot <107324867+prql-bot@users.noreply.github.com> Date: Thu, 13 Aug 2026 06:58:43 +0000 Subject: [PATCH 1/2] internal: remove dead code from the SQL backend --- prqlc/prqlc/src/sql/dialect.rs | 9 -------- prqlc/prqlc/src/sql/gen_query.rs | 37 ++++---------------------------- 2 files changed, 4 insertions(+), 42 deletions(-) diff --git a/prqlc/prqlc/src/sql/dialect.rs b/prqlc/prqlc/src/sql/dialect.rs index 9864b8d8b5a8..feb02a1a9feb 100644 --- a/prqlc/prqlc/src/sql/dialect.rs +++ b/prqlc/prqlc/src/sql/dialect.rs @@ -362,11 +362,6 @@ impl DialectHandler for PostgresDialect { } impl DialectHandler for RedshiftDialect { - fn ident_quoting_style(&self) -> IdentQuotingStyle { - // Use conditional quoting with dialect-specific keywords - IdentQuotingStyle::ConditionallyQuoted - } - fn interval_quoting_style(&self, dtf: &DateTimeField) -> IntervalQuotingStyle { if matches!(dtf, DateTimeField::Week(_) | DateTimeField::Weeks) { IntervalQuotingStyle::ValueAndUnitQuoted @@ -375,10 +370,6 @@ impl DialectHandler for RedshiftDialect { } } - fn supports_distinct_on(&self) -> bool { - false - } - // https://docs.aws.amazon.com/redshift/latest/dg/r_FORMAT_strings.html fn translate_chrono_item(&self, item: Item) -> Result { Ok(match item { diff --git a/prqlc/prqlc/src/sql/gen_query.rs b/prqlc/prqlc/src/sql/gen_query.rs index cbd0589e77ee..f17188d352c9 100644 --- a/prqlc/prqlc/src/sql/gen_query.rs +++ b/prqlc/prqlc/src/sql/gen_query.rs @@ -347,8 +347,7 @@ fn translate_set_ops_pipeline( } fn translate_relation_expr(relation_expr: RelationExpr, ctx: &mut Context) -> Result { - let alias = Some(&relation_expr.riid) - .and_then(|riid| ctx.anchor.relation_instances.get(riid)) + let alias = (ctx.anchor.relation_instances.get(&relation_expr.riid)) .and_then(|ri| ri.table_ref.name.clone()); Ok(match relation_expr.kind { @@ -448,40 +447,12 @@ fn translate_cte(cte: Cte, ctx: &mut Context) -> Result<(sql_ast::Cte, bool)> { right: step, }); - (inner_query, true) - // RECURSIVE can only follow WITH directly. // Initial implementation assumed that it applies only to the first CTE. // This meant that it had to wrap any-non-first CTE into a *nested* WITH, so the inner - // WITH could be RECURSIVE. - // This is implementation of that, in case some dialect requires it. - // let inner_cte = sql_ast::Cte { - // alias: simple_table_alias(cte_name.clone()), - // query: Box::new(inner_query), - // from: None, - // }; - // let outer_query = sql_ast::Query { - // with: Some(sql_ast::With { - // recursive: true, - // cte_tables: vec![inner_cte], - // }), - // ..default_query(sql_ast::SetExpr::Select(Box::new(sql_ast::Select { - // projection: vec![SelectItem::Wildcard( - // sql_ast::WildcardAdditionalOptions::default(), - // )], - // from: vec![TableWithJoins { - // relation: TableFactor::Table { - // name: sql_ast::ObjectName(vec![cte_name.clone()]), - // alias: None, - // args: None, - // with_hints: Vec::new(), - // }, - // joins: vec![], - // }], - // ..default_select() - // }))) - // }; - // (outer_query, false) + // WITH could be RECURSIVE. If a dialect ever needs that, the removed implementation is + // in the history of this file. + (inner_query, true) } }; From 87853d900e9b82a7863301b0609b55ca7c465a39 Mon Sep 17 00:00:00 2001 From: prql-bot <107324867+prql-bot@users.noreply.github.com> Date: Thu, 13 Aug 2026 07:10:16 +0000 Subject: [PATCH 2/2] internal: cite the PR number in the recursive-CTE pointer --- prqlc/prqlc/src/sql/gen_query.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prqlc/prqlc/src/sql/gen_query.rs b/prqlc/prqlc/src/sql/gen_query.rs index f17188d352c9..608979c249c3 100644 --- a/prqlc/prqlc/src/sql/gen_query.rs +++ b/prqlc/prqlc/src/sql/gen_query.rs @@ -451,7 +451,7 @@ fn translate_cte(cte: Cte, ctx: &mut Context) -> Result<(sql_ast::Cte, bool)> { // Initial implementation assumed that it applies only to the first CTE. // This meant that it had to wrap any-non-first CTE into a *nested* WITH, so the inner // WITH could be RECURSIVE. If a dialect ever needs that, the removed implementation is - // in the history of this file. + // in the history of this file (deleted in #6190). (inner_query, true) } };