bowenli86 commented on a change in pull request #10484: [FLINK-14906][table] 
create and drop temp system functions from DDL t…
URL: https://github.com/apache/flink/pull/10484#discussion_r355206648
 
 

 ##########
 File path: 
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/internal/TableEnvironmentImpl.java
 ##########
 @@ -843,29 +878,65 @@ private void dropCatalogFunction(DropFunctionOperation 
dropFunctionOperation) {
                                
.getReturnTypeOfAggregateFunction(aggregateFunction);
                        TypeInformation<ACC> accTypeInfo = 
UserFunctionsTypeHelper
                                
.getAccumulatorTypeOfAggregateFunction(aggregateFunction);
-
                        functionCatalog.registerTempCatalogAggregateFunction(
                                functionIdentifier,
                                aggregateFunction,
                                typeInfo,
                                accTypeInfo);
+
                } else if (functionDefinition instanceof 
TableFunctionDefinition) {
                        TableFunctionDefinition tableFunctionDefinition = 
(TableFunctionDefinition) functionDefinition;
                        TableFunction<T> tableFunction = (TableFunction<T>) 
tableFunctionDefinition.getTableFunction();
                        TypeInformation<T> typeInfo = UserFunctionsTypeHelper
                                .getReturnTypeOfTableFunction(tableFunction);
+
                        functionCatalog.registerTempCatalogTableFunction(
                                functionIdentifier,
                                tableFunction,
                                typeInfo);
                }
        }
 
+       private <T, ACC> void  registerSystemFunctionInFunctionCatalog(
+               String functionName, FunctionDefinition functionDefinition) {
+
+               if (functionDefinition instanceof ScalarFunctionDefinition) {
+                       ScalarFunctionDefinition scalarFunction = 
(ScalarFunctionDefinition) functionDefinition;
+                       functionCatalog.registerTempSystemScalarFunction(
+                               functionName, 
scalarFunction.getScalarFunction());
+               } else if (functionDefinition instanceof 
AggregateFunctionDefinition) {
+                       AggregateFunctionDefinition aggregateFunctionDefinition 
= (AggregateFunctionDefinition) functionDefinition;
+                       AggregateFunction<T, ACC > aggregateFunction =
+                               (AggregateFunction<T, ACC >) 
aggregateFunctionDefinition.getAggregateFunction();
+                       TypeInformation<T> typeInfo = UserFunctionsTypeHelper
+                               
.getReturnTypeOfAggregateFunction(aggregateFunction);
+                       TypeInformation<ACC> accTypeInfo = 
UserFunctionsTypeHelper
+                               
.getAccumulatorTypeOfAggregateFunction(aggregateFunction);
+                       functionCatalog.registerTempSystemAggregateFunction(
+                               functionName,
+                               aggregateFunction,
+                               typeInfo,
+                               accTypeInfo);
+
+               } else if (functionDefinition instanceof 
TableFunctionDefinition) {
+                       TableFunctionDefinition tableFunctionDefinition = 
(TableFunctionDefinition) functionDefinition;
+                       TableFunction<T> tableFunction = (TableFunction<T>) 
tableFunctionDefinition.getTableFunction();
+                       TypeInformation<T> typeInfo = UserFunctionsTypeHelper
+                               .getReturnTypeOfTableFunction(tableFunction);
+
+                       functionCatalog.registerTempSystemTableFunction(
+                               functionName,
+                               tableFunction,
+                               typeInfo);
+               }
+
+       }
+
        protected TableImpl createTable(QueryOperation tableOperation) {
-               return TableImpl.createTable(
 
 Review comment:
   revert

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to