Skip to content

Commit

Permalink
Setting adjust_database_uri for HiveEngineSpec (#2636)
Browse files Browse the repository at this point in the history
* Setting adjust_database_uri for HiveEngineSpec

* fix tests
  • Loading branch information
mistercrunch authored Apr 18, 2017
1 parent 76042be commit 91fe02c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions superset/db_engine_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,12 @@ def fetch_result_sets(cls, db, datasource_type, force=False):
return BaseEngineSpec.fetch_result_sets(
db, datasource_type, force=force)

@classmethod
def adjust_database_uri(cls, uri, selected_schema=None):
if selected_schema:
uri.database = selected_schema
return uri

@classmethod
def progress(cls, logs):
# 17/02/07 19:36:38 INFO ql.Driver: Total jobs = 5
Expand Down
6 changes: 3 additions & 3 deletions tests/model_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ def test_database_schema_postgres(self):
self.assertEquals('prod', db)

def test_database_schema_hive(self):
sqlalchemy_uri = 'hive://hive@hive.airbnb.io:10000/hive/default'
sqlalchemy_uri = 'hive://hive@hive.airbnb.io:10000/default?auth=NOSASL'
model = Database(sqlalchemy_uri=sqlalchemy_uri)
db = make_url(model.get_sqla_engine().url).database
self.assertEquals('hive/default', db)
self.assertEquals('default', db)

db = make_url(model.get_sqla_engine(schema='core_db').url).database
self.assertEquals('hive/core_db', db)
self.assertEquals('core_db', db)

def test_database_schema_mysql(self):
sqlalchemy_uri = 'mysql://root@localhost/superset'
Expand Down

0 comments on commit 91fe02c

Please sign in to comment.