-
Notifications
You must be signed in to change notification settings - Fork 14k
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: save columns reference from sqllab save datasets flow #24248
Conversation
Codecov Report
@@ Coverage Diff @@
## master #24248 +/- ##
===========================================
- Coverage 68.85% 58.16% -10.69%
===========================================
Files 1901 1901
Lines 73969 74000 +31
Branches 8119 8116 -3
===========================================
- Hits 50931 43044 -7887
- Misses 20927 28845 +7918
Partials 2111 2111
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 284 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@@ -218,7 +220,9 @@ export const SaveDatasetModal = ({ | |||
...formDataWithDefaults, | |||
datasource: `${datasetToOverwrite.datasetid}__table`, | |||
...(defaultVizType === 'table' && { | |||
all_columns: datasource?.columns?.map(column => column.column_name), | |||
all_columns: datasource?.columns?.map( | |||
column => column.name || column.column_name, |
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.
I've asked this before, but I don't remember the answer. Why can't we standardize this? This is definitely going to cause bugs in the future, having two possible options for the attribute name.
Can't we normalize the schema early, if they have to be stored differently, instead of normalizing it late here?
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.
looking into this now @betodealmeida, i think it was just a difference between how sqllab consumes columns vs. explore
@hughhhh can you add some tests on this for the bugs fixed? Thanks! |
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.
let's add some tests for this specific use case since it's not on the codebase already.
superset/queries/dao.py
Outdated
@@ -59,6 +59,8 @@ def update_saved_query_exec_info(query_id: int) -> None: | |||
def save_metadata(query: Query, payload: Dict[str, Any]) -> None: | |||
# pull relevant data from payload and store in extra_json | |||
columns = payload.get("columns", {}) | |||
for col in columns: | |||
col["column_name"] = col.pop("name") |
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 the query execution the dict comes back column[name]
, and decided to update the naming here before returning it to the client
@hughhhh does this break any apis? i.e., change the schema for the request or response? |
@hughhhh what's the main reasoning behind renaming the column |
/testenv up |
@eschutho Container image not yet published for this PR. Please try again when build is complete. |
@eschutho Ephemeral environment creation failed. Please check the Actions logs for details. |
The main reason is actually keep consistency across the app when it comes to Column objects/dicts, since we we've been incorporated query objects inside explore there has been tons of places where we have conditional logic to manage |
That would be great. Yeah, we should always keep the apis backward compatible. Even if the app has a breaking change, the apis have their own versioning and the request/response schemas should be backward compatible until we can bump to the next version of the api. |
311d07b
to
3fc4ea9
Compare
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. I agree with @john-bodley that the column.column_name property sounds redundant over just name
but maybe it's something we can revisit for the v3 api?
3fc4ea9
to
3580eb7
Compare
3580eb7
to
eeec51f
Compare
…ix-save-ds-in-sqllab
SUMMARY
With the deprecation of
/sqllab_viz
we need to update the API for/datasets
to manage saving columns when saving a dataset. Also added a refactor for changing column.name to always be column.column_name to match the backendTableColumn
modelBEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION