Skip to content

fix(unparser): use to_rfc3339 for default TIMESTAMPTZ formatting#21295

Open
sgrebnov wants to merge 1 commit intoapache:mainfrom
spiceai:sgrebnov/0401-timestamp_with_tz_to_string
Open

fix(unparser): use to_rfc3339 for default TIMESTAMPTZ formatting#21295
sgrebnov wants to merge 1 commit intoapache:mainfrom
spiceai:sgrebnov/0401-timestamp_with_tz_to_string

Conversation

@sgrebnov
Copy link
Copy Markdown
Member

@sgrebnov sgrebnov commented Apr 1, 2026

Which issue does this PR close?

Rationale for this change

The default timestamp_with_tz_to_string uses DateTime<Tz>.to_string(), which produces literals like 2025-09-15 11:00:00 +00:00 that are not supported by multiple dialects (e.g. DuckDB, BigQuery). Switching to to_rfc3339() produces valid ISO 8601 / RFC 3339 strings (e.g. 2025-09-15T11:00:00+00:00) that are broadly compatible.

What changes are included in this PR?

  • Changed the default Dialect::timestamp_with_tz_to_string implementation from dt.to_string() to dt.to_rfc3339()
  • Removed now-redundant timestamp_with_tz_to_string overrides from DuckDBDialect and BigQueryDialect (they produced equivalent RFC 3339-compatible output via custom format strings)
  • Updated test expectations to match the new default format

Are these changes tested?

Yes, existing tests in unparser::expr::tests have been updated to reflect the new format.

Manually verifying updated format supported by PostgreSQL, MySQL, SQLite, DuckDB and BigQuery.

Are there any user-facing changes?

Yes — timestamp-with-timezone literals are now formatted as RFC 3339 (2025-09-15T11:00:00+00:00) instead of the previous Display format (2025-09-15 11:00:00 +00:00). Dialects that need a different format can still override timestamp_with_tz_to_string.

@github-actions github-actions bot added the sql SQL Planner label Apr 1, 2026
@sgrebnov sgrebnov marked this pull request as ready for review April 1, 2026 10:22
@AndreaBozzo
Copy link
Copy Markdown
Contributor

Seems solid, waiting for someone else to take another look

Copy link
Copy Markdown
Contributor

@nuno-faria nuno-faria left a comment

Choose a reason for hiding this comment

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

Thanks @sgrebnov.

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.

unparser: use to_rfc3339 for TIMESTAMPTZ formatting

3 participants