superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From johnbod...@apache.org
Subject [incubator-superset] branch master updated: Adding column only if it doesn't already exist (#5179)
Date Wed, 13 Jun 2018 18:49:55 GMT
This is an automated email from the ASF dual-hosted git repository.

johnbodley pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new d6846d9  Adding column only if it doesn't already exist (#5179)
d6846d9 is described below

commit d6846d96ff08b4a4322075f2735107f2ed4d2490
Author: michellethomas <michelle.q.thomas@gmail.com>
AuthorDate: Wed Jun 13 11:49:43 2018 -0700

    Adding column only if it doesn't already exist (#5179)
---
 superset/data/__init__.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/superset/data/__init__.py b/superset/data/__init__.py
index 4f79be8..7bae20b 100644
--- a/superset/data/__init__.py
+++ b/superset/data/__init__.py
@@ -586,10 +586,13 @@ def load_birth_names():
     obj.main_dttm_col = 'ds'
     obj.database = utils.get_or_create_main_db()
     obj.filter_select_enabled = True
-    obj.columns.append(TableColumn(
-        column_name='num_california',
-        expression="CASE WHEN state = 'CA' THEN num ELSE 0 END"
-    ))
+
+    if not any(col.column_name == 'num_california' for col in obj.columns):
+        obj.columns.append(TableColumn(
+            column_name='num_california',
+            expression="CASE WHEN state = 'CA' THEN num ELSE 0 END"
+        ))
+
     db.session.merge(obj)
     db.session.commit()
     obj.fetch_metadata()

-- 
To stop receiving notification emails like this one, please contact
johnbodley@apache.org.

Mime
View raw message