Skip to content
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

fix: set allow filter_select for Query objects in Explore #20754

Merged
merged 4 commits into from
Jul 20, 2022

Conversation

hughhhh
Copy link
Member

@hughhhh hughhhh commented Jul 18, 2022

SUMMARY

Allow filter select dropdown to execute select distinct {col} from {table} to make it easier for users to know what values are available to filter when in explore.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@codecov
Copy link

codecov bot commented Jul 18, 2022

Codecov Report

Merging #20754 (cc099c4) into master (1101922) will increase coverage by 0.03%.
The diff coverage is 66.10%.

❗ Current head cc099c4 differs from pull request most recent head 80e79af. Consider uploading reports for the commit 80e79af to get more accurate results

@@            Coverage Diff             @@
##           master   #20754      +/-   ##
==========================================
+ Coverage   66.20%   66.24%   +0.03%     
==========================================
  Files        1754     1756       +2     
  Lines       66678    66758      +80     
  Branches     7049     7049              
==========================================
+ Hits        44143    44221      +78     
- Misses      20738    20740       +2     
  Partials     1797     1797              
Flag Coverage Δ
hive 53.24% <36.80%> (?)
mysql ?
postgres 81.06% <66.87%> (-0.20%) ⬇️
presto 53.10% <37.42%> (?)
python 81.41% <66.87%> (+0.03%) ⬆️
sqlite ?
unit 50.25% <17.17%> (-0.20%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ns/legacy-preset-chart-deckgl/src/utils/explore.js 0.00% <0.00%> (ø)
...set-chart-nvd3/src/vendor/superset/exploreUtils.js 0.00% <0.00%> (ø)
...d/src/SqlLab/components/SqlEditorLeftBar/index.tsx 49.20% <0.00%> (ø)
superset-frontend/src/utils/urlUtils.ts 46.80% <0.00%> (ø)
superset/commands/importers/v1/assets.py 85.71% <ø> (ø)
superset/commands/importers/v1/examples.py 0.00% <ø> (ø)
superset/connectors/sqla/views.py 87.30% <0.00%> (-3.97%) ⬇️
...erset/dashboards/commands/importers/v1/__init__.py 98.52% <ø> (ø)
superset/db_engine_specs/snowflake.py 75.65% <0.00%> (-0.67%) ⬇️
superset/models/sql_lab.py 77.37% <ø> (ø)
... and 40 more

@@ -1189,6 +1189,38 @@ def _get_top_groups(

return or_(*groups)

def values_for_column(self, column_name: str, limit: int = 10000) -> List[Any]:
Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Member

@AAfghahi AAfghahi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit, otherwise good!

@@ -359,7 +359,7 @@ const AdhocFilterEditPopoverSimpleTabContent: React.FC<Props> = props => {
const col = props.adhocFilter.subject;
const having = props.adhocFilter.clause === CLAUSES.HAVING;

if (col && datasource && datasource.filter_select && !having) {
if (col && datasource?.filter_select !== false && !having) {
Copy link
Contributor

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) {

@@ -212,6 +212,7 @@ def columns(self) -> List[ResultSetColumnType]:
@property
def data(self) -> Dict[str, Any]:
return {
"filter_select": True,
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

@hughhhh hughhhh merged commit 81bd496 into apache:master Jul 20, 2022
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/M 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants