ソースを参照

HUE-8740 [sqlalchemy] Support extra create_engine parameters

Romain 6 年 前
コミット
a300fcfe91

+ 6 - 1
desktop/libs/notebook/src/notebook/connectors/sql_alchemy.py

@@ -105,7 +105,12 @@ class SqlAlchemyApi(Api):
       url = raw_url.safe_substitute(**vars)
     else:
       url = self.options['url']
-    return create_engine(url)
+
+    options = self.options.copy()
+    options.pop('session', None)
+    options.pop('url', None)
+
+    return create_engine(url, **options)
 
   @query_error_handler
   def execute(self, notebook, snippet):

+ 11 - 1
docs/docs-site/content/administrator/configuration/editor/_index.md

@@ -505,6 +505,7 @@ Then give Hue the information about the database source:
 The dialect should be added to the Python system or Hue Python virtual environment:
 
       ./build/env/bin/pip install pybigquery
+      ./build/env/bin/pip install pyasn1==0.4.1
 
 From https://github.com/mxmzdlv/pybigquery.
 
@@ -513,7 +514,16 @@ Then give Hue the information about the database source:
     [[[bigquery]]]
        name = BigQuery
        interface=sqlalchemy
-       options='{"url": "bigquery://project"}'
+       options='{"url": "bigquery://projectName"}'
+
+To restrict to only one dataset:
+
+       options='{"url": "bigquery://projectName/datasetName"}'
+
+Supporting additional [connection parameters](https://github.com/mxmzdlv/pybigquery#connection-string-parameters):
+
+      options='{"url": "bigquery://", "credentials_path": "/etc/conf/hue/demo-4a0e4e08d81a.json"}'
+
 
 ### Apache Drill