mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
Adding column only if it doesn't already exist (#5179)
This commit is contained in:
parent
7f30b48955
commit
d6846d96ff
@ -586,10 +586,13 @@ def load_birth_names():
|
|||||||
obj.main_dttm_col = 'ds'
|
obj.main_dttm_col = 'ds'
|
||||||
obj.database = utils.get_or_create_main_db()
|
obj.database = utils.get_or_create_main_db()
|
||||||
obj.filter_select_enabled = True
|
obj.filter_select_enabled = True
|
||||||
obj.columns.append(TableColumn(
|
|
||||||
column_name='num_california',
|
if not any(col.column_name == 'num_california' for col in obj.columns):
|
||||||
expression="CASE WHEN state = 'CA' THEN num ELSE 0 END"
|
obj.columns.append(TableColumn(
|
||||||
))
|
column_name='num_california',
|
||||||
|
expression="CASE WHEN state = 'CA' THEN num ELSE 0 END"
|
||||||
|
))
|
||||||
|
|
||||||
db.session.merge(obj)
|
db.session.merge(obj)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
obj.fetch_metadata()
|
obj.fetch_metadata()
|
||||||
|
Loading…
Reference in New Issue
Block a user