-
Notifications
You must be signed in to change notification settings - Fork 14k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed a bug when querying with schema path to Redshift/Postgresql
- Loading branch information
Showing
2 changed files
with
65 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import unittest | ||
|
||
from sqlalchemy.engine.url import make_url | ||
|
||
from superset.models import Database | ||
|
||
|
||
class DatabaseModelTestCase(unittest.TestCase): | ||
def test_database_for_various_backend(self): | ||
sqlalchemy_uri = 'presto://presto.airbnb.io:8080/hive/default' | ||
model = Database(sqlalchemy_uri=sqlalchemy_uri) | ||
url = make_url(model.sqlalchemy_uri) | ||
db = model.get_database_for_various_backend(url, None) | ||
assert db == 'hive/default' | ||
db = model.get_database_for_various_backend(url, 'raw_data') | ||
assert db == 'hive/raw_data' | ||
|
||
sqlalchemy_uri = 'redshift+psycopg2://superset:[email protected]:5439/prod' | ||
model = Database(sqlalchemy_uri=sqlalchemy_uri) | ||
url = make_url(model.sqlalchemy_uri) | ||
db = model.get_database_for_various_backend(url, None) | ||
assert db == 'prod' | ||
db = model.get_database_for_various_backend(url, 'test') | ||
assert db == 'prod' | ||
|
||
sqlalchemy_uri = 'postgresql+psycopg2://superset:[email protected]:5439/prod' | ||
model = Database(sqlalchemy_uri=sqlalchemy_uri) | ||
url = make_url(model.sqlalchemy_uri) | ||
db = model.get_database_for_various_backend(url, None) | ||
assert db == 'prod' | ||
db = model.get_database_for_various_backend(url, 'adhoc') | ||
assert db == 'prod' | ||
|
||
sqlalchemy_uri = 'hive://[email protected]:10000/raw_data' | ||
model = Database(sqlalchemy_uri=sqlalchemy_uri) | ||
url = make_url(model.sqlalchemy_uri) | ||
db = model.get_database_for_various_backend(url, None) | ||
assert db == 'raw_data' | ||
db = model.get_database_for_various_backend(url, 'adhoc') | ||
assert db == 'adhoc' | ||
|
||
sqlalchemy_uri = 'mysql://superset:[email protected]/superset' | ||
model = Database(sqlalchemy_uri=sqlalchemy_uri) | ||
url = make_url(model.sqlalchemy_uri) | ||
db = model.get_database_for_various_backend(url, None) | ||
assert db == 'superset' | ||
db = model.get_database_for_various_backend(url, 'adhoc') | ||
assert db == 'adhoc' |