superset icon indicating copy to clipboard operation
superset copied to clipboard

fix: Add user filtering to changed_by. Fixes #27986

Open marre opened this issue 1 year ago • 5 comments

SUMMARY

Adds filtering of "modified by" in the same way as for "owner".
Fixes #27986

Example superset_config.py with EXTRA_RELATED_QUERY_FILTERS configured:

# Hide all users
def user_filter(query):
    from sqlalchemy.sql import false
    return query.filter(false())

EXTRA_RELATED_QUERY_FILTERS = {
    "user": user_filter,
}

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before:
image

After:
image

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • [x] Has associated issue: #27986
  • [ ] Required feature flags:
  • [x] 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

marre avatar Jun 18 '24 08:06 marre

Adding a link to the PR that introduced this feature for "owner" and "group". https://github.com/apache/superset/pull/22526

marre avatar Jun 18 '24 11:06 marre

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 83.74%. Comparing base (76d897e) to head (bc29572). Report is 1701 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #29287       +/-   ##
===========================================
+ Coverage   60.48%   83.74%   +23.25%     
===========================================
  Files        1931      524     -1407     
  Lines       76236    37789    -38447     
  Branches     8568        0     -8568     
===========================================
- Hits        46114    31646    -14468     
+ Misses      28017     6143    -21874     
+ Partials     2105        0     -2105     
Flag Coverage Δ
hive 49.13% <100.00%> (-0.02%) :arrow_down:
javascript ?
mysql 77.00% <100.00%> (?)
postgres 77.08% <100.00%> (?)
presto 53.71% <100.00%> (-0.10%) :arrow_down:
python 83.74% <100.00%> (+20.23%) :arrow_up:
sqlite 76.56% <100.00%> (?)
unit 59.86% <100.00%> (+2.22%) :arrow_up:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Jun 18 '24 17:06 codecov[bot]

@dpgaspar : I think I have corrected the formatting. Would be nice if you can start the workflows again.

marre avatar Jun 19 '24 12:06 marre

CI running 🤞

rusackas avatar Jun 20 '24 21:06 rusackas

@rusackas : Added missing newline to get ruff linter happy

@dpgaspar would love to get a new CI run...

marre avatar Jun 25 '24 06:06 marre

Would love to get some feedback if this PR is considered for merging. Or if I can improve it in some way.

marre avatar Jul 07 '24 06:07 marre

Updated branch with master to resolve merge conflict

marre avatar Jul 13 '24 10:07 marre

Updated the "summary" of this PR with a better description and added "testing instructions"

marre avatar Jul 13 '24 11:07 marre

Running CI again :)

rusackas avatar Jul 16 '24 04:07 rusackas

Anything else I can do to get this approved/merged?

marre avatar Jul 18 '24 17:07 marre

This looks awesome @marre - we would also greatly benefit from this. We'll be crossing our fingers for approval soon and we'll be willing to help if any additional work is needed

bcook-konza avatar Jul 18 '24 19:07 bcook-konza

Done! Thanks for your contribution!

rusackas avatar Jul 25 '24 21:07 rusackas

Thanks!

In what release will it be included in?

marre avatar Jul 26 '24 06:07 marre

@supersetbot label 4.1

sadpandajoe avatar Jul 30 '24 17:07 sadpandajoe

@marre, thank you! However, you mentioned that this would fix the 'Modified By' field issue, but the only field currently removing the list of users is 'Owner'.

Example for the 'Owner' field: image

Example for the 'Modified By' field

image

Is there any configuration that I'm missing?

Hide all users

from sqlalchemy.sql import false

def user_filter(query):
    return query.filter(false())
        
EXTRA_RELATED_QUERY_FILTERS = {
       "user": user_filter,
       "changed_by": user_filter
 }              

bruno-santos-6 avatar Aug 01 '24 15:08 bruno-santos-6

@supersetbot unlabel 4.1

sadpandajoe avatar Aug 01 '24 18:08 sadpandajoe

@sadpandajoe Would really love to have this in 4.1...

@bruno-santos-6 What version of superset are you testing with?

Just pulled latest from superset/superset (master branch@40520c54d40f887453827ef36a9f5924119ada62)

Without EXTRA_RELATED_QUERY_FILTERS

Without EXTRA_RELATED_QUERY_FILTERS configured:

Owner: image

Modified-by: image

With EXTRA_RELATED_QUERY_FILTERS

Added this to my superset_config.py:

def user_filter(query):
    from sqlalchemy.sql import false
    return query.filter(false())

EXTRA_RELATED_QUERY_FILTERS = {
    "user": user_filter,
}

Started with:

export SUPERSET_CONFIG_PATH=./superset_config.py
superset run -p 8088 --with-threads --reload --debugger --debug

Owner after: image

Modified-by after: image

marre avatar Aug 02 '24 08:08 marre

Noticed that I had a typo in the first sentence of the description. I wrote "modified-by" where I intended "owner" and vice-versa. Corrected in description.

marre avatar Aug 02 '24 08:08 marre

@marre You are right, I deployed Superset using Helm on Kubernetes, and the latest version of Superset available in the official chart is 4.0.1. I will try to apply version 4.0.2

bruno-santos-6 avatar Aug 05 '24 13:08 bruno-santos-6

You have to either grab it directly from github from master branch or wait for a release where this PR will be included in. I hope it will be in 4.1.0 as it was once tagged with 4.1, but that tag has been removed. So I really don't know when this will be included in a release.

marre avatar Aug 05 '24 13:08 marre