Przeglądaj źródła

[hplsql] temporary solution for left assist and table browser (#2707)

Ayush Goyal 3 lat temu
rodzic
commit
9c88b464f8

+ 16 - 3
desktop/core/src/desktop/js/catalog/api.ts

@@ -34,6 +34,7 @@ import DataCatalogEntry, {
   SourceMeta
 } from 'catalog/DataCatalogEntry';
 import { Cluster, Compute, Connector, Namespace } from 'config/types';
+import { findEditorConnector } from 'config/hueConfig';
 import { hueWindow } from 'types/types';
 import '../utils/json.bigDataParse';
 import sleep from 'utils/timing/sleep';
@@ -158,7 +159,7 @@ export const fetchDescribe = ({
       {
         format: 'json',
         cluster: JSON.stringify(entry.compute),
-        source_type: entry.getConnector().id,
+        source_type: getAssistConnectorId(entry),
         connector: JSON.stringify(entry.getConnector())
       },
       {
@@ -432,7 +433,7 @@ export const fetchSample = ({
       {
         notebook: {},
         snippet: JSON.stringify({
-          type: entry.getConnector().id,
+          type: getAssistConnectorId(entry),
           compute: entry.compute
         }),
         async: true,
@@ -551,7 +552,7 @@ export const fetchSourceMetadata = ({
     {
       notebook: {},
       snippet: JSON.stringify({
-        type: entry.getConnector().id,
+        type: getAssistConnectorId(entry),
         source: 'data'
       }),
       operation: entry.isModel() ? 'model' : 'default',
@@ -589,6 +590,18 @@ interface SearchOptions {
 
 type SearchResponse = { entities?: NavigatorMeta[] } | undefined;
 
+// this is a workaround for hplsql describe not working
+const getAssistConnectorId = (entry: DataCatalogEntry): string | number => {
+  const connector = entry.getConnector();
+  if (connector.dialect === 'hplsql') {
+    const hiveConnector = findEditorConnector(connector => connector.dialect === 'hive');
+    if (hiveConnector) {
+      return hiveConnector.id;
+    }
+  }
+  return connector.id;
+};
+
 export const searchEntities = ({
   limit,
   query,

+ 2 - 1
desktop/libs/notebook/src/notebook/connectors/base.py

@@ -399,7 +399,8 @@ def patch_snippet_for_connector(snippet):
   # TODO Connector unification
   """
   if snippet.get('connector') and snippet['connector'].get('type'):
-    snippet['type'] = snippet['connector']['type']  # To rename to 'id'
+    if snippet['connector']['dialect'] != 'hplsql':   # this is a workaround for hplsql describe not working
+      snippet['type'] = snippet['connector']['type']  # To rename to 'id'
     snippet['dialect'] = snippet['connector']['dialect']
   else:
     snippet['dialect'] = snippet['type']