Skip to content

Commit

Permalink
change to single column index
Browse files Browse the repository at this point in the history
  • Loading branch information
justinpark committed Apr 15, 2024
1 parent db08f3a commit 8a2c84e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,30 @@
# 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():
if not table_has_index(table, index):
op.create_index(
op.f(index),
table,
["user_id", "sql_editor_id"],
["sql_editor_id"],
unique=False,
)

Expand Down
7 changes: 2 additions & 5 deletions superset/models/sql_lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8a2c84e

Please sign in to comment.