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

Stamatis Zampetakis commented on CALCITE-3485:
----------------------------------------------

As it is shown in the stack trace the error comes up when we attempt to infer 
the types of the operands. Given that there are multiple overloads for the user 
defined function the operator remains an {{SqlUnresolvedFunction}} which at the 
moment does not have any strategy for inferring the types of its operands thus 
it fails normally since it cannot determine the type for a dynamic parameter. 

I was thinking that at this point we shouldn't be strict with the operand 
inference (i.e, use {{InferTypes.ANY_NULLABLE}} or something along these 
lines). If there is a problem it will fail later when we resolve the real 
function. 

The same idea is also applied in 
[SqlUnresolvedFunction#inferReturnType(SqlOperatorBinding 
opBinding)|https://github.com/apache/calcite/blob/08c83afb16ba8dde3082735edf693d6914716ada/core/src/main/java/org/apache/calcite/sql/SqlUnresolvedFunction.java#L66].


> Validation error in UDF with overloads and dynamic parameter
> ------------------------------------------------------------
>
>                 Key: CALCITE-3485
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3485
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.21.0
>            Reporter: Stamatis Zampetakis
>            Assignee: Stamatis Zampetakis
>            Priority: Major
>
> The problem can be reproduced by defining multiple user defined functions 
> with the same name and trying to validate a query having at least one operand 
> that is a dynamic parameter.
> The interesting part of the stack trace is shown below:
> {noformat}
> com.onwbp.org.apache.calcite.runtime.CalciteContextException: At line 1, 
> column 84: Illegal use of dynamic parameter
>       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>       at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>       at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>       at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
>       at 
> com.onwbp.org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463)
>       at 
> com.onwbp.org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:835)
>       at 
> com.onwbp.org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:820)
>       at 
> com.onwbp.org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4881)
>       at 
> com.onwbp.org.apache.calcite.sql.validate.SqlValidatorImpl.inferUnknownTypes(SqlValidatorImpl.java:1801)
>       at 
> com.onwbp.org.apache.calcite.sql.validate.SqlValidatorImpl.inferUnknownTypes(SqlValidatorImpl.java:1880)
>       at 
> com.onwbp.org.apache.calcite.sql.validate.SqlValidatorImpl.validateWhereOrOn(SqlValidatorImpl.java:4052)
>       at 
> com.onwbp.org.apache.calcite.sql.validate.SqlValidatorImpl.validateWhereClause(SqlValidatorImpl.java:4044)
>       at 
> com.onwbp.org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3386)
>       at 
> com.onwbp.org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
>       at 
> com.onwbp.org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
>       at 
> com.onwbp.org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1009)
>       at 
> com.onwbp.org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:969)
>       at 
> com.onwbp.org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:216)
>       at 
> com.onwbp.org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:944)
>       at 
> com.onwbp.org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:651)
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to