[ 
https://issues.apache.org/jira/browse/CALCITE-5526?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17776924#comment-17776924
 ] 

Will Noble commented on CALCITE-5526:
-------------------------------------

Let me know if you think the two basic tests in [this draft 
PR|https://github.com/apache/calcite/pull/3476] fall short of illuminating the 
issue.

The {{UdtTest}} case passes and shows the happy path of scenario #2 above. The 
{{SqlUserDefinedTypeNameSpec}} nodes are converted to normal {{RelDataType}} 
objects during sql-to-rel conversion. Relational expressions are 
dialect-agnostic by nature. Losing the context that those types were originally 
UDTs is fine, even desirable.

The {{SqlParserTest}} is the base class for a few tests like 
{{CoreSqlParserTest}} and {{ServerParserTest}}. These tests involve parsing and 
then unparsing SQL without converting to rel nodes, so it exemplifies the 
complexity of scenario #1. With the draft implementation as currently written, 
{{CoreSqlParserTest}} passes, but {{ServerParserTest}} does not, because the 
former uses backtick identifier quoting and the latter uses double-quotes. 
While these tests function by simply parsing then unparsing, perhaps this does 
not represent a realistic use-case for Calcite, and could be revisited as a 
testing strategy. Otherwise, the implementation could be tweaked in various 
ways as described in that PR.

> Handle unparsing of literals based on type system
> -------------------------------------------------
>
>                 Key: CALCITE-5526
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5526
>             Project: Calcite
>          Issue Type: Task
>            Reporter: Will Noble
>            Assignee: Will Noble
>            Priority: Minor
>
> CALCITE-5424 dealt with parsing date/time literals via a custom type system, 
> however there is still no way to unparse them via the same type system. This 
> is handled in 
> [SqlDialect.unparseDateTimeLiteral|https://github.com/apache/calcite/blob/a0e119ea42def418957f214f539469f1aba76c18/core/src/main/java/org/apache/calcite/sql/SqlDialect.java#L468]
>  which simply calls the literal object's {{toString()}} method.
> The literal object (a subclass of {{SqlAbstractDateTimeLiteral}}) should not 
> be able to determine it's own unparsed representation by itself since it 
> could be unparsed in any dialect. Since the current system for resolving 
> custom types relies on access to the catalog, it appears we'll need to 
> introduce to {{SqlDialect}} a dependency on {{CalciteCatalogReader}} so it 
> can use the same mappings for unparsing as it does for parsing.



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

Reply via email to