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

fix: Fix Uniqueness check before update for Sqllab Overwrites #16859

Merged
merged 7 commits into from Sep 29, 2021

Conversation

hughhhh
Copy link
Member

@hughhhh hughhhh commented Sep 27, 2021

SUMMARY

Inside the before_update event listener whenever a user would overwrite a dataset from sqllab we'd get 'committed_state': {'database_id': symbol('NO_VALUE')},. This is causing update (PUT) request to fail in sqllab to fix this we've updated the network call to not include database_id since it isn't mandatory.

Also did a small refactor to remove src/api/datasets.ts

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

@hughhhh hughhhh changed the title fix: Fix Uniqueness Check before update fix: Fix Uniqueness check before update for Sqllab Overwrites Sep 27, 2021
superset/connectors/sqla/models.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Sep 27, 2021

Codecov Report

Merging #16859 (cceaa5c) into master (27a40d2) will increase coverage by 0.11%.
The diff coverage is 20.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16859      +/-   ##
==========================================
+ Coverage   77.05%   77.16%   +0.11%     
==========================================
  Files        1021     1021              
  Lines       54693    56341    +1648     
  Branches     7457     7679     +222     
==========================================
+ Hits        42141    43475    +1334     
- Misses      12307    12618     +311     
- Partials      245      248       +3     
Flag Coverage Δ
hive 81.45% <ø> (+0.03%) ⬆️
javascript 71.04% <20.00%> (-0.16%) ⬇️
mysql 82.10% <ø> (+0.25%) ⬆️
postgres 82.16% <ø> (+0.25%) ⬆️
presto 81.99% <ø> (+0.23%) ⬆️
python 82.62% <ø> (+0.20%) ⬆️
sqlite ?

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

Impacted Files Coverage Δ
superset/datasets/commands/update.py 94.11% <ø> (ø)
superset/datasets/dao.py 96.50% <ø> (-0.12%) ⬇️
...erset-frontend/src/SqlLab/components/ResultSet.tsx 61.94% <20.00%> (-1.42%) ⬇️
superset/db_engine_specs/databricks.py 90.90% <0.00%> (-9.10%) ⬇️
superset-frontend/src/dataMask/actions.ts 66.66% <0.00%> (-5.56%) ⬇️
superset/db_engine_specs/sqlite.py 91.89% <0.00%> (-5.41%) ⬇️
superset/db_engine_specs/hive.py 82.66% <0.00%> (-4.01%) ⬇️
superset/connectors/sqla/utils.py 88.23% <0.00%> (-3.93%) ⬇️
superset/utils/celery.py 86.20% <0.00%> (-3.45%) ⬇️
.../database/DatabaseModal/DatabaseConnectionForm.tsx 51.32% <0.00%> (-2.60%) ⬇️
... and 21 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 27a40d2...cceaa5c. Read the comment docs.

@@ -1662,9 +1663,9 @@ def before_update(

# Check whether the relevant attributes have changed.
state = db.inspect(target) # pylint: disable=no-member

for attr in ["database_id", "schema", "table_name"]:
for attr in ["schema", "table_name"]:
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't remove database_id here, otherwise someone might create a dataset with the same database ID, schema and table name. We should figure out why database ID is coming as null when updating.

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.

A couple questions.

@hughhhh hughhhh merged commit 331de0c into master Sep 29, 2021
opus-42 pushed a commit to opus-42/incubator-superset that referenced this pull request Nov 14, 2021
…#16859)

* add condition to make sure columns are available before throwing

* fix

* remove database_id from history changed

* refactor update call to datasets

* cleanup

* oops

* prettier
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 28, 2021
…#16859)

* add condition to make sure columns are available before throwing

* fix

* remove database_id from history changed

* refactor update call to datasets

* cleanup

* oops

* prettier
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.4.0 labels Mar 13, 2024
@mistercrunch mistercrunch deleted the hugh/fix-unique branch March 26, 2024 17:56
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/L 🚢 1.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants