Skip to content

fix: date.trunc returns error for SQLite instead of invalid SQL#5733

Merged
max-sixty merged 1 commit intomainfrom
fix/date-trunc-sqlite
Mar 25, 2026
Merged

fix: date.trunc returns error for SQLite instead of invalid SQL#5733
max-sixty merged 1 commit intomainfrom
fix/date-trunc-sqlite

Conversation

@prql-bot
Copy link
Copy Markdown
Collaborator

Summary

  • SQLite doesn't have a DATE_TRUNC function, but prqlc was generating DATE_TRUNC('day', event_time) when targeting SQLite
  • Added let trunc = unit column -> null to the sqlite.date module in std.sql.prql, following the same pattern used for date.diff on unsupported dialects
  • Added a test date_trunc_unsupported_dialects to verify SQLite correctly returns an error

Test plan

  • cargo insta test -p prqlc --test integration -- date_trunc passes (7 tests)
  • task prqlc:pull-request test suite passes

Closes #5730

🤖 Generated with Claude Code

SQLite doesn't have a DATE_TRUNC function, but prqlc was generating
`DATE_TRUNC('day', event_time)` when targeting SQLite. This adds
`let trunc = unit column -> null` to the sqlite.date module, following
the same pattern used for date.diff on unsupported dialects.

Closes #5730

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@prql-bot prql-bot enabled auto-merge (squash) March 25, 2026 07:05
@max-sixty max-sixty merged commit 9f24503 into main Mar 25, 2026
36 checks passed
@max-sixty max-sixty deleted the fix/date-trunc-sqlite branch March 25, 2026 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

date.trunc generates invalid SQL for SQLite target

2 participants