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

refactor: Migration for Tabbed Sql Editor #17925

Merged
merged 14 commits into from
Jan 12, 2022

Conversation

AAfghahi
Copy link
Member

@AAfghahi AAfghahi commented Jan 4, 2022

SUMMARY

This is the first portion of a larger bug issue of retaining a query's saved status when refreshing the page in sql lab. In order to create this we needed to create a foreign key in the tab state view that links it to the saved query.

This migration does that, and the subsequent logic is here: #17771

Benchmark


Running benchmark will downgrade the Superset DB to bb38f40aa3ff and upgrade to c53bae8f08dd again. There may be data loss in downgrades. Continue? [y/N]: y
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade c53bae8f08dd -> bb38f40aa3ff, add_saved_query_foreign_key_to_tab_state
Revision ID: c53bae8f08dd
Revises: bb38f40aa3ff
Create Date: 2021-12-15 15:05:21.845777

Identifying models used in the migration:
- ab_user (1 rows in table ab_user)
- dbs (1 rows in table dbs)
- query (0 rows in table query)
- tab_state (0 rows in table tab_state)
Benchmarking migration
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade bb38f40aa3ff -> c53bae8f08dd, add_saved_query_foreign_key_to_tab_state
Revision ID: c53bae8f08dd
Revises: bb38f40aa3ff
Create Date: 2021-12-15 15:05:21.845777
Migration on current DB took: 0.29 seconds
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade c53bae8f08dd -> bb38f40aa3ff, add_saved_query_foreign_key_to_tab_state
Revision ID: c53bae8f08dd
Revises: bb38f40aa3ff
Create Date: 2021-12-15 15:05:21.845777
Running with at least 10 entities of each model
- Adding 9 entities to the ab_user model
Processing ████████████████████████████████ 100%
- Adding 9 entities to the dbs model
Processing ████████████████████████████████ 100%
- Adding 10 entities to the query model
Processing ████████████████████████████████ 100%
- Adding 10 entities to the tab_state model
Processing ████████████████████████████████ 100%
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade bb38f40aa3ff -> c53bae8f08dd, add_saved_query_foreign_key_to_tab_state
Revision ID: c53bae8f08dd
Revises: bb38f40aa3ff
Create Date: 2021-12-15 15:05:21.845777
Migration for 10+ entities took: 0.29 seconds
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade c53bae8f08dd -> bb38f40aa3ff, add_saved_query_foreign_key_to_tab_state
Revision ID: c53bae8f08dd
Revises: bb38f40aa3ff
Create Date: 2021-12-15 15:05:21.845777
Running with at least 100 entities of each model
- Adding 90 entities to the ab_user model
Processing ████████████████████████████████ 100%
- Adding 90 entities to the dbs model
Processing ████████████████████████████████ 100%
- Adding 90 entities to the query model
Processing ████████████████████████████████ 100%
- Adding 90 entities to the tab_state model
Processing ████████████████████████████████ 100%
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade bb38f40aa3ff -> c53bae8f08dd, add_saved_query_foreign_key_to_tab_state
Revision ID: c53bae8f08dd
Revises: bb38f40aa3ff
Create Date: 2021-12-15 15:05:21.845777
Migration for 100+ entities took: 0.43 seconds
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade c53bae8f08dd -> bb38f40aa3ff, add_saved_query_foreign_key_to_tab_state
Revision ID: c53bae8f08dd
Revises: bb38f40aa3ff
Create Date: 2021-12-15 15:05:21.845777
Running with at least 1000 entities of each model
- Adding 900 entities to the ab_user model
Processing ████████████████████████████████ 100%
- Adding 900 entities to the dbs model
Processing ████████████████████████████████ 100%
- Adding 900 entities to the query model
Processing ████████████████████████████████ 100%
- Adding 900 entities to the tab_state model
Processing ████████████████████████████████ 100%
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade bb38f40aa3ff -> c53bae8f08dd, add_saved_query_foreign_key_to_tab_state
Revision ID: c53bae8f08dd
Revises: bb38f40aa3ff
Create Date: 2021-12-15 15:05:21.845777
Migration for 1000+ entities took: 0.28 seconds
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade c53bae8f08dd -> bb38f40aa3ff, add_saved_query_foreign_key_to_tab_state
Revision ID: c53bae8f08dd
Revises: bb38f40aa3ff
Create Date: 2021-12-15 15:05:21.845777
Running with at least 10000 entities of each model
- Adding 9000 entities to the ab_user model
Processing ████████████████████████████████ 100%
- Adding 9000 entities to the dbs model
Processing ████████████████████████████████ 100%
- Adding 9000 entities to the query model
Processing ████████████████████████████████ 100%
- Adding 9000 entities to the tab_state model
Processing ████████████████████████████████ 100%
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade bb38f40aa3ff -> c53bae8f08dd, add_saved_query_foreign_key_to_tab_state
Revision ID: c53bae8f08dd
Revises: bb38f40aa3ff
Create Date: 2021-12-15 15:05:21.845777
Migration for 10000+ entities took: 0.54 seconds
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade c53bae8f08dd -> bb38f40aa3ff, add_saved_query_foreign_key_to_tab_state
Revision ID: c53bae8f08dd
Revises: bb38f40aa3ff
Create Date: 2021-12-15 15:05:21.845777
Running with at least 100000 entities of each model
- Adding 90000 entities to the ab_user model
Processing ████████████████████████████████ 100%
- Adding 90000 entities to the dbs model
Processing ████████████████████████████████ 100%
- Adding 90000 entities to the query model
Processing ████████████████████████████████ 100%
- Adding 90000 entities to the tab_state model
Processing ████████████████████████████████ 100%
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade bb38f40aa3ff -> c53bae8f08dd, add_saved_query_foreign_key_to_tab_state
Revision ID: c53bae8f08dd
Revises: bb38f40aa3ff
Create Date: 2021-12-15 15:05:21.845777
Migration for 100000+ entities took: 0.51 seconds
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade c53bae8f08dd -> bb38f40aa3ff, add_saved_query_foreign_key_to_tab_state
Revision ID: c53bae8f08dd
Revises: bb38f40aa3ff
Create Date: 2021-12-15 15:05:21.845777
Running with at least 1000000 entities of each model
- Adding 900000 entities to the ab_user model
Processing ████████████████████████████████ 100%
- Adding 900000 entities to the dbs model
Processing ████████████████████████████████ 100%
- Adding 900000 entities to the query model
Processing ████████████████████████████████ 100%
- Adding 900000 entities to the tab_state model
Processing ████████████████████████████████ 100%
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade bb38f40aa3ff -> c53bae8f08dd, add_saved_query_foreign_key_to_tab_state
Revision ID: c53bae8f08dd
Revises: bb38f40aa3ff
Create Date: 2021-12-15 15:05:21.845777
Migration for 1000000+ entities took: 2.09 seconds

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

@AAfghahi AAfghahi requested a review from a team as a code owner January 4, 2022 22:44
@betodealmeida betodealmeida self-requested a review January 4, 2022 22:56
@betodealmeida
Copy link
Member

This looks great! But let's wait until we have the sibling PR ready and approved before merging this, in case we need to change the migration.

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.

Blocking this just in case.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2022

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

Please consider rebasing your branch to avoid db migration conflicts.

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 great!

@AAfghahi AAfghahi merged commit 5e84fd1 into apache:master Jan 12, 2022
shcoderAlex pushed a commit to casual-precision/superset that referenced this pull request Feb 7, 2022
* a lot of console logs

* migration for tabbed Sql Editors
bwang221 pushed a commit to casual-precision/superset that referenced this pull request Feb 10, 2022
* a lot of console logs

* migration for tabbed Sql Editors
@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.

4 participants