diff --git a/superset/charts/schemas.py b/superset/charts/schemas.py index 26e2470fbff6..434cd5d4b740 100644 --- a/superset/charts/schemas.py +++ b/superset/charts/schemas.py @@ -1735,6 +1735,7 @@ class ImportV1ChartSchema(Schema): viz_type = fields.String(required=True) params = fields.Dict() query_context = fields.String(allow_none=True, validate=utils.validate_json) + extra = fields.String(allow_none=True, validate=utils.validate_json) cache_timeout = fields.Integer(allow_none=True) uuid = fields.UUID(required=True) version = fields.String(required=True) diff --git a/superset/migrations/versions/2026-06-17_16-58_9d4b2e8c1f0a_add_extra_column_to_slices.py b/superset/migrations/versions/2026-06-17_16-58_9d4b2e8c1f0a_add_extra_column_to_slices.py new file mode 100644 index 000000000000..8fecb02cbff4 --- /dev/null +++ b/superset/migrations/versions/2026-06-17_16-58_9d4b2e8c1f0a_add_extra_column_to_slices.py @@ -0,0 +1,45 @@ +# 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. +"""add extra column to slices + +Revision ID: 9d4b2e8c1f0a +Revises: 78a40c08b4be +Create Date: 2026-06-17 16:58:00.000000 + +""" + +import sqlalchemy as sa + +from superset.migrations.shared.utils import add_columns, drop_columns +from superset.utils.core import MediumText + +# revision identifiers, used by Alembic. +revision = "9d4b2e8c1f0a" +down_revision = "78a40c08b4be" + + +def upgrade() -> None: + """Add the nullable ``extra`` column to ``slices``.""" + add_columns( + "slices", + sa.Column("extra", MediumText(), nullable=True), + ) + + +def downgrade() -> None: + """Drop the ``extra`` column from ``slices``.""" + drop_columns("slices", "extra") diff --git a/superset/models/slice.py b/superset/models/slice.py index 40de049df2ab..6f978a8a7b66 100644 --- a/superset/models/slice.py +++ b/superset/models/slice.py @@ -82,6 +82,7 @@ class Slice( # pylint: disable=too-many-public-methods viz_type = Column(String(250)) params = Column(utils.MediumText()) query_context = Column(utils.MediumText()) + extra = Column(utils.MediumText()) description = Column(Text) cache_timeout = Column(Integer) perm = Column(String(1000)) @@ -134,6 +135,7 @@ class Slice( # pylint: disable=too-many-public-methods "viz_type", "params", "query_context", + "extra", "cache_timeout", ] export_parent = "table" @@ -156,6 +158,7 @@ def clone(self) -> Slice: params=self.params, description=self.description, cache_timeout=self.cache_timeout, + extra=self.extra, ) @renders("datasource_name") diff --git a/tests/integration_tests/charts/commands_tests.py b/tests/integration_tests/charts/commands_tests.py index 75d8f7d2a22f..0999e8c1c644 100644 --- a/tests/integration_tests/charts/commands_tests.py +++ b/tests/integration_tests/charts/commands_tests.py @@ -104,6 +104,7 @@ def test_export_chart_command(self, mock_g): "uuid": str(example_chart.uuid), "version": "1.0.0", "query_context": None, + "extra": None, } @patch("superset.utils.core.g") @@ -152,6 +153,7 @@ def test_export_chart_command_key_order(self, mock_g): "viz_type", "params", "query_context", + "extra", "cache_timeout", "uuid", "version",