-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
Filtering out SQLLab views out of table list view by default #4746
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,54 @@ | ||
"""is_sqllab_view | ||
|
||
Revision ID: 130915240929 | ||
Revises: f231d82b9b26 | ||
Create Date: 2018-04-03 08:19:34.098789 | ||
|
||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.ext.declarative import declarative_base | ||
|
||
from superset import db | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '130915240929' | ||
down_revision = 'f231d82b9b26' | ||
|
||
Base = declarative_base() | ||
|
||
|
||
class Table(Base): | ||
"""Declarative class to do query in upgrade""" | ||
__tablename__ = 'tables' | ||
id = sa.Column(sa.Integer, primary_key=True) | ||
sql = sa.Column(sa.Text) | ||
is_sqllab_view = sa.Column(sa.Boolean()) | ||
|
||
|
||
def upgrade(): | ||
bind = op.get_bind() | ||
op.add_column( | ||
'tables', | ||
sa.Column( | ||
'is_sqllab_view', | ||
sa.Boolean(), | ||
nullable=True, | ||
default=False, | ||
server_default=sa.false(), | ||
), | ||
) | ||
|
||
session = db.Session(bind=bind) | ||
|
||
# Use Slice class defined here instead of models.Slice | ||
for tbl in session.query(Table).all(): | ||
if tbl.sql: | ||
tbl.is_sqllab_view = True | ||
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. I guess the presence of custom SQL doesn't always imply that the SQL corresponds to a SQL Lab view. 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. Right, I'm not sure how else to identify it. It's the best proxy we have. Note that this does not change any behavior other than being filtered out by default in the Table list view, but the filter can be removed anyways, so I didn't think it had to be perfect. Goal here is just to hide some of the clutter this creates. |
||
session.merge(tbl) | ||
session.commit() | ||
db.session.close() | ||
|
||
|
||
def downgrade(): | ||
op.drop_column('tables', 'is_sqllab_view') |
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.
Is there anyway to infer this rather than it be a form option?
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.
I could remove it from the
edit_columns
and have it only in theshow_columns
if you think it's better