You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Rui Wang (Jira)" <ji...@apache.org> on 2020/09/13 02:22:00 UTC

[jira] [Commented] (CALCITE-4255) Add vararg UDFs support in org.apache.calcite.schema.ScalarFunction

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

Rui Wang commented on CALCITE-4255:
-----------------------------------



There was an effort to support CONCAT with varargs: https://github.com/apache/calcite/pull/1862 You might can check it as a reference to how to define UDF with varargs.

> Add vararg UDFs support in org.apache.calcite.schema.ScalarFunction
> -------------------------------------------------------------------
>
>                 Key: CALCITE-4255
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4255
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.25.0
>            Reporter: jamie12221
>            Priority: Minor
>
> It looks like vararg does not to be supported.
> It uses the exact number of arguments to find the function.
> {code:java}
> org.apache.calcite.sql.SqlUtil#lookupSubjectRoutines
> public static Iterator<SqlOperator> lookupSubjectRoutines(
>     SqlOperatorTable opTab,
>     SqlIdentifier funcName,
>     List<RelDataType> argTypes,
>     List<String> argNames,
>     SqlSyntax sqlSyntax,
>     SqlKind sqlKind,
>     SqlFunctionCategory category,
>     SqlNameMatcher nameMatcher,
>     boolean coerce) {
>   // start with all routines matching by name
>   Iterator<SqlOperator> routines =
>       lookupSubjectRoutinesByName(opTab, funcName, sqlSyntax, category,
>           nameMatcher);
>   // first pass:  eliminate routines which don't accept the given
>   // number of arguments
>   routines = filterRoutinesByParameterCount(routines, argTypes);
>   // NOTE: according to SQL99, procedures are NOT overloaded on type,
>   // only on number of arguments.
>   if (category == SqlFunctionCategory.USER_DEFINED_PROCEDURE) {
>     return routines;
>   }
> {code}



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