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: avoid filters containing null value #17168

Merged
merged 1 commit into from
Oct 21, 2021

Conversation

zhaoyongjie
Copy link
Member

@zhaoyongjie zhaoyongjie commented Oct 20, 2021

SUMMARY

related PR: #16936
closed: #16803

Avoid filters getting null values. User should add IS NOT NULL or IS NULL operator to handle Empty value in SQL

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

After

image

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue: [explore][filter] NOT EQUALS NULL doesn't allow to SAVE #16803
  • 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 Oct 20, 2021

Codecov Report

Merging #17168 (a66e162) into master (d38e686) will decrease coverage by 0.21%.
The diff coverage is 100.00%.

❗ Current head a66e162 differs from pull request most recent head 4b00577. Consider uploading reports for the commit 4b00577 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master   #17168      +/-   ##
==========================================
- Coverage   76.91%   76.69%   -0.22%     
==========================================
  Files        1038     1039       +1     
  Lines       55557    55561       +4     
  Branches     7567     7567              
==========================================
- Hits        42729    42614     -115     
- Misses      12578    12697     +119     
  Partials      250      250              
Flag Coverage Δ
hive ?
mysql 81.91% <100.00%> (+<0.01%) ⬆️
postgres 81.92% <100.00%> (+<0.01%) ⬆️
presto ?
python 82.00% <100.00%> (-0.42%) ⬇️
sqlite 81.59% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
...end/src/components/Datasource/DatasourceEditor.jsx 71.91% <ø> (ø)
...tend/src/components/Datasource/DatasourceModal.tsx 75.38% <ø> (ø)
...re/components/controls/DatasourceControl/index.jsx 79.06% <ø> (ø)
superset/views/core.py 76.94% <ø> (ø)
...rc/components/Datasource/ChangeDatasourceModal.tsx 86.36% <100.00%> (ø)
...erset-frontend/src/components/Datasource/index.tsx 100.00% <100.00%> (ø)
...ontend/src/views/CRUD/data/dataset/DatasetList.tsx 66.29% <100.00%> (ø)
superset/connectors/base/models.py 88.25% <100.00%> (ø)
superset/connectors/druid/models.py 82.99% <100.00%> (ø)
superset/connectors/sqla/models.py 85.71% <100.00%> (-1.61%) ⬇️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d38e686...4b00577. Read the comment docs.

@pkdotson
Copy link
Member

/testenv up

@github-actions
Copy link
Contributor

@pkdotson Ephemeral environment spinning up at http://54.244.176.33:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

Copy link
Member

@pkdotson pkdotson left a comment

Choose a reason for hiding this comment

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

Tested in eph env and LGTM! I'll close my pr since it's no longer need. Would be nice to get @villebro checkmark as well!

@villebro
Copy link
Member

@zhaoyongjie does the filter box use this same endpoint? IIRC, the filter box select works with null values (the native filter one does, too, but it uses the chart data endpoint for this so won't be affected). If this doesn't affect the filter box then LGTM, otherwise we may need to add an additional param to the endpoint path to toggle between allowing/disallowing nulls and calling it without nulls only on the adhoc filter request.

@zhaoyongjie
Copy link
Member Author

zhaoyongjie commented Oct 21, 2021

@zhaoyongjie does the filter box use this same endpoint? IIRC, the filter box select works with null values (the native filter one does, too, but it uses the chart data endpoint for this so won't be affected). If this doesn't affect the filter box then LGTM, otherwise we may need to add an additional param to the endpoint path to toggle between allowing/disallowing nulls and calling it without nulls only on the adhoc filter request.

Good point! currently(after this PR), changed original behavior.

For example, there is a table:

SELECT 'foo' as foo 
UNION 
SELECT 'bar'
UNION
SELECT NULL
-----------------------------
foo
NULL
bar
foo

We call the filter endpoint before, the response was

[None, 'bar', 'foo']

and now, the response is

['bar', 'foo']

but the None value is doesn't fit SQL where clause. for instance:

SELECT col1
FROM tbl
WHERE col1 in (NULL)

So, I think we can change old behavior safely. might be I have not considered it well, What do you think about it?

@villebro
Copy link
Member

@zhaoyongjie let me test this quickly, too!

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

Code LGTM + Tested to work as expected; the new flow of not making the NULL value available in the adhoc filter select makes more sense as there is the IS NULL option, and the filter box null value dropdown still works like before.

@zhaoyongjie zhaoyongjie merged commit 4c708af into apache:master Oct 21, 2021
@github-actions
Copy link
Contributor

Ephemeral environment shutdown and build artifacts deleted.

opus-42 pushed a commit to opus-42/incubator-superset that referenced this pull request Nov 14, 2021
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.5.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 🚢 1.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[explore][filter] NOT EQUALS NULL doesn't allow to SAVE
4 participants