Add literal_processor to TIMESTAMP, TIME and DATE SQLAlchemy types - #631
Open
hashhar wants to merge 2 commits into
Open
Add literal_processor to TIMESTAMP, TIME and DATE SQLAlchemy types#631hashhar wants to merge 2 commits into
hashhar wants to merge 2 commits into
Conversation
hashhar
force-pushed
the
hashhar/609-timestamp-literal-processor
branch
from
August 18, 2026 14:52
0d300f5 to
916e775
Compare
Move the datetime, time, and date branches of _format_prepared_param verbatim into trino.temporal.format_temporal_literal. The rendered SQL is unchanged. A later commit reuses the function from the SQLAlchemy dialect.
TIMESTAMP and TIME had no literal_processor, so literal_binds=True raised CompileError for those columns. DATE columns compiled to a bare varchar literal that Trino rejects. Apache Superset's select_star() hits the failure when it reflects partition columns. The new literal processors delegate to trino.temporal, which the DBAPI parameter formatter already uses, so a value compiles to the same SQL on both paths. The shared renderer gains several fixes. Named zones render as zone names for pytz as well as zoneinfo. Fixed offsets render as +HH:MM instead of tzname() output. Years below 1000 render zero-padded on every platform. Sub-minute UTC offsets raise an error because a Trino literal cannot represent them. In SQLAlchemy, values of the wrong Python type raise CompileError instead of turning into bad SQL.
hashhar
force-pushed
the
hashhar/609-timestamp-literal-processor
branch
from
August 19, 2026 22:15
916e775 to
0da6bad
Compare
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.
literal_binds=TrueraisedCompileErrorforTIMESTAMPandTIMEcolumns and compiledDATEto a bare varchar literal that Trino rejects. Superset'sselect_star()hits this on partition columns.The temporal formatting moves into a shared
trino.temporalmodule used by both the DBAPI and SQLAlchemy paths so a value compiles to the same SQL:ZoneInfo, pytz) render as zone names (Asia/Kolkata) instead of fixed offsets.ZoneInfo-awaretimekeeps its zone offset instead of silently dropping it.CompileErrorinstead of turning into bad SQL.Covers reflected columns only. The generic SQLAlchemy
DateTime/Time/Datetypes stay uncovered (pre-existing gap).Release notes
(x) Release notes are required, with the following suggested text: