You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/07/10 10:06:16 UTC

[GitHub] [flink] JingsongLi commented on issue #8920: [FLINK-13024][table] integrate FunctionCatalog with CatalogManager

JingsongLi commented on issue #8920: [FLINK-13024][table] integrate FunctionCatalog with CatalogManager
URL: https://github.com/apache/flink/pull/8920#issuecomment-509999248
 
 
   > Thanks @bowenli86. I added some feedback.
   > 
   > I think my biggest concern is how we pass input types and literals to functions. This should actually happen at a different level in the stack. For simplification, a function catalog should just lookup functions by name. The returned function definition of the factory should take care of receiving literals and input types. Since function definition does not return `TypeInference` yet, we could also use `getParameterType` and `getReturnType` of UDFs. They don't take literals but I think it is acceptable to postpone supporting this to the next release to still get this feature in before the feature freeze.
   
   My suggestion:
   
   Solution I: We only support function with single one method in 1.9. We rewrite `function.getResolver().getEvalMethod(typeInfos)` in hive UDF to find the single method in hive function by ourselves. Then, we can use this return type to override `getReturnType`. The biggest problem with this solution is that support for Hive functions is limited. 
   
   Solution II:
   We add `HiveScalarSqlFunction` in blink runner, it extends `ScalarSqlFunction`, override getFunction to set the input types and literals to cloned function. (Use java reflection to invoke `setArgumentTypesAndConstants`) And override `ReturnTypeInference`, to return the correct type with java reflection to `getHiveResultType`.
   In blink `FunctionCatalogOperatorTable. convertToSqlFunction`, we judge the function, if it is a hive function(Use java reflection), we decide to generate a `HiveScalarSqlFunction`.
   In this way, we can let get the correct return type from hive function and let hive function know its input types and literals.
   Advantage: 1.We can support most of hive functions.  2.Just change blink runner.
   Disadvantage: Use java reflection will be a little hack, and it's also a temporary solution.
   like the following:
   https://github.com/JingsongLi/flink/commit/3a74dcebd7342ceb6bb3b4da4f388360918369d5
   https://github.com/JingsongLi/flink/commit/6a3f9ecce5343f8cba979809066ef1a17b58d1b3
   
   I prefer Solution II, Hope to get your feedback.

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


With regards,
Apache Git Services