feat: add 'date.trunc' function for date trunc support#5729
feat: add 'date.trunc' function for date trunc support#5729
Conversation
|
great, would you mind running the other CI failure is on me; I will fix more generally: thank you for these. Sorry the diffs are so big when something is added to the stdlib. if you want to bundle the changes together, that's fine (but no obligation, fine with me) |
59e8c32 to
bebb12b
Compare
prql-bot
left a comment
There was a problem hiding this comment.
The BigQuery and MSSQL date.trunc s-string overrides in std.sql.prql (lines 233 and 315) are dead code — process_date_trunc in gen_expr.rs intercepts these dialects and constructs the AST directly before the s-strings are ever reached. The s-strings would also produce incorrect SQL (quoted unit strings instead of unquoted keywords), which is why the Rust code is needed. Consider removing the BigQuery/MSSQL overrides to avoid confusion, or adding a comment noting they're overridden.
Minor: SQLite has no date.trunc override (unlike date.diff which has -> null), so date.trunc on SQLite will generate DATE_TRUNC(...) which SQLite doesn't support. Fine as a follow-up.
I ran pre-commit as you suggested. Thank you! Regarding your comment, 'if you want to bundle the changes together, that's fine'—does that mean I can submit the main logic changes first without the snap file updates, and then update the snap files in a separate PR later? |
unfortunately not — I had meant if you want to put multiple functions in the same PR... |
Closes #5728
Adds a
date.truncfunction to provide native date truncation capabilities in PRQL.