drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Barclay (Drill) (JIRA)" <j...@apache.org>
Subject [jira] [Created] (DRILL-3431) CHAR not handled same as VARCHAR for cast to INTERVAL
Date Tue, 30 Jun 2015 19:19:04 GMT
Daniel Barclay (Drill) created DRILL-3431:
---------------------------------------------

             Summary: CHAR not handled same as VARCHAR for cast to INTERVAL
                 Key: DRILL-3431
                 URL: https://issues.apache.org/jira/browse/DRILL-3431
             Project: Apache Drill
          Issue Type: Bug
            Reporter: Daniel Barclay (Drill)


Expressions of type VARCHAR can be used in casting to an interval type. (The expression itself
is not rejected, even if a value is invalid and causes an error in execution.)

However, expressions of type CHAR are rejected.

Note that since character string literals are of type CHAR, that means that character string
literals cannot be cast to interval types.
&nbsp;

In the following, note how the expression of type VARCHAR (the cast specification casting
to VARCHAR(10)) is accepted (execution gets to the conversion's format syntax check), but
how the expressions of type CHAR (the cast to CHAR(10) and the direct character string literal)
are rejected:

{noformat}
0: jdbc:drill:zk=local> SELECT CAST( CAST( 'xxx' AS VARCHAR(10) ) AS INTERVAL HOUR ) FROM
INFORMATION_SCHEMA.CATALOGS;
Error: SYSTEM ERROR: IllegalArgumentException: Invalid format: "xxx"

Fragment 0:0

[Error Id: 237092b2-d203-4126-9a6b-e036bc229cd4 on dev-linux2:31010] (state=,code=0)
0: jdbc:drill:zk=local> SELECT CAST( CAST( 'xxx' AS CHAR(10) ) AS INTERVAL HOUR ) FROM
INFORMATION_SCHEMA.CATALOGS;
Jun 30, 2015 11:39:55 AM org.apache.calcite.sql.validate.SqlValidatorException <init>
SEVERE: org.apache.calcite.sql.validate.SqlValidatorException: Cast function cannot convert
value of type CHAR(10) to type INTERVAL HOUR
Jun 30, 2015 11:39:55 AM org.apache.calcite.runtime.CalciteException <init>
SEVERE: org.apache.calcite.runtime.CalciteContextException: From line 1, column 8 to line
1, column 57: Cast function cannot convert value of type CHAR(10) to type INTERVAL HOUR
Error: PARSE ERROR: From line 1, column 8 to line 1, column 57: Cast function cannot convert
value of type CHAR(10) to type INTERVAL HOUR


[Error Id: c50b7497-d85f-42af-bcee-512b26363a66 on dev-linux2:31010] (state=,code=0)
0: jdbc:drill:zk=local> SELECT CAST( 'xxx' AS INTERVAL HOUR ) FROM INFORMATION_SCHEMA.CATALOGS;
Jun 30, 2015 11:40:02 AM org.apache.calcite.sql.validate.SqlValidatorException <init>
SEVERE: org.apache.calcite.sql.validate.SqlValidatorException: Cast function cannot convert
value of type CHAR(3) to type INTERVAL HOUR
Jun 30, 2015 11:40:02 AM org.apache.calcite.runtime.CalciteException <init>
SEVERE: org.apache.calcite.runtime.CalciteContextException: From line 1, column 8 to line
1, column 37: Cast function cannot convert value of type CHAR(3) to type INTERVAL HOUR
Error: PARSE ERROR: From line 1, column 8 to line 1, column 37: Cast function cannot convert
value of type CHAR(3) to type INTERVAL HOUR


[Error Id: 16bda2bf-a907-4c1d-92e5-0344e4b8e286 on dev-linux2:31010] (state=,code=0)
0: jdbc:drill:zk=local> 
{noformat}


Is Drill missing an implicit cast (to convert CHAR to VARCHAR before checking types for the
case specification)?  Or is it that the cast specification code should accept type CHAR but
does not?  (Or is it something else?)







--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message