[ 
https://issues.apache.org/jira/browse/CALCITE-6037?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ran Tao updated CALCITE-6037:
-----------------------------
    Description: 
In SqlLibraryOperators, we defined some SqlFunctions like below:
{code:java}
@LibraryOperator(libraries = {SPARK})
public static final SqlFunction ARRAY =
    SqlBasicFunction.create("ARRAY",
        SqlLibraryOperators::arrayReturnType,
        OperandTypes.SAME_VARIADIC);
{code}
{code:java}
public static final SqlFunction EXTRACT_VALUE =
    SqlBasicFunction.create("EXTRACTVALUE",
        ReturnTypes.VARCHAR_2000.andThen(SqlTypeTransforms.FORCE_NULLABLE),
        OperandTypes.STRING_STRING); {code}
{code:java}
public static final SqlFunction XML_TRANSFORM =
    SqlBasicFunction.create("XMLTRANSFORM",
        ReturnTypes.VARCHAR.andThen(SqlTypeTransforms.FORCE_NULLABLE),
        OperandTypes.STRING_STRING); {code}
however, they used a simplified constructor of SqlBasicFunction by set function 
category to Numeric forever.
{code:java}
/** Creates a {@code SqlBasicFunction}
 * with kind {@link SqlKind#OTHER_FUNCTION}
 * and category {@link SqlFunctionCategory#NUMERIC}. */
public static SqlBasicFunction create(String name,
    SqlReturnTypeInference returnTypeInference,
    SqlOperandTypeChecker operandTypeChecker) {
  return new SqlBasicFunction(name, SqlKind.OTHER_FUNCTION,
      SqlSyntax.FUNCTION, true, returnTypeInference, null,
      OperandHandlers.DEFAULT, operandTypeChecker, 0,
      SqlFunctionCategory.NUMERIC, call -> SqlMonotonicity.NOT_MONOTONIC);
} {code}
We should use constructor with SqlFunctionCategory to correct their category.

  was:
In SqlLibraryOperators, we defined some SqlFunctions like below:

 
{code:java}
@LibraryOperator(libraries = {SPARK})
public static final SqlFunction ARRAY =
    SqlBasicFunction.create("ARRAY",
        SqlLibraryOperators::arrayReturnType,
        OperandTypes.SAME_VARIADIC);
{code}
{code:java}
public static final SqlFunction EXTRACT_VALUE =
    SqlBasicFunction.create("EXTRACTVALUE",
        ReturnTypes.VARCHAR_2000.andThen(SqlTypeTransforms.FORCE_NULLABLE),
        OperandTypes.STRING_STRING); {code}
{code:java}
public static final SqlFunction XML_TRANSFORM =
    SqlBasicFunction.create("XMLTRANSFORM",
        ReturnTypes.VARCHAR.andThen(SqlTypeTransforms.FORCE_NULLABLE),
        OperandTypes.STRING_STRING); {code}
however, they used a simplified constructor of SqlBasicFunction by set function 
category to Numeric forever.
{code:java}
/** Creates a {@code SqlBasicFunction}
 * with kind {@link SqlKind#OTHER_FUNCTION}
 * and category {@link SqlFunctionCategory#NUMERIC}. */
public static SqlBasicFunction create(String name,
    SqlReturnTypeInference returnTypeInference,
    SqlOperandTypeChecker operandTypeChecker) {
  return new SqlBasicFunction(name, SqlKind.OTHER_FUNCTION,
      SqlSyntax.FUNCTION, true, returnTypeInference, null,
      OperandHandlers.DEFAULT, operandTypeChecker, 0,
      SqlFunctionCategory.NUMERIC, call -> SqlMonotonicity.NOT_MONOTONIC);
} {code}
We should use constructor with SqlFunctionCategory to correct their category.


> The function category of ARRAY/EXTRACT_VALUE/XML_TRANSFORM/EXTRACT/EXISTSNODE 
> is incorrect
> ------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-6037
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6037
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.35.0
>            Reporter: Ran Tao
>            Assignee: Ran Tao
>            Priority: Major
>             Fix For: 1.36.0
>
>
> In SqlLibraryOperators, we defined some SqlFunctions like below:
> {code:java}
> @LibraryOperator(libraries = {SPARK})
> public static final SqlFunction ARRAY =
>     SqlBasicFunction.create("ARRAY",
>         SqlLibraryOperators::arrayReturnType,
>         OperandTypes.SAME_VARIADIC);
> {code}
> {code:java}
> public static final SqlFunction EXTRACT_VALUE =
>     SqlBasicFunction.create("EXTRACTVALUE",
>         ReturnTypes.VARCHAR_2000.andThen(SqlTypeTransforms.FORCE_NULLABLE),
>         OperandTypes.STRING_STRING); {code}
> {code:java}
> public static final SqlFunction XML_TRANSFORM =
>     SqlBasicFunction.create("XMLTRANSFORM",
>         ReturnTypes.VARCHAR.andThen(SqlTypeTransforms.FORCE_NULLABLE),
>         OperandTypes.STRING_STRING); {code}
> however, they used a simplified constructor of SqlBasicFunction by set 
> function category to Numeric forever.
> {code:java}
> /** Creates a {@code SqlBasicFunction}
>  * with kind {@link SqlKind#OTHER_FUNCTION}
>  * and category {@link SqlFunctionCategory#NUMERIC}. */
> public static SqlBasicFunction create(String name,
>     SqlReturnTypeInference returnTypeInference,
>     SqlOperandTypeChecker operandTypeChecker) {
>   return new SqlBasicFunction(name, SqlKind.OTHER_FUNCTION,
>       SqlSyntax.FUNCTION, true, returnTypeInference, null,
>       OperandHandlers.DEFAULT, operandTypeChecker, 0,
>       SqlFunctionCategory.NUMERIC, call -> SqlMonotonicity.NOT_MONOTONIC);
> } {code}
> We should use constructor with SqlFunctionCategory to correct their category.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to