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

Matt Wang commented on CALCITE-3243:
------------------------------------

[~zabetak] I find the reason, it's caused by  
https://issues.apache.org/jira/browse/CALCITE-3017. In this PR, it made the 
following changes:
{quote}_The main approach is to remove the implicit add of calls to 
{{JsonValueExpressionOperator}}, and use Java method overload instead._
{quote}
In SqlJsonValueFunction class, the SqlOperandTypeChecker is set to
{code:java}
OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.CHARACTER, 
SqlTypeFamily.ANY, SqlTypeFamily.ANY, SqlTypeFamily.ANY,SqlTypeFamily.ANY, 
SqlTypeFamily.ANY)
{code}
but in SqlJsonValueExpressionOperator, the SqlOperandTypeChecker is (when the 
json value is TRUE or 1, the SqlOperandTypeChecker actually is 
OperandTypes.STRING):

 
{code:java}
structured ? OperandTypes.ANY : OperandTypes.STRING{code}
So it can find the type error in 
_FamilyOperandTypeChecker.checkSingleOperandType()_ for 
SqlJsonValueExpressionOperator object.
 
 

> Incomplete validation of operands in JSON functions  
> -----------------------------------------------------
>
>                 Key: CALCITE-3243
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3243
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.20.0
>            Reporter: Stamatis Zampetakis
>            Assignee: Matt Wang
>            Priority: Major
>
> The operands of various JSON functions are not validated correctly. 
> Consider for instance the {{JSON_VALUE}} function and the following calls:
> {code:sql}
> json_value('{\"foo\":100}', 'strict $.foo')"
> json_value(1, 'strict $.foo')"
> json_value(TRUE, 'strict $.foo')"
> {code}
> The first call is legal but the next are not; if I am not wrong the operands 
> should be always CHAR or VARCHAR literals which is not the case above.
> Queries involving such calls fail at runtime when compiling generated code. I 
> guess that such kind of problems should be captured by the validator and we 
> should not even arrive at the code generation step.
> The problems can be easily reproduced by adding such calls in the 
> {{SqlOperatorBaseTest}}.
> The problem does not only affect {{JSON_VALUE}} but other JSON functions 
> (such as {{JSON_QUERY}} etc.) as well. 



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Reply via email to