Browse Source

HUE-3584 [editor] Solr SQL does not alway return the column values

Romain Rigaux 9 năm trước cách đây
mục cha
commit
5b4a04672a
1 tập tin đã thay đổi với 8 bổ sung2 xóa
  1. 8 2
      desktop/libs/notebook/src/notebook/connectors/solr.py

+ 8 - 2
desktop/libs/notebook/src/notebook/connectors/solr.py

@@ -63,7 +63,13 @@ class SolrApi(Api):
     if info.get('EXCEPTION'):
       raise QueryError(info['EXCEPTION'])
 
-    data = [[cell for cell in doc.values()] for doc in response['result-set']['docs']]
+    headers = []
+    for row in response['result-set']['docs']:
+      for col in row.keys():
+        if col not in headers:
+          headers.append(col)
+
+    data = [[doc.get(col) for col in headers] for doc in response['result-set']['docs']]
     has_result_set = bool(data)
 
     return {
@@ -77,7 +83,7 @@ class SolrApi(Api):
           'name': col,
           'type': '',
           'comment': ''
-        } for col in response['result-set']['docs'][0].keys()] if has_result_set else [],
+        } for col in headers] if has_result_set else [],
         'type': 'table'
       },
       'statement_id': 0,