From 0f16ab5195e847acd66777fbb0eafe6b65ce8232 Mon Sep 17 00:00:00 2001 From: Nikolay Denev Date: Sat, 17 Jan 2026 15:37:58 -0600 Subject: [PATCH] fix: use PostgreSQL dialect for PRQL compilation The Generic dialect produces REGEXP() function calls for the ~= operator, but DataFusion doesn't have a REGEXP function. PostgreSQL dialect produces the ~ operator which DataFusion supports. --- src/datafusion_integration/prql.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/datafusion_integration/prql.rs b/src/datafusion_integration/prql.rs index 11946a7..c482a90 100644 --- a/src/datafusion_integration/prql.rs +++ b/src/datafusion_integration/prql.rs @@ -191,8 +191,10 @@ pub fn is_prql(input: &str) -> bool { /// Compile PRQL source to SQL. /// -/// Uses the `prqlc` compiler with the generic SQL dialect, which should -/// be compatible with DataFusion. +/// Uses the `prqlc` compiler with the PostgreSQL dialect, which is most +/// compatible with DataFusion's SQL parser. Key differences from generic: +/// - Regex: `~=` compiles to `~` operator (not `REGEXP()` function) +/// - String functions and operators match DataFusion's PostgreSQL-style syntax /// /// # Errors /// @@ -202,7 +204,7 @@ pub fn compile_prql(prql: &str) -> Result { use prqlc::{Options, Target}; let opts = Options::default() - .with_target(Target::Sql(Some(prqlc::sql::Dialect::Generic))) + .with_target(Target::Sql(Some(prqlc::sql::Dialect::Postgres))) .no_format(); prqlc::compile(prql, &opts).map_err(|e| {