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

Julian Hyde edited comment on CALCITE-1439 at 2/21/17 7:00 PM:
---------------------------------------------------------------

Catching all errors is overkill. We should not catch, say NullPointerException, 
AssertionError or OutOfMemoryError. The only error that should be masked is if 
the constant reducer encounters a SQL runtime error while evaluating the user's 
expression.

I think we need to refine the contract of the 
{{RelOptPlanner.Executor.reduce(RexBuilder rexBuilder, List<RexNode> constExps, 
List<RexNode> reducedValues)}} method. If any constant is not reduced 
correctly, the executor should write null (not a RexLiteral representing the 
NULL literal) into the corresponding slot in {{reducedValues}}. Or, if it 
chooses, into all slots.


was (Author: julianhyde):
Catching all errors is overkill. We should not catch, say NullPointerException, 
AssertionError or OutOfMemoryError. The only error that should be masked is if 
the constant reducer encounters a SQL runtime error while evaluating the user's 
expression.

I think we need to refine the contract of the 
{{RelOptPlanner.Executor.reduce(RexBuilder rexBuilder, List<RexNode> constExps, 
List<RexNode> reducedValues)}} method. If any constant is not reduced 
correctly, the executor should write null (not a RexLiteral representing the 
NULL literal) into that slot. Or, if it chooses, into all slots.

> Handling errors during constant reduction
> -----------------------------------------
>
>                 Key: CALCITE-1439
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1439
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Julian Hyde
>            Assignee: Julian Hyde
>
> A literal is a constant, and so a cast of a literal is also a constant, but 
> when we do constant reduction sometimes there are errors if the cast is not 
> valid. For example, the query
> {code}
> values cast('' as integer)
> {code}
> gives {{ExceptionInInitializerError}} and, to make matters worse, the Avatica 
> JDBC driver does not catch the exception (because it is a 
> {{java.lang.Error}}) and wrap it as a {{java.sql.SQLException}} as it ought 
> to.
> Note that {{cast('1.2' as integer)}} is also invalid but {{cast(' -1 ' as 
> integer)}} is valid.
> This issue probably also applies to divide-by-zero and other exceptions 
> evaluating scalar expressions.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to