-
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
fix: overwrite update override columns on PUT /dataset #20862
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
52d4ec8
update override columns
hughhhh 2dcffa2
fix merge conflicts
hughhhh 775295f
save
hughhhh 88126f7
Merge branch 'master' of https://github.com/preset-io/superset into f…
hughhhh 2580526
fix overwrite with session.flush
hughhhh 24fc6a1
write test
hughhhh 2efa332
write test
hughhhh ae41b21
layup
hughhhh 9e1a585
Merge branch 'master' of https://github.com/preset-io/superset into f…
hughhhh 12963aa
address concerns
hughhhh 4d2a242
address concerns
hughhhh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -777,6 +777,56 @@ def test_update_dataset_item_w_override_columns(self): | |
db.session.delete(dataset) | ||
db.session.commit() | ||
|
||
def test_update_dataset_item_w_override_columns_same_columns(self): | ||
""" | ||
Dataset API: Test update dataset with override columns | ||
""" | ||
if backend() == "sqlite": | ||
return | ||
|
||
# Add default dataset | ||
main_db = get_main_database() | ||
dataset = self.insert_default_dataset() | ||
prev_col_len = len(dataset.columns) | ||
|
||
cols = [ | ||
{ | ||
"column_name": c.column_name, | ||
"description": c.description, | ||
"expression": c.expression, | ||
"type": c.type, | ||
"advanced_data_type": c.advanced_data_type, | ||
"verbose_name": c.verbose_name, | ||
} | ||
for c in dataset.columns | ||
] | ||
|
||
cols.append( | ||
{ | ||
"column_name": "new_col", | ||
"description": "description", | ||
"expression": "expression", | ||
"type": "INTEGER", | ||
"advanced_data_type": "ADVANCED_DATA_TYPE", | ||
"verbose_name": "New Col", | ||
} | ||
) | ||
|
||
self.login(username="admin") | ||
dataset_data = { | ||
"columns": cols, | ||
} | ||
uri = f"api/v1/dataset/{dataset.id}?override_columns=true" | ||
rv = self.put_assert_metric(uri, dataset_data, "put") | ||
|
||
assert rv.status_code == 200 | ||
|
||
columns = db.session.query(TableColumn).filter_by(table_id=dataset.id).all() | ||
assert len(columns) != prev_col_len | ||
assert len(columns) == 3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add an assert that the number of columns was not 3 before the update? (ie, in line ~790) Otherwise we don't know if the update actually did anything. |
||
db.session.delete(dataset) | ||
db.session.commit() | ||
|
||
def test_update_dataset_create_column_and_metric(self): | ||
""" | ||
Dataset API: Test update dataset create column | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
for put /dataset, does override_columns literally mean just the columns or should we be overriding the metrics, too?
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.
from sqllab, we don't allow users to create metrics so if you look at the
update_metrics
function we end up just deleting all the rows sinceproperties["metrics"]
is always None from that context.