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

feat: Logic added to limiting factor column in Query model #13521

Merged
merged 18 commits into from
Apr 30, 2021

Conversation

AAfghahi
Copy link
Member

@AAfghahi AAfghahi commented Mar 8, 2021

SUMMARY

This is the logic for the migration that can be found here: #14234

What this does is that it assigns one of five categories to each query based on if there is a limiting factor in the results that the query is grabbing. This is in order to create more intelligent error messages in the superset frontend.

Reason

Will be used in the frontend for better user facing messages. Previously several users had complained that they had downloaded the CSV of a query not realizing that the query had been limited either by the dropdown select or their own query parameters. This column will address using backend logic to determine what type of limiting factor, if any, has been placed on the query.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TEST PLAN

Added unit tests!

ADDITIONAL INFORMATION

  • Requires DB Migration.

@AAfghahi AAfghahi changed the title Querydb migration feat: Querydb migration Mar 8, 2021
@AAfghahi AAfghahi force-pushed the querydb_migration branch from dc48414 to bfa3b05 Compare March 8, 2021 23:18
@betodealmeida betodealmeida self-requested a review March 9, 2021 00:03
superset/sql_lab.py Outdated Show resolved Hide resolved
Copy link
Member

@betodealmeida betodealmeida left a comment

Choose a reason for hiding this comment

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

Looks good! Did you get a chance to test the migration by running superset db upgrade?

@betodealmeida betodealmeida added the risk:db-migration PRs that require a DB migration label Mar 9, 2021
@AAfghahi
Copy link
Member Author

AAfghahi commented Mar 9, 2021

Looks good! Did you get a chance to test the migration by running superset db upgrade?

I just did, and it seemed to go through.

(Also happy birthday!)

@AAfghahi AAfghahi force-pushed the querydb_migration branch from 1472ac2 to c902b3e Compare March 10, 2021 23:39
@github-actions
Copy link
Contributor

⚠️ @AAfghahi Your base branch master has just also updated superset/migrations.

Please consider rebasing your branch to avoid db migration conflicts.

@github-actions
Copy link
Contributor

⚠️ @AAfghahi Your base branch master has just also updated superset/migrations.

Please consider rebasing your branch to avoid db migration conflicts.

4 similar comments
@github-actions
Copy link
Contributor

⚠️ @AAfghahi Your base branch master has just also updated superset/migrations.

Please consider rebasing your branch to avoid db migration conflicts.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 9, 2021

⚠️ @AAfghahi Your base branch master has just also updated superset/migrations.

Please consider rebasing your branch to avoid db migration conflicts.

@github-actions
Copy link
Contributor

⚠️ @AAfghahi Your base branch master has just also updated superset/migrations.

Please consider rebasing your branch to avoid db migration conflicts.

@github-actions
Copy link
Contributor

⚠️ @AAfghahi Your base branch master has just also updated superset/migrations.

Please consider rebasing your branch to avoid db migration conflicts.

@AAfghahi AAfghahi marked this pull request as ready for review April 15, 2021 19:22
@AAfghahi AAfghahi requested a review from a team as a code owner April 15, 2021 19:22
@AAfghahi AAfghahi force-pushed the querydb_migration branch 4 times, most recently from d120ca4 to aa899de Compare April 15, 2021 20:24
@codecov
Copy link

codecov bot commented Apr 15, 2021

Codecov Report

Merging #13521 (e9d2b3c) into master (9097c29) will decrease coverage by 0.23%.
The diff coverage is 89.74%.

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

@@            Coverage Diff             @@
##           master   #13521      +/-   ##
==========================================
- Coverage   76.92%   76.68%   -0.24%     
==========================================
  Files         955      955              
  Lines       48055    48080      +25     
  Branches     6033     6034       +1     
==========================================
- Hits        36967    36871      -96     
- Misses      10890    11011     +121     
  Partials      198      198              
Flag Coverage Δ
hive ?
javascript 71.55% <ø> (-0.02%) ⬇️
mysql 81.01% <89.74%> (+<0.01%) ⬆️
postgres 81.04% <89.74%> (+<0.01%) ⬆️
presto ?
python 81.13% <89.74%> (-0.44%) ⬇️
sqlite 80.65% <89.74%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
superset-frontend/src/SqlLab/reducers/sqlLab.js 34.95% <ø> (ø)
superset/sql_lab.py 81.90% <81.81%> (+0.33%) ⬆️
superset/views/core.py 75.70% <86.66%> (+0.05%) ⬆️
superset/db_engine_specs/base.py 87.66% <100.00%> (-0.44%) ⬇️
superset/models/core.py 88.85% <100.00%> (-0.28%) ⬇️
superset/models/sql_lab.py 92.30% <100.00%> (+0.41%) ⬆️
superset/sql_parse.py 99.38% <100.00%> (ø)
superset/db_engines/hive.py 0.00% <0.00%> (-82.15%) ⬇️
superset/db_engine_specs/hive.py 70.32% <0.00%> (-17.08%) ⬇️
superset/db_engine_specs/presto.py 83.36% <0.00%> (-6.53%) ⬇️
... and 24 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 9097c29...57ceca3. Read the comment docs.

@github-actions
Copy link
Contributor

⚠️ @AAfghahi Your base branch master has just also updated superset/migrations.

Please consider rebasing your branch to avoid db migration conflicts.

@betodealmeida
Copy link
Member

@AAfghahi do you want to split this PR into migration + limiting_factor detection logic?

For the limiting_factor detecting logic we need to test with all possible cases, and also add some unit tests to make sure we're not returning more data than requested, or less.

@AAfghahi
Copy link
Member Author

AAfghahi commented Apr 15, 2021

@betodealmeida that makes sense, so then should I move everything that isn't the migration to another PR?

And then add unit tests to the limiting factor one?

AAfghahi and others added 7 commits April 30, 2021 10:15
Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
@AAfghahi AAfghahi force-pushed the querydb_migration branch from 36a4c63 to 9214621 Compare April 30, 2021 14:16
@AAfghahi AAfghahi force-pushed the querydb_migration branch from 9214621 to 54bddb2 Compare April 30, 2021 14:18
AAfghahi and others added 2 commits April 30, 2021 16:22
Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
@AAfghahi AAfghahi force-pushed the querydb_migration branch from e9d2b3c to 57ceca3 Compare April 30, 2021 20:44
@betodealmeida betodealmeida merged commit e507508 into apache:master Apr 30, 2021
@craig-rueda craig-rueda deleted the querydb_migration branch April 30, 2021 23:45
@villebro villebro removed the risk:db-migration PRs that require a DB migration label May 3, 2021
amitmiran137 pushed a commit to nielsen-oss/superset that referenced this pull request May 3, 2021
* master: (38 commits)
  refactor(native-filters): allow cascading only for filter_select (apache#14441)
  test(maximize-chart): Add tests to maximize chart action (apache#14371)
  fix: fixing mysql error message (apache#14416)
  feat: Logic added to limiting factor column in Query model (apache#13521)
  change relationship (apache#14435)
  fix: bootstrap data permissions (apache#14348)
  fix: parse simple string error message values (apache#14360)
  chore: add stack trace to all calls of logger.error (apache#14382)
  update README with new docs and recordings (apache#14432)
  Renamed impyla from implya in impala.mdx and Renamed PIP package impyla from impala in index.mdx (apache#14425)
  fix(native-filters): fix filter scope error (apache#14426)
  feat: Adding limiting_factor column to Query model (apache#14234)
  feat: Add etag caching to dashboard APIs (apache#14357)
  chore: Moves Card to the components folder (apache#14139)
  feat: Dynamic imports for the Icons component (apache#14318)
  feat: Support env vars configuration for WebSocket server (apache#14398)
  fix: SQLLab role permissions (apache#14372)
  fix(native-filters): always show filters without dataset (apache#14409)
  fix error getting partitionQuery from table.partition (apache#14369)
  refactor: Boostrap to AntD - Tabs (apache#14048)
  ...
amitmiran137 pushed a commit that referenced this pull request May 4, 2021
* Sqllab limit

* Add migration script

* Set default values

* initial push

* revisions

* Update superset/views/core.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* moving migration to separate PR

* with migration

* revisions

* Fix apply_limit_to_sql

* all but tests

* added unit tests

* revisions

* Update superset/sql_lab.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* Update superset/sql_parse.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* fixed black issue

* Update superset/views/core.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* updated logic

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
(cherry picked from commit e507508)
hughhhh pushed a commit that referenced this pull request May 4, 2021
* Sqllab limit

* Add migration script

* Set default values

* initial push

* revisions

* Update superset/views/core.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* moving migration to separate PR

* with migration

* revisions

* Fix apply_limit_to_sql

* all but tests

* added unit tests

* revisions

* Update superset/sql_lab.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* Update superset/sql_parse.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* fixed black issue

* Update superset/views/core.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* updated logic

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
cccs-RyanS pushed a commit to CybercentreCanada/superset that referenced this pull request Sep 8, 2021
)

* Sqllab limit

* Add migration script

* Set default values

* initial push

* revisions

* Update superset/views/core.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* moving migration to separate PR

* with migration

* revisions

* Fix apply_limit_to_sql

* all but tests

* added unit tests

* revisions

* Update superset/sql_lab.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* Update superset/sql_parse.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* fixed black issue

* Update superset/views/core.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* updated logic

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
(cherry picked from commit e507508)
cccs-RyanS pushed a commit to CybercentreCanada/superset that referenced this pull request Sep 8, 2021
)

* Sqllab limit

* Add migration script

* Set default values

* initial push

* revisions

* Update superset/views/core.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* moving migration to separate PR

* with migration

* revisions

* Fix apply_limit_to_sql

* all but tests

* added unit tests

* revisions

* Update superset/sql_lab.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* Update superset/sql_parse.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* fixed black issue

* Update superset/views/core.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* updated logic

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
(cherry picked from commit e507508)
cccs-RyanS pushed a commit to CybercentreCanada/superset that referenced this pull request Dec 17, 2021
)

* Sqllab limit

* Add migration script

* Set default values

* initial push

* revisions

* Update superset/views/core.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* moving migration to separate PR

* with migration

* revisions

* Fix apply_limit_to_sql

* all but tests

* added unit tests

* revisions

* Update superset/sql_lab.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* Update superset/sql_parse.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* fixed black issue

* Update superset/views/core.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* updated logic

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
)

* Sqllab limit

* Add migration script

* Set default values

* initial push

* revisions

* Update superset/views/core.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* moving migration to separate PR

* with migration

* revisions

* Fix apply_limit_to_sql

* all but tests

* added unit tests

* revisions

* Update superset/sql_lab.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* Update superset/sql_parse.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* fixed black issue

* Update superset/views/core.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* updated logic

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
)

* Sqllab limit

* Add migration script

* Set default values

* initial push

* revisions

* Update superset/views/core.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* moving migration to separate PR

* with migration

* revisions

* Fix apply_limit_to_sql

* all but tests

* added unit tests

* revisions

* Update superset/sql_lab.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* Update superset/sql_parse.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* fixed black issue

* Update superset/views/core.py

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* updated logic

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
@mistercrunch mistercrunch added 🍒 1.2.0 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.3.0 labels Mar 12, 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 preset-io size/L v1.2 🍒 1.2.0 🚢 1.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants