You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by be...@apache.org on 2021/12/13 22:29:30 UTC

[superset] branch master updated: fix: Change datatype of column type in BaseColumn to allow larger datatype names for complexed columns (#17360)

This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new e6db62c  fix: Change datatype of column type in BaseColumn to allow larger datatype names for complexed columns (#17360)
e6db62c is described below

commit e6db62c469b9dcf391015e7bb768a73316d9efbc
Author: cccs-joel <jo...@cyber.gc.ca>
AuthorDate: Mon Dec 13 17:28:21 2021 -0500

    fix: Change datatype of column type in BaseColumn to allow larger datatype names for complexed columns (#17360)
    
    * Change datatype of column type in BaseColumn to allow larger datatype names for complexed columns
    
    * Fixed formatting
    
    * Added an entry in the UPDATING.md file as a potential downtime
    
    * Update UPDATING.md
    
    Accept proposed changes.
    
    Co-authored-by: Beto Dealmeida <ro...@dealmeida.net>
    
    * Updated down revision number to reflect new head
    
    Co-authored-by: cccs-joel <cc...@users.noreply.github.com>
    Co-authored-by: Beto Dealmeida <ro...@dealmeida.net>
---
 UPDATING.md                                        |  1 +
 superset/connectors/base/models.py                 |  2 +-
 superset/datasets/schemas.py                       |  2 +-
 ...cbaac5_change_datatype_of_type_in_basecolumn.py | 46 ++++++++++++++++++++++
 4 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/UPDATING.md b/UPDATING.md
index 2533c1f..1b44f07 100644
--- a/UPDATING.md
+++ b/UPDATING.md
@@ -38,6 +38,7 @@ assists people when migrating to a new version.
 - [17539](https://github.com/apache/superset/pull/17539): all Superset CLI commands
   (init, load_examples and etc) require setting the FLASK_APP environment variable
   (which is set by default when .flaskenv is loaded)
+- [17360](https://github.com/apache/superset/pull/17360): changes the column type from `VARCHAR(32)` to `TEXT` in table `table_columns`, potentially requiring a table lock on MySQL dbs or taking some time to complete on large deployments.
 
 ### Deprecations
 
diff --git a/superset/connectors/base/models.py b/superset/connectors/base/models.py
index 47d0a21..f8a3261 100644
--- a/superset/connectors/base/models.py
+++ b/superset/connectors/base/models.py
@@ -578,7 +578,7 @@ class BaseColumn(AuditMixinNullable, ImportExportMixin):
     column_name = Column(String(255), nullable=False)
     verbose_name = Column(String(1024))
     is_active = Column(Boolean, default=True)
-    type = Column(String(32))
+    type = Column(Text)
     groupby = Column(Boolean, default=True)
     filterable = Column(Boolean, default=True)
     description = Column(Text)
diff --git a/superset/datasets/schemas.py b/superset/datasets/schemas.py
index 58258b1..637e282 100644
--- a/superset/datasets/schemas.py
+++ b/superset/datasets/schemas.py
@@ -42,7 +42,7 @@ def validate_python_date_format(value: str) -> None:
 class DatasetColumnsPutSchema(Schema):
     id = fields.Integer()
     column_name = fields.String(required=True, validate=Length(1, 255))
-    type = fields.String(validate=Length(1, 32))
+    type = fields.String(allow_none=True)
     verbose_name = fields.String(allow_none=True, Length=(1, 1024))
     description = fields.String(allow_none=True)
     expression = fields.String(allow_none=True)
diff --git a/superset/migrations/versions/3ba29ecbaac5_change_datatype_of_type_in_basecolumn.py b/superset/migrations/versions/3ba29ecbaac5_change_datatype_of_type_in_basecolumn.py
new file mode 100644
index 0000000..15f8148
--- /dev/null
+++ b/superset/migrations/versions/3ba29ecbaac5_change_datatype_of_type_in_basecolumn.py
@@ -0,0 +1,46 @@
+# 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.
+"""Change datatype of type in BaseColumn
+
+Revision ID: 3ba29ecbaac5
+Revises: abe27eaf93db
+Create Date: 2021-11-02 17:44:51.792138
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = "3ba29ecbaac5"
+down_revision = "abe27eaf93db"
+
+import sqlalchemy as sa
+from alembic import op
+from sqlalchemy.dialects import postgresql
+
+
+def upgrade():
+
+    with op.batch_alter_table("table_columns") as batch_op:
+        batch_op.alter_column(
+            "type", existing_type=sa.VARCHAR(length=32), type_=sa.TEXT()
+        )
+
+
+def downgrade():
+    with op.batch_alter_table("table_columns") as batch_op:
+        batch_op.alter_column(
+            "type", existing_type=sa.TEXT(), type_=sa.VARCHAR(length=32)
+        )