TJ Banghart created CALCITE-5616:
------------------------------------

             Summary: Allow unparsing of SqlIntervalQualifier in EXTRACT to be 
overridden by dialects
                 Key: CALCITE-5616
                 URL: https://issues.apache.org/jira/browse/CALCITE-5616
             Project: Calcite
          Issue Type: Improvement
          Components: core
            Reporter: TJ Banghart


In {{SqlExtractFunction#unparse}}, the first operand is passed to  
{{SqlIntervalQualifier.asIdentifier}} which returns a {{SqlIdentifier}} [if the 
operand is a 
{{SqlIntervalQualifier}}|https://github.com/apache/calcite/blob/5c7be55ffee836366dcc7fefb6adfc0b8c47465f/core/src/main/java/org/apache/calcite/sql/SqlIntervalQualifier.java#L1366-L1370].
 

{{SqlIdentifier#unparse}} is handled by 
[{{SqlUtil#unparseSqlIdentifierSyntax}}|https://github.com/apache/calcite/blob/5c7be55ffee836366dcc7fefb6adfc0b8c47465f/core/src/main/java/org/apache/calcite/sql/SqlUtil.java#L384-L412]
 which has no dialect context.

We should unparse these interval identifiers in the target dialect using the 
[existing {{SqlDialect#unparseSqlIntervalQualifier}} 
method|https://github.com/apache/calcite/blob/5c7be55ffee836366dcc7fefb6adfc0b8c47465f/core/src/main/java/org/apache/calcite/sql/SqlDialect.java#L492-L538].
 This would help prevent errors when unparsing interval identifiers for some 
dialects. 

For example, BigQuery uses {{DAYOFWEEK}} rather than {{DOW}} but there is 
currently no way to override this in {{BigQuerySqlDialect}}.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to