-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix: set allow filter_select
for Query objects in Explore
#20754
Merged
Merged
Changes from 3 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1189,6 +1189,38 @@ def _get_top_groups( | |
|
||
return or_(*groups) | ||
|
||
def values_for_column(self, column_name: str, limit: int = 10000) -> List[Any]: | ||
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 think that a better idea here is to use the Max display limit. |
||
"""Runs query against sqla to retrieve some | ||
sample values for the given column. | ||
""" | ||
cols = {} | ||
for col in self.columns: | ||
if isinstance(col, dict): | ||
cols[col.get("column_name")] = col | ||
else: | ||
cols[col.column_name] = col | ||
|
||
target_col = cols[column_name] | ||
tp = None # todo(hughhhh): add back self.get_template_processor() | ||
tbl, cte = self.get_from_clause(tp) | ||
|
||
if isinstance(target_col, dict): | ||
sql_column = sa.column(target_col.get("name")) | ||
else: | ||
sql_column = target_col | ||
|
||
qry = sa.select([sql_column]).select_from(tbl).distinct() | ||
if limit: | ||
qry = qry.limit(limit) | ||
|
||
engine = self.database.get_sqla_engine() | ||
sql = qry.compile(engine, compile_kwargs={"literal_binds": True}) | ||
sql = self._apply_cte(sql, cte) | ||
sql = self.mutate_query_from_config(sql) | ||
|
||
df = pd.read_sql_query(sql=sql, con=engine) | ||
return df[column_name].to_list() | ||
|
||
def get_sqla_query( # pylint: disable=too-many-arguments,too-many-locals,too-many-branches,too-many-statements | ||
self, | ||
apply_fetch_values_predicate: bool = False, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,6 +212,7 @@ def columns(self) -> List[ResultSetColumnType]: | |
@property | ||
def data(self) -> Dict[str, Any]: | ||
return { | ||
"filter_select": 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. Related to my comment in the frontend change. If we add this here, the frontend change should not be needed. |
||
"name": self.tab_name, | ||
"columns": self.columns, | ||
"metrics": [], | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If we are adding the "filter_select": true in sql_lab.py we can remove this change. If we keep this change we don't need to make the change in sql_lab.py.
If we do keep this change, I realized we should actually do a check on datasource because datasource. operations are used within the if block. so recommend changing to this this:
if (col && datasource && datasource.filter_select !== false && !having) {