Skip to content

Commit 5bcc274

Browse files
authored
fix: use PostgreSQL dialect for PRQL compilation (#54)
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.
1 parent 183f626 commit 5bcc274

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/datafusion_integration/prql.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,10 @@ pub fn is_prql(input: &str) -> bool {
191191

192192
/// Compile PRQL source to SQL.
193193
///
194-
/// Uses the `prqlc` compiler with the generic SQL dialect, which should
195-
/// be compatible with DataFusion.
194+
/// Uses the `prqlc` compiler with the PostgreSQL dialect, which is most
195+
/// compatible with DataFusion's SQL parser. Key differences from generic:
196+
/// - Regex: `~=` compiles to `~` operator (not `REGEXP()` function)
197+
/// - String functions and operators match DataFusion's PostgreSQL-style syntax
196198
///
197199
/// # Errors
198200
///
@@ -202,7 +204,7 @@ pub fn compile_prql(prql: &str) -> Result<String> {
202204
use prqlc::{Options, Target};
203205

204206
let opts = Options::default()
205-
.with_target(Target::Sql(Some(prqlc::sql::Dialect::Generic)))
207+
.with_target(Target::Sql(Some(prqlc::sql::Dialect::Postgres)))
206208
.no_format();
207209

208210
prqlc::compile(prql, &opts).map_err(|e| {

0 commit comments

Comments
 (0)