From 8a2c84ed24db2b4b1a23c0a8d639a37b0889aba2 Mon Sep 17 00:00:00 2001 From: justinpark Date: Fri, 8 Mar 2024 16:01:53 -0800 Subject: [PATCH] change to single column index --- ..._b9f38daf22be_add_query_sql_editor_id_index.py} | 14 +++++++------- superset/models/sql_lab.py | 7 ++----- 2 files changed, 9 insertions(+), 12 deletions(-) rename superset/migrations/versions/{2024-03-04_14-48_efb7a20ff8d8_add_query_sql_editor_id_index.py => 2024-04-15_09-36_b9f38daf22be_add_query_sql_editor_id_index.py} (84%) diff --git a/superset/migrations/versions/2024-03-04_14-48_efb7a20ff8d8_add_query_sql_editor_id_index.py b/superset/migrations/versions/2024-04-15_09-36_b9f38daf22be_add_query_sql_editor_id_index.py similarity index 84% rename from superset/migrations/versions/2024-03-04_14-48_efb7a20ff8d8_add_query_sql_editor_id_index.py rename to superset/migrations/versions/2024-04-15_09-36_b9f38daf22be_add_query_sql_editor_id_index.py index 82f4f29cc5891..6a0c0dbb265f3 100644 --- a/superset/migrations/versions/2024-03-04_14-48_efb7a20ff8d8_add_query_sql_editor_id_index.py +++ b/superset/migrations/versions/2024-04-15_09-36_b9f38daf22be_add_query_sql_editor_id_index.py @@ -16,22 +16,22 @@ # under the License. """add_query_sql_editor_id_index -Revision ID: efb7a20ff8d8 -Revises: be1b217cd8cd -Create Date: 2024-03-04 14:48:16.998927 +Revision ID: b9f38daf22be +Revises: 5ad7321c2169 +Create Date: 2024-04-15 09:36:46.589419 """ # revision identifiers, used by Alembic. -revision = "efb7a20ff8d8" -down_revision = "be1b217cd8cd" +revision = "b9f38daf22be" +down_revision = "5ad7321c2169" from alembic import op from superset.migrations.shared.utils import table_has_index table = "query" -index = "ix_query_user_id_sql_editor_id" +index = "ix_sql_editor_id" def upgrade(): @@ -39,7 +39,7 @@ def upgrade(): op.create_index( op.f(index), table, - ["user_id", "sql_editor_id"], + ["sql_editor_id"], unique=False, ) diff --git a/superset/models/sql_lab.py b/superset/models/sql_lab.py index 0987bd2d0a0ca..84e8ae2d3626f 100644 --- a/superset/models/sql_lab.py +++ b/superset/models/sql_lab.py @@ -106,7 +106,7 @@ class Query( user_id = Column(Integer, ForeignKey("ab_user.id"), nullable=True) status = Column(String(16), default=QueryStatus.PENDING) tab_name = Column(String(256)) - sql_editor_id = Column(String(256)) + sql_editor_id = Column(String(256), index=True) schema = Column(String(256)) sql = Column(MediumText()) # Query to retrieve the results, @@ -148,10 +148,7 @@ class Query( ) user = relationship(security_manager.user_model, foreign_keys=[user_id]) - __table_args__ = ( - sqla.Index("ti_user_id_changed_on", user_id, changed_on), - sqla.Index("ix_query_user_id_sql_editor_id", user_id, sql_editor_id), - ) + __table_args__ = (sqla.Index("ti_user_id_changed_on", user_id, changed_on),) def get_template_processor(self, **kwargs: Any) -> BaseTemplateProcessor: return get_template_processor(query=self, database=self.database, **kwargs)