Browse Source

HUE-8832 [spark] Support SparkSql in Livy

Romain 6 years ago
parent
commit
d439df8c11

+ 1 - 1
desktop/conf.dist/hue.ini

@@ -874,7 +874,7 @@
     #   name=SparkSql
     #   interface=hiveserver2
 
-    [[[sparksql]]]
+    [[[sql]]]
       name=SparkSql
       interface=livy
 

+ 1 - 1
desktop/conf/pseudo-distributed.ini.tmpl

@@ -876,7 +876,7 @@
     #   name=SparkSql
     #   interface=hiveserver2
 
-    [[[sparksql]]]
+    [[[sql]]]
       name=SparkSql
       interface=livy
 

+ 9 - 3
desktop/libs/notebook/src/notebook/connectors/spark_shell.py

@@ -294,9 +294,15 @@ class SparkApi(Api):
           images = [data['image/png']]
         except KeyError:
           images = []
-        data = [[data['text/plain']]]
-        meta = [{'name': 'Header', 'type': 'STRING_TYPE', 'comment': ''}]
-        type = 'text'
+        if 'application/json' in data:
+          result = data['application/json']
+          data = result['data']
+          meta = [{'name': field['name'], 'type': field['type'], 'comment': ''} for field in result['schema']['fields']]
+          type = 'table'
+        else:
+          data = [[data['text/plain']]]
+          meta = [{'name': 'Header', 'type': 'STRING_TYPE', 'comment': ''}]
+          type = 'text'
       else:
         data = table['data']
         headers = table['headers']