[
https://issues.apache.org/jira/browse/CALCITE-5987?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17768183#comment-17768183
]
Julian Hyde commented on CALCITE-5987:
--------------------------------------
I agree this might be useful. You are correct that not every SQL constant can
be simply represented as a literal, and types such as {{VARCHAR}} and
{{VARBINARY}} are cases in point.
> SqlImplementor loses type information for literals
> --------------------------------------------------
>
> Key: CALCITE-5987
> URL: https://issues.apache.org/jira/browse/CALCITE-5987
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Affects Versions: 1.35.0
> Reporter: Mihai Budiu
> Priority: Minor
>
> When converting a SqlNode to a String query, the conversion can produce SQL
> that computes different results. This happens because literals do not carry
> type information in the result string. For example, this plan:
> {code}
> rel#7:LogicalValues.(type=RecordType(VARCHAR(3) EXPR$0),tuples=[{ 'A' }])
> {code}
> will generate a SQL query:
> {code}
> SELECT 'A'
> {code}
> While the type of the former result is VARCHAR(3), the latter query produces
> a CHAR(1) result.
> It would be nice if SqlImplementor had an option to produce a query that
> preserves the output type, e.g.:
> {code}
> SELECT (CAST 'A' as VARCHAR(3))
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)