diff --git a/UPDATING.md b/UPDATING.md index 2533c1ffd0d44..1b44f078292d6 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 47d0a21657f19..f8a3261805e7c 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 58258b1dda158..637e282a2b91d 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 0000000000000..15f81488a310c --- /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) + )