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

ASF GitHub Bot commented on PHOENIX-3355:
-----------------------------------------

Github user maryannxue commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/222#discussion_r87512188
  
    --- Diff: 
phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixScalarFunction.java
 ---
    @@ -90,6 +153,10 @@ public PFunction getFunctionInfo() {
             return functionInfo;
         }
     
    +    public FunctionParseNode.BuiltInFunctionInfo getParseInfo(){
    --- End diff --
    
    So here maybe all we need is the exact FunctionExpression class. In case of 
abstract function class, we need some additional information in 
BuiltinFunctionInfo. So I'm thinking to add annotation for those derived 
function expression classes, e.g. RoundDateFunction as well. And in order to 
let the standalone Phoenix function map not to add the derived signatures and 
meanwhile to make sure that calcite-phoenix's function map will not have the 
abstract  function classes, we can add one more attribute to BuiltinFunction as:
    {code}
    
        @Retention(RetentionPolicy.RUNTIME)
        @Target(ElementType.TYPE)
        public
        @interface Argument {
            Class<? extends PDataType>[] allowedTypes() default {};
            boolean isConstant() default false;
            String defaultValue() default "";
            String enumeration() default "";
            String minValue() default "";
            String maxValue() default "";
            FunctionClassType classType() default FunctionClassType.NONE;
        }
        
        public enum FunctionClassType {
            NONE,
            ABSTRACT,
            DERIVED,
        }
    {code}
    
    Thus in CalciteUtils, we'll use reflection to get the function constructor, 
either with or without StatementContext, depending on each individual function, 
and instantiate the instance.


> Register Phoenix built-in functions as Calcite functions
> --------------------------------------------------------
>
>                 Key: PHOENIX-3355
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-3355
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: James Taylor
>            Assignee: Eric Lomore
>              Labels: calcite
>         Attachments: PHOENIX-3355.function_constructor.patch, 
> PHOENIX-3355.wip, PHOENIX-3355.wip2
>
>
> We should register all Phoenix built-in functions that don't exist in Calcite.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to