Skip to content

fix: render FOR VERSION/TIMESTAMP FROM/BETWEEN bounds, not a tuple [CLAUDE]#7903

Closed
chuenchen309 wants to merge 1 commit into
tobymao:mainfrom
chuenchen309:hunt/timetravel-xdialect
Closed

fix: render FOR VERSION/TIMESTAMP FROM/BETWEEN bounds, not a tuple [CLAUDE]#7903
chuenchen309 wants to merge 1 commit into
tobymao:mainfrom
chuenchen309:hunt/timetravel-xdialect

Conversation

@chuenchen309

Copy link
Copy Markdown
Contributor

The base version_sql renders a FROM/BETWEEN time-travel range straight from its Tuple, so a valid range comes back as a tuple literal:

>>> sqlglot.parse_one("SELECT * FROM t FOR VERSION BETWEEN '1' AND '2'", read="trino").sql("trino")
"SELECT * FROM t FOR VERSION BETWEEN ('1', '2')"

FROM '1' TO '2' is affected the same way. The parser stores the two bounds as a Tuple, but for these two kinds they need to be joined by AND/TO rather than emitted as (start, end). CONTAINED IN (...), AS OF and ALL are unchanged.

Added two identity cases to the Presto tests; both fail on main and pass here. Full suite green.

Disclosure: found and fixed with Claude Code — the AI hit the round-trip mismatch, wrote the fix and the tests. I review every change and am responsible for it; the fail-before/pass-after tests re-run from the diff.

…LAUDE]

version_sql emitted the two range bounds as the underlying Tuple, so
`FOR VERSION BETWEEN '1' AND '2'` round-tripped to
`FOR VERSION BETWEEN ('1', '2')` (and FROM ... TO likewise). Render the
bounds joined by AND/TO instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

2 participants