You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by 月宫的木马兔 <gr...@qq.com> on 2020/02/11 02:16:10 UTC

How to add a UDF with variable number parameter in calcite?

hi experts,
&nbsp; I'm using Apache Calcite to validate SQL. The problem is when I add a UDF with variable number parameter, the validator can not find this function.



Version of Calcite is 1.21.0

Here this is my code.

TestfuncFunction.java
public class ConcatFunction {     public String eval(String... arg0) {         return "";     } }AddUDF:SchemaPlus schemaPlus = Frameworks.createRootSchema(true);schemaPlus.add("CONCAT", ScalarFunctionImpl.create(ConcatFunction.class),"eval"));SQL: select concat(name, " ") from test_tableException:

Re: How to add a UDF with variable number parameter in calcite?

Posted by Feng Zhu <we...@gmail.com>.
Vargs UDF is not supported in Calcite now.
There are some discussions[1] and on-going work[2] for it.

[1] https://issues.apache.org/jira/browse/CALCITE-2772
[2] https://github.com/apache/calcite/pull/1405]

月宫的木马兔 <gr...@qq.com> 于2020年2月11日周二 上午10:20写道:

> hi experts,
>   I'm using Apache Calcite to validate SQL. The problem is when I add a
> UDF with variable number parameter, the validator can not find this
> function.
>
> Version of Calcite is 1.21.0
>
> Here this is my code.
>
> *TestfuncFunction.java*
>
> public class ConcatFunction {
>     public String eval(String... arg0) {
>         return "";
>     }}
>
> *AddUDF:*
>
> SchemaPlus schemaPlus = Frameworks.createRootSchema(true);
>
> schemaPlus.add("CONCAT", ScalarFunctionImpl.create(ConcatFunction.class),"eval"));
>
> *SQL:* select concat(name, " ") from test_table
>
> *Exception:*
>
>
>
>
>
>
>