Skip to content

Commit 5a17d9c

Browse files
committed
Call sqlContext.sql using reflection
1 parent 615c395 commit 5a17d9c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

spark/src/main/java/org/apache/zeppelin/spark/SparkSqlInterpreter.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
package org.apache.zeppelin.spark;
1919

20+
import java.lang.reflect.InvocationTargetException;
21+
import java.lang.reflect.Method;
2022
import java.util.List;
2123
import java.util.Properties;
2224
import java.util.concurrent.atomic.AtomicInteger;
@@ -114,8 +116,15 @@ public InterpreterResult interpret(String st, InterpreterContext context) {
114116
sc.setLocalProperty("spark.scheduler.pool", null);
115117
}
116118

119+
Object rdd = null;
120+
try {
121+
Method sqlMethod = sqlc.getClass().getMethod("sql", String.class);
122+
rdd = sqlMethod.invoke(sqlc, st);
123+
} catch (NoSuchMethodException | SecurityException | IllegalAccessException
124+
| IllegalArgumentException | InvocationTargetException e) {
125+
throw new InterpreterException(e);
126+
}
117127

118-
Object rdd = sqlc.sql(st);
119128
String msg = ZeppelinContext.showDF(sc, context, rdd, maxResult);
120129
return new InterpreterResult(Code.SUCCESS, msg);
121130
}

0 commit comments

Comments
 (0)