-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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
[3541] Augmenting datasources uniqueness constraints #3583
[3541] Augmenting datasources uniqueness constraints #3583
Conversation
Coverage decreased (-0.07%) to 70.077% when pulling 09440f6a985372f5acb56ed9801cbb917424195d on john-bodley:john-bodley-issue-3541 into 076f9cd on apache:master. |
Looks like Postgres is choking on this... Given the |
09440f6
to
9df0b18
Compare
Coverage decreased (-0.07%) to 69.935% when pulling 9df0b1850f362fbff22ffbfe96f9ddbc8d63afaf on john-bodley:john-bodley-issue-3541 into e95132d on apache:master. |
Knowing that deleting constraints is iffy on some platform with alembic, I vote for also removing this line while at it: |
@mistercrunch regardless of whether the line which defines the uniqueness constraint exists, given that |
@john-bodley it's just to insure that new installs that would fail the Otherwise, or complementarily, this function, and related commit/PRs hisotry may have hints as to how to handle deleting constraints in Alembic. |
9df0b18
to
33b6ea0
Compare
Coverage decreased (-0.2%) to 69.844% when pulling 33b6ea0f33d6742ccced965ffbc445a8bbf3dae0 on john-bodley:john-bodley-issue-3541 into 6f1351f on apache:master. |
33b6ea0
to
b931bb1
Compare
Coverage decreased (-0.5%) to 69.627% when pulling b931bb147e37ebc0a120c464e8ef0085fb8bbe98 on john-bodley:john-bodley-issue-3541 into 6f1351f on apache:master. |
b931bb1
to
fe06fa8
Compare
Coverage decreased (-0.02%) to 70.065% when pulling fe06fa836326412fbd4ae2fe6bb70c56fb2681ed on john-bodley:john-bodley-issue-3541 into 6f1351f on apache:master. |
fe06fa8
to
dd80dbf
Compare
Coverage decreased (-0.02%) to 70.065% when pulling dd80dbf58f815b386d730e991660367c20d64867 on john-bodley:john-bodley-issue-3541 into 6f1351f on apache:master. |
dd80dbf
to
93ebaf7
Compare
Coverage decreased (-0.08%) to 70.003% when pulling 93ebaf7dcf20ccc57ee62540f58a909332d878a3 on john-bodley:john-bodley-issue-3541 into 6f1351f on apache:master. |
93ebaf7
to
cbcd4ae
Compare
Coverage decreased (-0.09%) to 69.993% when pulling cbcd4ae16a24e92d0dd2378649beb075f2eed327 on john-bodley:john-bodley-issue-3541 into 6f1351f on apache:master. |
3 similar comments
Coverage decreased (-0.09%) to 69.993% when pulling cbcd4ae16a24e92d0dd2378649beb075f2eed327 on john-bodley:john-bodley-issue-3541 into 6f1351f on apache:master. |
Coverage decreased (-0.09%) to 69.993% when pulling cbcd4ae16a24e92d0dd2378649beb075f2eed327 on john-bodley:john-bodley-issue-3541 into 6f1351f on apache:master. |
Coverage decreased (-0.09%) to 69.993% when pulling cbcd4ae16a24e92d0dd2378649beb075f2eed327 on john-bodley:john-bodley-issue-3541 into 6f1351f on apache:master. |
cbcd4ae
to
1504cc9
Compare
Coverage decreased (-0.09%) to 69.993% when pulling 1504cc9c3af3e6472390268b2c71d8d73aac19b4 on john-bodley:john-bodley-issue-3541 into 6f1351f on apache:master. |
1 similar comment
Coverage decreased (-0.09%) to 69.993% when pulling 1504cc9c3af3e6472390268b2c71d8d73aac19b4 on john-bodley:john-bodley-issue-3541 into 6f1351f on apache:master. |
@mistercrunch could you PTAL at this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
that was a hairy problem, thanks for tackling it!
Coverage decreased (-0.09%) to 71.366% when pulling 16beb4602b98d2c7bc49636a8edaf0dd8a58ea13 on john-bodley:john-bodley-issue-3541 into b059506 on apache:master. |
1 similar comment
Coverage decreased (-0.09%) to 71.366% when pulling 16beb4602b98d2c7bc49636a8edaf0dd8a58ea13 on john-bodley:john-bodley-issue-3541 into b059506 on apache:master. |
@john-bodley let me know if you want me to merge this once the conflicts are resolved. |
70ec3b1
to
ace9437
Compare
ace9437
to
3188ec7
Compare
@mistercrunch I've resolve all the merge conflicts. |
This PR fixes issue #3541 by replacing the uniqueness constraint on the
datasource_name
column of thedatasources
table with the a combination of thecluster_name
anddatasource_name
columns.Tested by ensuring that it was valid to have multiple datasources with the same name under the condition that the clusters differed, i.e.,
The previous unique
datasource_name
key was used as a foreign key constraint for thecolumns
andmetrics
tables. Given thatdatasource_name
is no longer unique, I'm now using theid
column (which is the primary key which one could argue is a better candidate to use) as the foreign key.Note during testing I discovered that there were duplicate foreign key constraints in the
columns
table (and possiblymetrics
) as this was defined in multiple migrations (1226819ee0e3, 3b626e2a6783). The upgrade (which actually removes these constraints and the underlying column) resolves this issue which means an upgrade followed by a downgrade will leave the database in a more viable state.Also we should be using the inspector for the Alembic bind rather than relying on the actual Superset DB engine for inspecting the table schema, given that there may be differences in the perspective of the DB state. For example in MySQL when one performs an upgrade on a new DB the set of foreign key constraints differ between what the DB engine reports (2) and the current schema state (4). Hence the following functions are now deprecated:
though regrettably need to remain to ensure consistent historical behavior for upgrades/downgrades.
Finally I incremented the
id
for several Druid test cases as10003
was used in multiple test cases.I tested the data migration, component, i.e., populating the
datasource_id
column in thecolumns
andmetrics
table by:master
branch.superset db upgrade
and confirmed that thecolumns
andmetrics
tables had been correctly updated.superset db downgrade
and confirmed that thecolumns
andmetrics
tables had been correctly reverted.Finally for MySQL, Postgres, and SQLite, I ran the following commands,
superset db upgrade
superset db downgrade
to validate the logic across the major SQLA connectors.