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: Adding limiting_factor column to Query model #14234

Merged
merged 2 commits into from
Apr 29, 2021

Conversation

AAfghahi
Copy link
Member

SUMMARY

Adding a new enum column to the query table which would indicate if the query model is limited and what the limiting factor would be.

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

TEST PLAN

Benchmarking the migration using #13561:

% python scripts/benchmark_migration.py superset/migrations/versions/b5676c717e8b_add_new_columns_to_query_model.py --limit 10000000 --no-auto-cleanup
Loaded your LOCAL configuration at [/Users/beto/Projects/incubator-superset/superset_config.py]
logging was configured successfully
2021-04-14 22:54:24,887:INFO:superset.utils.logging_configurator:logging was configured successfully
2021-04-14 22:54:24,900:INFO:root:Configured event logger of type <class 'superset.utils.log.DBEventLogger'>
/Users/beto/Projects/incubator-superset/venv/lib/python3.8/site-packages/flask_caching/__init__.py:191: UserWarning: Flask-Caching: CACHE_TYPE is set to null, caching is effectively disabled.
  warnings.warn(
2021-04-14 22:54:26,086:WARNING:root:ENABLE_ALERTS is deprecated and will be removed in version 2.0.0
Importing migration script: superset/migrations/versions/b5676c717e8b_add_new_columns_to_query_model.py
Migration goes from 070c043f2fdb to b5676c717e8b
Current version of the DB is b5676c717e8b

Identifying models used in the migration:
- Query (0 rows in table query)

Running benchmark will downgrade the Superset DB to 070c043f2fdb and upgrade to b5676c717e8b again. There may be data loss in downgrades. Continue? [y/N]: y
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade b5676c717e8b -> 070c043f2fdb, add new columns to query model
Benchmarking migration
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 070c043f2fdb -> b5676c717e8b, add new columns to query model
Migration on current DB took: 0.23 seconds
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade b5676c717e8b -> 070c043f2fdb, add new columns to query model
Running with at least 10 entities of each model
- Adding 10 entities to the Query model
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 070c043f2fdb -> b5676c717e8b, add new columns to query model
Migration for 10+ entities took: 0.22 seconds
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade b5676c717e8b -> 070c043f2fdb, add new columns to query model
Running with at least 100 entities of each model
- Adding 90 entities to the Query model
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 070c043f2fdb -> b5676c717e8b, add new columns to query model
Migration for 100+ entities took: 0.33 seconds
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade b5676c717e8b -> 070c043f2fdb, add new columns to query model
Running with at least 1000 entities of each model
- Adding 900 entities to the Query model
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 070c043f2fdb -> b5676c717e8b, add new columns to query model
Migration for 1000+ entities took: 0.20 seconds
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade b5676c717e8b -> 070c043f2fdb, add new columns to query model
Running with at least 10000 entities of each model
- Adding 9000 entities to the Query model
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 070c043f2fdb -> b5676c717e8b, add new columns to query model
Migration for 10000+ entities took: 0.22 seconds
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade b5676c717e8b -> 070c043f2fdb, add new columns to query model
Running with at least 100000 entities of each model
- Adding 90000 entities to the Query model
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 070c043f2fdb -> b5676c717e8b, add new columns to query model
Migration for 100000+ entities took: 0.23 seconds
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade b5676c717e8b -> 070c043f2fdb, add new columns to query model
Running with at least 1000000 entities of each model
- Adding 900000 entities to the Query model
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 070c043f2fdb -> b5676c717e8b, add new columns to query model
Migration for 1000000+ entities took: 0.35 seconds
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade b5676c717e8b -> 070c043f2fdb, add new columns to query model
Running with at least 10000000 entities of each model
- Adding 9000000 entities to the Query model
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 070c043f2fdb -> b5676c717e8b, add new columns to query model
Migration for 10000000+ entities took: 7.42 seconds

Results:

Current: 0.23 s
10+: 0.22 s
100+: 0.33 s
1000+: 0.20 s
10000+: 0.22 s
100000+: 0.23 s
1000000+: 0.35 s
10000000+: 7.42 s

ADDITIONAL INFORMATION

  • Requires DB Migration.

@AAfghahi AAfghahi requested a review from a team as a code owner April 19, 2021 15:01
@AAfghahi AAfghahi changed the title add limiting factor to query model feat: Adding limiting_factor column to Query model Apr 19, 2021
@hughhhh hughhhh added the risk:db-migration PRs that require a DB migration label Apr 19, 2021
@codecov
Copy link

codecov bot commented Apr 19, 2021

Codecov Report

Merging #14234 (9db249b) into master (86d2a61) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #14234   +/-   ##
=======================================
  Coverage   76.79%   76.79%           
=======================================
  Files         955      955           
  Lines       48251    48251           
  Branches     6030     6030           
=======================================
  Hits        37055    37055           
  Misses      11001    11001           
  Partials      195      195           
Flag Coverage Δ
hive 80.77% <ø> (ø)
mysql 81.03% <ø> (ø)
postgres 81.06% <ø> (ø)
presto 80.77% <ø> (ø)
python 81.60% <ø> (ø)
sqlite 80.67% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out 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 86d2a61...9db249b. Read the comment docs.

@betodealmeida betodealmeida self-requested a review April 19, 2021 20:27
@AAfghahi AAfghahi force-pushed the addNewColumnsToQueryModel branch from 8028b67 to 9db249b Compare April 27, 2021 22:21
@betodealmeida betodealmeida merged commit 982a91e into apache:master Apr 29, 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)
  ...
john-bodley added a commit that referenced this pull request May 7, 2021
cccs-RyanS pushed a commit to CybercentreCanada/superset that referenced this pull request Dec 17, 2021
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
* add limiting factor to query model

* varchar instead of enum
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.2.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 risk:db-migration PRs that require a DB migration size/M 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants