-
Notifications
You must be signed in to change notification settings - Fork 17.7k
feat(charts): add extensible extra metadata column to slices #41200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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()) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: The new chart metadata field is persisted on the model but not copied when charts are cloned, so dashboard duplication will silently drop Severity Level: Major
|
||
| 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") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both additions here (and the key-order one at line 156) only assert that the |
||
| } | ||
|
|
||
| @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", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds
extrato the import schema, but the REST API schemas don't declare it:ChartPostSchema(line 225),ChartPutSchema(line 287), andChartEntityResponseSchema(line 204). As written,extragets silently dropped onPOST/PUT /api/v1/chart/and is absent from theGETresponse, so the column is only reachable through import/export.Is REST read/write in scope for this PR? If so, add
extrato those three schemas the same wayquery_contextis wired (fields.String+utils.validate_json). If this is intentionally import-only groundwork for the SIP, can you note that in the PR description so the REST follow-up doesn't get lost?