Skip to content

Commit

Permalink
Avoid using keys in HIVE_REGISTRY as UDF name for coral-trino (#116)
Browse files Browse the repository at this point in the history
* Bump calcite version to 1.21.0.148

* Avoid using key in HIVE_REGISTRY as UDF name for coral-trino
  • Loading branch information
ljfgem authored Aug 2, 2021
1 parent 82a9c71 commit e2d04c6
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,19 @@ private static void addDaliUDFs() {
ImmutableMultimap<String, HiveFunction> registry = HIVE_REGISTRY.getRegistry();
Converter<String, String> caseConverter = CaseFormat.UPPER_CAMEL.converterTo(CaseFormat.LOWER_UNDERSCORE);
for (Map.Entry<String, HiveFunction> entry : registry.entries()) {
if (!entry.getKey().startsWith("com.linkedin")) {
// we cannot use entry.getKey() as function name directly, because keys are all lowercase, which will
// fail to be converted to lowercase with underscore correctly
final String hiveFunctionName = entry.getValue().getHiveFunctionName();
if (!hiveFunctionName.startsWith("com.linkedin")) {
continue;
}
String[] nameSplit = entry.getKey().split("\\.");
// filter above guarantees we've atleast 2 entries
String[] nameSplit = hiveFunctionName.split("\\.");
// filter above guarantees we've at least 2 entries
String className = nameSplit[nameSplit.length - 1];
String funcName = caseConverter.convert(className);
SqlOperator op = entry.getValue().getSqlOperator();
for (int i = op.getOperandCountRange().getMin(); i <= op.getOperandCountRange().getMax(); i++) {
if (!isDaliUDFAlreadyAdded(entry.getKey(), i)) {
if (!isDaliUDFAlreadyAdded(hiveFunctionName, i)) {
createUDFMapEntry(UDF_MAP, op, i, funcName);
}
}
Expand Down

0 comments on commit e2d04c6

Please sign in to comment.