Repository navigation
Only read date unit words as date units when they are function arguments - #2825
Draft
edeadington wants to merge 1 commit into
Draft
edeadington wants to merge 1 commit into
edeadington wants to merge 1 commit into
Conversation
An unquoted YEAR, MONTH, DAY, HOUR, MINUTE or SECOND was parsed as a DateUnitExpression anywhere an expression could start, so a column with one of those names lost its spelling and its qualifier, and broke UPDATE ... SET (a, year) = ... with a ClassCastException. The word is now parsed as a Column and converted to a DateUnitExpression only when it is a whole argument of a function, which keeps its original spelling. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
edeadington
marked this pull request as ready for review
October 15, 2026 10:03
edeadington
marked this pull request as draft
October 15, 2026 10:54
This branch has not been 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.
Since
DateUnitExpressionwas added, an unquotedYEAR,MONTH,DAY,HOUR,MINUTEorSECONDis read as a date unit anywhere an expression can start, not only inside date functions. Columns with those names, which are common and not reserved in most databases, come back wrong:DateUnitExpressionalso kept only the enum, so the original spelling was lost anddayprinted back asDAY.This PR removes
DateUnitExpressionfromPrimaryExpression, so these words parse as columns again, as they did before. A word is converted to aDateUnitExpressiononly after the function has been parsed and only when it is a whole, unquoted argument of the function, e.g.DATEADD(day, 1, d)orLAST_DAY(d, month). This follows the same approach as the existing ODBCTIMESTAMPADDinterval normalisation. A word inside a larger argument expression, such asCOALESCE(year + 1, 0), stays a column.DateUnitExpressionnow keeps the text it was parsed from, sodayprints back asday.The new tests cover the unit argument, a bare column, a qualified column, a word nested within an argument expression, a quoted argument and the
UPDATEtuple.