Skip to content

Commit 1de59a3

Browse files
authored
Add bridge to cast ObjectInspector from UDF class loader to main class loader (#73)
1 parent d948118 commit 1de59a3

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

coral-hive/src/main/java/com/linkedin/coral/hive/hive2rel/functions/ArtifactsResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class ArtifactsResolver {
4040
private final Ivy _ivyInstance;
4141
public ArtifactsResolver() {
4242
// Ivy spews a lot of junk on the console. Hiding it
43-
Message.setDefaultLogger(new DefaultMessageLogger(getIvyLogLevel()));
43+
Message.setDefaultLogger(new DefaultMessageLogger(Message.MSG_ERR));
4444
final IvySettings settings = setupIvySettings();
4545
_ivyInstance = Ivy.newInstance(settings);
4646
}

coral-hive/src/main/java/com/linkedin/coral/hive/hive2rel/functions/HiveGenericUDFReturnTypeInference.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ public RelDataType inferReturnType(SqlOperatorBinding sqlOperatorBinding) {
4646
try {
4747
Class dynamicallyLoadedUdfClass = getDynamicallyLoadedUdfClass();
4848
return getRelDataType(
49-
(ObjectInspector) dynamicallyLoadedUdfClass
50-
.getMethod("initialize", getDynamicallyLoadedObjectInspectorArrayClass()).invoke(
51-
dynamicallyLoadedUdfClass.newInstance(), getDynamicallyLoadedObjectInspectors(inputObjectInspectors)),
49+
getContextObjectInspector(
50+
dynamicallyLoadedUdfClass.getMethod("initialize", getDynamicallyLoadedObjectInspectorArrayClass()).invoke(
51+
dynamicallyLoadedUdfClass.newInstance(),
52+
new Object[] { getDynamicallyLoadedObjectInspectors(inputObjectInspectors) })),
5253
sqlOperatorBinding.getTypeFactory());
5354
} catch (NoSuchMethodException e) {
5455
throw new RuntimeException(
@@ -146,7 +147,7 @@ private final ObjectInspector getContextObjectInspector(Object oi) {
146147
return TypeInfoUtils
147148
.getStandardJavaObjectInspectorFromTypeInfo(TypeInfoUtils.getTypeInfoFromTypeString(typeInfoString));
148149
} catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
149-
throw new RuntimeException("Could not get Context ObjectInspector from UDF ObjectInspector.", e);
150+
throw new RuntimeException("Could not get Context ObjectInspector from dynamically loaded ObjectInspector.", e);
150151
}
151152
}
152153

0 commit comments

Comments
 (0)