浏览代码

HUE-9413 [qb] Parameterize the Query History DB connection

As the properties are directly used in settings.py, they need to
live in the desktop module and no the jobbrowser app.

Note: not documented yet as soon will be the same as the Hue DB.
Romain 5 年之前
父节点
当前提交
39b01a8813

+ 2 - 2
apps/jobbrowser/src/jobbrowser/conf.py

@@ -67,10 +67,10 @@ ENABLE_QUERY_BROWSER = Config(
 
 
 ENABLE_HIVE_QUERY_BROWSER = Config(
 ENABLE_HIVE_QUERY_BROWSER = Config(
   key="enable_hive_query_browser",
   key="enable_hive_query_browser",
-  help=_("# Show the Hive query section for listing and showing more troubleshooting information."),
+  help=_("Show the Hive section for listing the query history and providing more troubleshooting information."),
   type=coerce_bool,
   type=coerce_bool,
   default=False
   default=False
-) 
+)
 
 
 ENABLE_HISTORY_V2 = Config(
 ENABLE_HISTORY_V2 = Config(
   key="enable_history_v2",
   key="enable_history_v2",

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

@@ -1634,7 +1634,7 @@
   # Show the Impala query section for listing and showing more troubleshooting information.
   # Show the Impala query section for listing and showing more troubleshooting information.
   ## enable_query_browser=true
   ## enable_query_browser=true
 
 
-  # Show the Hive query section for listing and showing more troubleshooting information.
+  # Show the Hive section for listing the query history and providing more troubleshooting information.
   ## enable_hive_query_browser=false
   ## enable_hive_query_browser=false
 
 
 
 

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

@@ -1620,7 +1620,7 @@
   # Show the Impala query section for listing and showing more troubleshooting information.
   # Show the Impala query section for listing and showing more troubleshooting information.
   ## enable_query_browser=true
   ## enable_query_browser=true
 
 
-  # Show the Hive query section for listing and showing more troubleshooting information.
+  # Show the Hive section for listing the query history and providing more troubleshooting information.
   ## enable_hive_query_browser=false
   ## enable_hive_query_browser=false
 
 
 
 

+ 57 - 0
desktop/core/src/desktop/conf.py

@@ -1968,6 +1968,63 @@ CONNECTORS = UnspecifiedConfigSection(
 )
 )
 
 
 
 
+QUERY_DATABASE = ConfigSection(
+  key='query_database',
+  help=_("""Configuration options for specifying the Query History Database."""),
+  members=dict(
+    ENGINE=Config(
+      key='engine',
+      help=_('Database engine, such as postgresql_psycopg2, mysql, or sqlite3.'),
+      type=coerce_database,
+      default='django.db.backends.sqlite3',
+    ),
+    NAME=Config(
+      key='name',
+      help=_('Database name, or path to DB if using sqlite3.'),
+      type=str,
+      default='das',
+    ),
+    USER=Config(
+      key='user',
+      help=_('Database username.'),
+      type=str,
+      default='',
+    ),
+    SCHEMA=Config(
+      key='schema',
+      help=_('Database schema, to be used only when public schema is revoked in postgres.'),
+      type=str,
+      default='public',
+    ),
+    PASSWORD=Config(
+      key='password',
+      help=_('Database password.'),
+      private=True,
+      type=str,
+      default="",
+    ),
+    HOST=Config(
+      key='host',
+      help=_('Database host.'),
+      type=str,
+      default='',
+    ),
+    PORT=Config(
+      key='port',
+      help=_('Database port.'),
+      type=coerce_port,
+      default='',
+    ),
+    OPTIONS=Config(
+      key='options',
+      help=_('Database options to send to the server when connecting.'),
+      type=coerce_json_dict,
+      dynamic_default=default_database_options
+    ),
+  )
+)
+
+
 def validate_ldap(user, config):
 def validate_ldap(user, config):
   res = []
   res = []
 
 

+ 12 - 18
desktop/core/src/desktop/settings.py

@@ -395,23 +395,17 @@ DATABASES = {
   'default': default_db
   'default': default_db
 }
 }
 
 
-    #engine=postgresql_psycopg2
-    #user=hstest
-    #name=hsdev
-    #host=localhost
-    #password=hstest
-    #options='{"options": "-c search_path=das,public"}'
-    #port=15432
-
-DATABASES['query'] = {
-  'ENGINE': 'django.db.backends.postgresql_psycopg2',
-  'HOST': 'localhost',
-  'NAME': 'hsdev',
-  'USER': 'hstest',
-  'PASSWORD': 'hstest',
-  'OPTIONS': {"options": "-c search_path=das,public"},
-  'PORT': 5432
-}
+if desktop.conf.QUERY_DATABASE.HOST.get():
+  DATABASES['query'] = {
+    'ENGINE': desktop.conf.QUERY_DATABASE.ENGINE.get(),
+    'HOST': desktop.conf.QUERY_DATABASE.HOST.get(),
+    'NAME': desktop.conf.QUERY_DATABASE.NAME.get(),
+    'USER': desktop.conf.QUERY_DATABASE.USER.get(),
+    'PASSWORD': desktop.conf.QUERY_DATABASE.PASSWORD.get(),
+    'OPTIONS': desktop.conf.QUERY_DATABASE.OPTIONS.get(),
+    'PORT': desktop.conf.QUERY_DATABASE.PORT.get(),
+    "SCHEMA" : desktop.conf.QUERY_DATABASE.SCHEMA.get(),
+  }
 
 
 CACHES = {
 CACHES = {
     'default': {
     'default': {
@@ -667,9 +661,9 @@ if not desktop.conf.DATABASE_LOGGING.get():
     from django.db.backends.utils import CursorWrapper
     from django.db.backends.utils import CursorWrapper
 
 
     BaseDatabaseWrapper.make_debug_cursor = lambda self, cursor: CursorWrapper(cursor, self)
     BaseDatabaseWrapper.make_debug_cursor = lambda self, cursor: CursorWrapper(cursor, self)
-
   disable_database_logging()
   disable_database_logging()
 
 
+
 ############################################################
 ############################################################
 # Searching saved documents in Oracle returns following error:
 # Searching saved documents in Oracle returns following error:
 #   DatabaseError: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
 #   DatabaseError: ORA-06502: PL/SQL: numeric or value error: character string buffer too small