[GitHub] [flink] xuefuz commented on a change in pull request #9822: [FLINK-14216][table] introduce temp system functions to FunctionCatalog

2019-10-09 Thread GitBox
xuefuz commented on a change in pull request #9822: [FLINK-14216][table] 
introduce temp system functions to FunctionCatalog
URL: https://github.com/apache/flink/pull/9822#discussion_r333160531
 
 

 ##
 File path: 
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/FunctionCatalog.java
 ##
 @@ -240,13 +298,24 @@ public PlannerTypeInferenceUtil 
getPlannerTypeInferenceUtil() {
return plannerTypeInferenceUtil;
}
 
-   private void registerFunction(String name, FunctionDefinition 
functionDefinition) {
-   // TODO: should register to catalog
-   userFunctions.put(normalizeName(name), functionDefinition);
+   private void registerTempSystemFunction(String name, FunctionDefinition 
functionDefinition) {
+   tempSystemFunctions.put(normalizeName(name), 
functionDefinition);
+   }
+
+   private void registerTempCatalogFunction(ObjectIdentifier oi, 
FunctionDefinition functionDefinition) {
+   tempCatalogFunctions.put(normalizeObjectIdentifier(oi), 
functionDefinition);
}
 
@VisibleForTesting
static String normalizeName(String name) {
return name.toUpperCase();
}
+
+   @VisibleForTesting
+   static ObjectIdentifier normalizeObjectIdentifier(ObjectIdentifier oi) {
+   return ObjectIdentifier.of(
+   oi.getCatalogName(),
+   oi.getDatabaseName(),
 
 Review comment:
   Ok. sounds good.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] xuefuz commented on a change in pull request #9822: [FLINK-14216][table] introduce temp system functions to FunctionCatalog

2019-10-03 Thread GitBox
xuefuz commented on a change in pull request #9822: [FLINK-14216][table] 
introduce temp system functions to FunctionCatalog
URL: https://github.com/apache/flink/pull/9822#discussion_r331333915
 
 

 ##
 File path: 
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/FunctionCatalog.java
 ##
 @@ -128,12 +127,71 @@ public void registerScalarFunction(String name, 
ScalarFunction function) {
throw new TableException("Unknown function class: " + 
function.getClass());
}
 
-   registerFunction(
+   registerTempSystemFunction(
name,
definition
);
}
 
+   public void registerTempCatalogScalarFunction(ObjectIdentifier oi, 
ScalarFunction function) {
+   
UserFunctionsTypeHelper.validateInstantiation(function.getClass());
+   registerTempCatalogFunction(
+   oi,
+   new ScalarFunctionDefinition(oi.getObjectName(), 
function)
+   );
+   }
+
+   public  void registerTempCatalogTableFunction(
+   ObjectIdentifier oi,
+   TableFunction function,
+   TypeInformation resultType) {
+   // check if class not Scala object
+   
UserFunctionsTypeHelper.validateNotSingleton(function.getClass());
+   // check if class could be instantiated
+   
UserFunctionsTypeHelper.validateInstantiation(function.getClass());
+
+   registerTempCatalogFunction(
+   oi,
+   new TableFunctionDefinition(
+   oi.getObjectName(),
+   function,
+   resultType)
+   );
+   }
+
+   public  void registerTempCatalogAggregateFunction(
+   ObjectIdentifier oi,
+   UserDefinedAggregateFunction function,
+   TypeInformation resultType,
+   TypeInformation accType) {
 
 Review comment:
   Same as above.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] xuefuz commented on a change in pull request #9822: [FLINK-14216][table] introduce temp system functions to FunctionCatalog

2019-10-03 Thread GitBox
xuefuz commented on a change in pull request #9822: [FLINK-14216][table] 
introduce temp system functions to FunctionCatalog
URL: https://github.com/apache/flink/pull/9822#discussion_r331333067
 
 

 ##
 File path: 
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/FunctionCatalog.java
 ##
 @@ -240,13 +298,24 @@ public PlannerTypeInferenceUtil 
getPlannerTypeInferenceUtil() {
return plannerTypeInferenceUtil;
}
 
-   private void registerFunction(String name, FunctionDefinition 
functionDefinition) {
-   // TODO: should register to catalog
-   userFunctions.put(normalizeName(name), functionDefinition);
+   private void registerTempSystemFunction(String name, FunctionDefinition 
functionDefinition) {
+   tempSystemFunctions.put(normalizeName(name), 
functionDefinition);
+   }
+
+   private void registerTempCatalogFunction(ObjectIdentifier oi, 
FunctionDefinition functionDefinition) {
+   tempCatalogFunctions.put(normalizeObjectIdentifier(oi), 
functionDefinition);
}
 
@VisibleForTesting
static String normalizeName(String name) {
return name.toUpperCase();
}
+
+   @VisibleForTesting
+   static ObjectIdentifier normalizeObjectIdentifier(ObjectIdentifier oi) {
+   return ObjectIdentifier.of(
+   oi.getCatalogName(),
+   oi.getDatabaseName(),
 
 Review comment:
   Don't we need to normalize the cat/db names as well, if they are case 
insensitive.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] xuefuz commented on a change in pull request #9822: [FLINK-14216][table] introduce temp system functions to FunctionCatalog

2019-10-03 Thread GitBox
xuefuz commented on a change in pull request #9822: [FLINK-14216][table] 
introduce temp system functions to FunctionCatalog
URL: https://github.com/apache/flink/pull/9822#discussion_r33163
 
 

 ##
 File path: 
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/FunctionCatalog.java
 ##
 @@ -128,12 +127,71 @@ public void registerScalarFunction(String name, 
ScalarFunction function) {
throw new TableException("Unknown function class: " + 
function.getClass());
}
 
-   registerFunction(
+   registerTempSystemFunction(
name,
definition
);
}
 
+   public void registerTempCatalogScalarFunction(ObjectIdentifier oi, 
ScalarFunction function) {
+   
UserFunctionsTypeHelper.validateInstantiation(function.getClass());
+   registerTempCatalogFunction(
+   oi,
+   new ScalarFunctionDefinition(oi.getObjectName(), 
function)
+   );
+   }
+
+   public  void registerTempCatalogTableFunction(
+   ObjectIdentifier oi,
+   TableFunction function,
+   TypeInformation resultType) {
 
 Review comment:
   One more tab indention?


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:
us...@infra.apache.org


With regards,
Apache Git Services