瀏覽代碼

HUE-5841 [metadata] Sample popup not showing up when listing certain databases in Search

Romain Rigaux 8 年之前
父節點
當前提交
5f82f6b610

+ 3 - 3
desktop/libs/dashboard/src/dashboard/conf.py

@@ -31,7 +31,7 @@ IS_ENABLED = Config(
   type=coerce_bool
 )
 
- 
+
 def get_properties():
   if ENGINES.get():
     engines = ENGINES.get()
@@ -52,7 +52,7 @@ def get_properties():
         'nesting': False,
       },
     }
-    
+
 def get_engines(user):
   engines = []
   apps = get_apps_dict()
@@ -76,7 +76,7 @@ def get_engines(user):
       }
       for interpreter in get_ordered_interpreters(user) if interpreter['interface'] in ('hiveserver2', 'jdbc', 'rdbms')
     ]
-    
+
   return engines
 
 

+ 2 - 0
desktop/libs/metadata/src/metadata/navigator_api.py

@@ -243,6 +243,8 @@ def _augment_highlighting(query_s, records):
     name = record.get('originalName', '') or ''
     record['hue_description'] = ''
     record['hue_name'] = record.get('parentPath', '') if record.get('parentPath') else ''
+    if record.get('parentPath') is None:
+      record['parentPath'] = ''
 
     if record['hue_name'] and record.get('sourceType', '') != 'S3':
       record['hue_name'] = (record['hue_name'].replace('/', '.') + '.').lstrip('.')

+ 13 - 0
desktop/libs/metadata/src/metadata/navigator_tests.py

@@ -31,6 +31,7 @@ from desktop.lib.test_utils import add_to_group, grant_access
 from hadoop.pseudo_hdfs4 import is_live_cluster
 
 from metadata.conf import has_navigator
+from metadata.navigator_api import _augment_highlighting
 from metadata.navigator_client import NavigatorApi
 
 
@@ -147,3 +148,15 @@ class TestNavigator(object):
     for key, value in post_dict.items():
       json_dict[key] = json.dumps(value)
     return json_dict
+
+
+class TestNavigatorAPI(object):
+
+  def test_augment_highlighting_emty_db_name(self):
+    query_s = 'type:database*'
+    records = [
+      {u'customProperties': None, u'deleteTime': None, u'fileSystemPath': u'hdfs://Enchilada/data/marketsriskcalc/work/hive', u'description': None, u'params': None, u'type': u'DATABASE', u'internalType': u'hv_database', u'sourceType': u'HIVE', u'tags': None, u'deleted': False, u'technicalProperties': None, u'userEntity': False, u'originalDescription': None, u'metaClassName': u'hv_database', u'properties': None, u'identity': u'51002517', u'firstClassParentId': None, u'name': None, u'extractorRunId': u'845beb21b95783c4f55276a4ae38a332##3', u'sourceId': u'56850544', u'packageName': u'nav', u'parentPath': None, u'originalName': u'marketsriskcalc_work'}, {u'customProperties': None, u'deleteTime': None, u'fileSystemPath': u'hdfs://Enchilada/data/catssolprn/work/hive', u'description': None, u'params': None, u'type': u'DATABASE', u'internalType': u'hv_database', u'sourceType': u'HIVE', u'tags': None, u'deleted': False, u'technicalProperties': None, u'userEntity': False, u'originalDescription': None, u'metaClassName': u'hv_database', u'properties': None, u'identity': u'51188932', u'firstClassParentId': None, u'name': None, u'extractorRunId': u'845beb21b95783c4f55276a4ae38a332##3', u'sourceId': u'56850544', u'packageName': u'nav', u'parentPath': None, u'originalName': u'catssolprn_work'}
+    ]
+
+    _augment_highlighting(query_s, records)
+    assert_equal('', records[0]['parentPath'])