[
https://issues.apache.org/jira/browse/CALCITE-3468?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16967010#comment-16967010
]
Julian Hyde commented on CALCITE-3468:
--------------------------------------
The problem is that Calcite's type system allows {{VARCHAR}} types with
unspecified/unbounded precision (as it should) but Oracle does not.
Best we can do is to use the maximum precision of that data type. {{CHAR(2000),
VARCHAR(4000)}} and {{VARCHAR2(4000)}} seem to be valid, and {{CHAR(2001),
VARCHAR(4001)}} and {{VARCHAR2(4001)}} give {{ORA-00910: specified length too
long for its datatype}}.
You can write {{CHAR}} without a precision, but that means {{CHAR(1)}}, which
is not what we want.
See [rextester|https://rextester.com/ZFEVP6116] if you want to do further
experiments.
We added Hive-like type system in CALCITE-401 and we should do the same for
Oracle here.
> Oracle cast to varchar does not use precision when it should
> ------------------------------------------------------------
>
> Key: CALCITE-3468
> URL: https://issues.apache.org/jira/browse/CALCITE-3468
> Project: Calcite
> Issue Type: Improvement
> Reporter: Lindsey Meyer
> Priority: Major
>
> We're trying to cast a node to a varchar with something like this:
> {noformat}
> relBuilder.cast(node, SqlTypeName.VARCHAR)
> {noformat}
> And in Oracle SQL, this generates sql like
> {noformat}
> CAST(node AS VARCHAR){noformat}
> which is incorrect. Oracle can only have VARCHAR types with an explicit
> precision.
> Looking at the code, it _seems_ like this should work with Oracle, so I'm not
> really sure what's going on here
--
This message was sent by Atlassian Jira
(v8.3.4#803005)