john-bodley commented on code in PR #23614: URL: https://github.com/apache/superset/pull/23614#discussion_r1162165263
########## superset/migrations/versions/2023-03-27_12-30_7e67aecbf3f1_chart_ds_constraint.py: ########## @@ -0,0 +1,66 @@ +# 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. +"""chart-ds-constraint + +Revision ID: 7e67aecbf3f1 +Revises: b5ea9d343307 +Create Date: 2023-03-27 12:30:01.164594 + +""" + +# revision identifiers, used by Alembic. +revision = "7e67aecbf3f1" +down_revision = "07f9a902af1b" + +import sqlalchemy as sa +from alembic import op +from sqlalchemy.ext.declarative import declarative_base + +from superset import db + +Base = declarative_base() + + +class Slice(Base): # type: ignore + __tablename__ = "slices" + + id = sa.Column(sa.Integer, primary_key=True) + slice_name = sa.Column(sa.String(250)) + datasource_type = sa.Column(sa.String(200)) + query_context = sa.Column(sa.Text) + + +def upgrade(): + bind = op.get_bind() + session = db.Session(bind=bind) + + with op.batch_alter_table("slices") as batch_op: + for slc in session.query(Slice).filter(Slice.datasource_type != "table").all(): + # clean up all charts with datasource_type not != table + slc.datasource_type = "table" Review Comment: @hughhhh per your response, > So those slices are most likely broken, because charts/slices don't know who to execute grabbing data when the datasource_type is Query I guess the question/concern is simply changing the `datasource_type` to `table` doesn't really mitigate the problematic charts as the `datasource_id` is then likely incorrect as well, i.e., it's referencing the `query.id` column rather than the `tables.id` column. Also please refer to my comment regarding the chart parameters as we (for right or wrong) doubly define the ID/type tuple. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org