Skip to content

Conversation

krinart
Copy link
Contributor

@krinart krinart commented Sep 8, 2025

Which issue does this PR close?

PR improves unparser to produce valid CAST SQL for SQLite and timestamp_text

Rationale for this change

SQLite does not have dedicated DATE type and prefers a text string that is an ISO 8601 date/time value.

Default implementation of timestamp_cast_dtype casts values to Timestamp. However you can see below that casting to TIMESTAMP produces invalid value in cast of sqlite, where casting to TEXT produces a valid one:

sqlite> select event_time, cast(event_time as timestamp), cast(event_time as text) from my_table limit 1;

2025-08-30 01:36:00.888580  |  2025  |  2025-08-30 01:36:00.888580

What changes are included in this PR?

PR introduces custom timestamp_cast_dtype implementation for SqliteDialect.

Are these changes tested?

Yes, added unit tests + manual testing

Are there any user-facing changes?

No

Copy link
Contributor

@Jefffrey Jefffrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me 👍

@Jefffrey Jefffrey merged commit 50733bc into apache:main Sep 12, 2025
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sql SQL Planner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants