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 May 2, 2024
1 parent 3fb35e3 commit 1d19118
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: 3dfd0e78650e
Revises: 5f57af97bc3f
Create Date: 2024-05-02 13:40:23.126659
"""

# revision identifiers, used by Alembic.
revision = "efb7a20ff8d8"
down_revision = "be1b217cd8cd"
revision = '3dfd0e78650e'
down_revision = '5f57af97bc3f'

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 @@ -107,7 +107,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))
catalog = Column(String(256), nullable=True, default=None)
sql = Column(MediumText())
Expand Down Expand Up @@ -150,10 +150,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 1d19118

Please sign in to comment.