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 <roberto@dealmeida.net>

* Updated down revision number to reflect new head

Co-authored-by: cccs-joel <cccs-joel@users.noreply.github.com>
Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
This commit is contained in:
cccs-joel 2021-12-13 17:28:21 -05:00 committed by GitHub
parent 0d2299cb60
commit e6db62c469
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 2 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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)
)