fix(exasol): fix TO_CHAR parsing leaking canonical datetime format tokens #6650
+21
−2
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.
What motivated this PR?
When transpiling Exasol SQL that uses
TO_CHARwith datetime format strings to other SQL dialects using SQLGlot, canonical datetime tokens (e.g.,%a,%A) can appear in the generated SQL. These tokens are internal representations and are not valid syntax in target dialects, leading to execution errors or invalid SQL output.What was incorrect in the existing logic?
The Exasol parser canonicalises datetime format strings inside
TO_CHARexpressions. However, when generating SQL for a target dialect, these canonical tokens are not remapped to the target dialect’s format model.For example:
When transpiled from Exasol to Oracle could incorrectly produce:
instead of the valid Oracle format
'DY'.This behaviour only occurs for
TO_CHARexpressions; other datetime formatting paths remain correct.How does this PR resolve the issue?
This PR updates the Exasol
TO_CHARparsing logic so that canonical datetime tokens are correctly remapped when generating SQL for other dialects.The implementation:
TO_CHARparsing in the Exasol dialect; other datetime formatting paths are unaffected.Documentation and semantic notes
TO_CHARexpressions with datetime format strings.