Repository navigation
fix: compare naive timestamps with CURRENT_TIMESTAMP() and count sub-day DATEDIFF of a DATE - #115
Merged
Merged
Conversation
…IFF of a DATE A TIMESTAMP_NTZ beside a TIMESTAMP_LTZ, such as CURRENT_TIMESTAMP() or DATEADD of it, now reads the local value as its wall time in the UTC session, at its own precision, as Snowflake does. DATEADD takes a TIMESTAMP_LTZ the same way. DATEDIFF in HOUR, MINUTE or SECOND reads a DATE operand as its midnight.
…ub-day DATEDIFF of a DATE Recorded from fix/ntz-current-timestamp ec34616 (6 cases, utc-v1, no failures).
…tamp The naive-local comparison's rule id moves to the catalogue constants: conversion/constants.rs is at its 2,000-line limit until it is split.
…al bound does
TIMESTAMP_NTZ against CONVERT_TIMEZONE('UTC', tz), against a TIMESTAMP_TZ
column at a non-UTC offset, and against CONVERT_TIMEZONE('UTC',
CURRENT_TIMESTAMP()), under utc-v1.
Snowflake results for temporal/naive_zoned_comparison at 05d20a3. A TIMESTAMP_NTZ beside a TIMESTAMP_TZ compares instants, the naive value read in the session's time zone (UTC), with or without CONVERT_TIMEZONE('UTC', ...).
…uack into fix/ntz-current-timestamp
…s recorded
Snowflake reads the naive value in the session time zone and compares
instants beside a TIMESTAMP_TZ at any offset, with or without
CONVERT_TIMEZONE, so the naive-local comparison now reads a
TIMESTAMP_TZ as its UTC wall time too. This covers dbt's incremental
upper bound, convert_timezone('UTC', current_timestamp()).
Cases whose outcome now matches Snowflake no longer declare a
divergence, and the zoned columns' NTZ comparison declares
timestamp_tz_submicro for its nanosecond row, as their text
comparisons do.
kvlonge
added a commit
that referenced
this pull request
Nov 6, 2026
…econds A zoned value read as its UTC wall time at a precision above microseconds is cast to nanoseconds, which DuckDB cannot hold past 2262, where Snowflake compares it. BETWEEN joins the comparisons the rule and timestamp_range cover.
…TWEEN TIMESTAMP_NTZ(9) beside TIMESTAMP_TZ and TIMESTAMP_LTZ sentinels past the nanosecond range, and BETWEEN with mixed naive and zoned bounds, under utc-v1.
…tamp # Conflicts: # sqlquack.toml
…n BETWEEN Snowflake results for the two cases added at 757ee76. Past the nanosecond range and in BETWEEN with mixed bounds, a TIMESTAMP_NTZ still compares with TIMESTAMP_TZ and TIMESTAMP_LTZ values as instants, read in the session's time zone (UTC).
…uack into fix/ntz-current-timestamp
… of naive and zoned timestamps
kvlonge
added a commit
that referenced
this pull request
Nov 6, 2026
…with a nanosecond local one
…comparison separately
Contributor
Author
|
Gate on the exact head 559fc80 (a91604e, a merge of main 139fc9e, the test and corpus commits):
|
kvlonge
marked this pull request as ready for review
November 7, 2026 07:17
kvlonge
had a problem deploying
to
github-pages
November 7, 2026 07:23 — with
GitHub Actions
Failure
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Incremental and freshness filters compare a TIMESTAMP_NTZ column with CURRENT_TIMESTAMP(), directly or through DATEADD. dbt_utils.recency compiles to exactly that comparison. These were refused with SQ0003 ("comparing TIMESTAMP_NTZ(9) with TIMESTAMP_LTZ(9) needs an implicit conversion"). DATEDIFF in HOUR, MINUTE or SECOND with a DATE operand was also refused.
Changes
session_timezone_utc.session_timezone_utcnow lists these functions.timestamp_range.cases/temporal/naive_local_comparison.toml(comparisons, CURRENT_TIMESTAMP(), DATEADD of a local column, sub-day DATEDIFF of DATEs), recorded on Snowflake.Verification
make check-ci,make test-rustandmake verify-recordedon the merged head: 12,044 cases, 0 failed, 0 translation-result regressions.