-
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.
[fix] make datasource names non-nullable
- Loading branch information
1 parent
05b6767
commit acbbbd4
Showing
9 changed files
with
77 additions
and
14 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
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
49 changes: 49 additions & 0 deletions
49
superset/migrations/versions/b6fa807eac07_make_datasource_names_non_nullable.py
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,49 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
"""make_datasource_names_non_nullable | ||
Revision ID: b6fa807eac07 | ||
Revises: 258b5280a45e | ||
Create Date: 2019-10-02 00:29:16.679272 | ||
""" | ||
from alembic import op | ||
from sqlalchemy import String | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "b6fa807eac07" | ||
down_revision = "258b5280a45e" | ||
|
||
|
||
def upgrade(): | ||
with op.batch_alter_table("clusters") as batch_op: | ||
batch_op.alter_column("cluster_name", existing_type=String(250), nullable=False) | ||
with op.batch_alter_table("dbs") as batch_op: | ||
batch_op.alter_column( | ||
"database_name", existing_type=String(250), nullable=False | ||
) | ||
with op.batch_alter_table("tables") as batch_op: | ||
batch_op.alter_column("table_name", existing_type=String(250), nullable=False) | ||
|
||
|
||
def downgrade(): | ||
with op.batch_alter_table("clusters") as batch_op: | ||
batch_op.alter_column("cluster_name", existing_type=String(250), nullable=True) | ||
with op.batch_alter_table("dbs") as batch_op: | ||
batch_op.alter_column("database_name", existing_type=String(250), nullable=True) | ||
with op.batch_alter_table("tables") as batch_op: | ||
batch_op.alter_column("table_name", existing_type=String(250), nullable=True) |
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
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 |
---|---|---|
|
@@ -32,7 +32,7 @@ class DatabaseModelTestCase(SupersetTestCase): | |
) | ||
def test_database_schema_presto(self): | ||
sqlalchemy_uri = "presto://presto.airbnb.io:8080/hive/default" | ||
model = Database(sqlalchemy_uri=sqlalchemy_uri) | ||
model = Database(database_name="test_database", sqlalchemy_uri=sqlalchemy_uri) | ||
|
||
db = make_url(model.get_sqla_engine().url).database | ||
self.assertEquals("hive/default", db) | ||
|
@@ -41,7 +41,7 @@ def test_database_schema_presto(self): | |
self.assertEquals("hive/core_db", db) | ||
|
||
sqlalchemy_uri = "presto://presto.airbnb.io:8080/hive" | ||
model = Database(sqlalchemy_uri=sqlalchemy_uri) | ||
model = Database(database_name="test_database", sqlalchemy_uri=sqlalchemy_uri) | ||
|
||
db = make_url(model.get_sqla_engine().url).database | ||
self.assertEquals("hive", db) | ||
|
@@ -51,7 +51,7 @@ def test_database_schema_presto(self): | |
|
||
def test_database_schema_postgres(self): | ||
sqlalchemy_uri = "postgresql+psycopg2://postgres.airbnb.io:5439/prod" | ||
model = Database(sqlalchemy_uri=sqlalchemy_uri) | ||
model = Database(database_name="test_database", sqlalchemy_uri=sqlalchemy_uri) | ||
|
||
db = make_url(model.get_sqla_engine().url).database | ||
self.assertEquals("prod", db) | ||
|
@@ -67,7 +67,7 @@ def test_database_schema_postgres(self): | |
) | ||
def test_database_schema_hive(self): | ||
sqlalchemy_uri = "hive://[email protected]:10000/default?auth=NOSASL" | ||
model = Database(sqlalchemy_uri=sqlalchemy_uri) | ||
model = Database(database_name="test_database", sqlalchemy_uri=sqlalchemy_uri) | ||
db = make_url(model.get_sqla_engine().url).database | ||
self.assertEquals("default", db) | ||
|
||
|
@@ -79,7 +79,7 @@ def test_database_schema_hive(self): | |
) | ||
def test_database_schema_mysql(self): | ||
sqlalchemy_uri = "mysql://root@localhost/superset" | ||
model = Database(sqlalchemy_uri=sqlalchemy_uri) | ||
model = Database(database_name="test_database", sqlalchemy_uri=sqlalchemy_uri) | ||
|
||
db = make_url(model.get_sqla_engine().url).database | ||
self.assertEquals("superset", db) | ||
|
@@ -93,7 +93,7 @@ def test_database_schema_mysql(self): | |
def test_database_impersonate_user(self): | ||
uri = "mysql://root@localhost" | ||
example_user = "giuseppe" | ||
model = Database(sqlalchemy_uri=uri) | ||
model = Database(database_name="test_database", sqlalchemy_uri=uri) | ||
|
||
model.impersonate_user = True | ||
user_name = make_url(model.get_sqla_engine(user_name=example_user).url).username | ||
|
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