-
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
chore: migrate sqllab_viz
endpoint to api v1
#23729
Conversation
…-apiv1-sqllab-viz
ae7b376
to
21a4833
Compare
Codecov Report
@@ Coverage Diff @@
## master #23729 +/- ##
==========================================
- Coverage 68.02% 68.02% -0.01%
==========================================
Files 1936 1936
Lines 74929 74931 +2
Branches 8141 8141
==========================================
+ Hits 50970 50971 +1
- Misses 21871 21872 +1
Partials 2088 2088
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
21a4833
to
2912bb1
Compare
2912bb1
to
8038701
Compare
superset/datasets/api.py
Outdated
@@ -989,3 +1001,120 @@ def get_or_create_dataset(self) -> Response: | |||
exc_info=True, | |||
) | |||
return self.response_422(message=ex.message) | |||
|
|||
@expose("/sqllab_viz/", methods=["POST"]) |
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.
Instead of creating a new endpoint, could we instead re-use the POST /api/v1/dataset/
endpoint? It seems to serve the same purpose and has the validation being done in this endpoint automatically built-in
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.
Nice, glad this approach works! There's still one place the endpoint needs to be updated, and some cleanup
schema: schema, | ||
table_name: datasourceName, | ||
sql: sql, | ||
owners: [1], |
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.
the owners
key can probably just be omitted from the payload here, then the backend should default to making the current user owner I believe
@@ -49,7 +49,7 @@ export function saveDataset({ | |||
const { | |||
json: { data }, | |||
} = await SupersetClient.post({ | |||
endpoint: '/superset/sqllab_viz/', | |||
endpoint: '/api/v1/dataset/sqllab_viz/', |
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.
This one will need be updated as well
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.
Also since this is explore, the response payload from POST /api/v1/dataset/
maybe be missing keys that explore expects to be there in order to work properly. After this post we may need to make a request to GET /api/v1/dataset/{id}
, which will return all needed keys. See here in a recent PR of mine where I had to do something similar: https://github.com/apache/superset/pull/23678/files#diff-ccfa293ffd1a07eab82f8646fcb2732ff5d001fec273656b18064db5115ac9fbR165
superset/datasets/schemas.py
Outdated
is_dttm = fields.Boolean(required=True, description="Name of table") | ||
|
||
|
||
class SqllabVizSchema(Schema): |
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.
these can be removed
@@ -485,102 +485,6 @@ def test_pa_conversion_dict(self): | |||
self.assertEqual(len(data), results.size) | |||
self.assertEqual(len(cols), len(results.columns)) | |||
|
|||
def test_sqllab_viz(self): |
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.
nit: I think it's fine to leave in tests for deprecated endpoints, we can just delete them when they are eventually removed for good
cd01015
to
0c8ae6a
Compare
0c8ae6a
to
0ce4316
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, just one small thing
superset/datasets/api.py
Outdated
@@ -95,6 +95,7 @@ class DatasetRestApi(BaseSupersetModelRestApi): | |||
"related_objects", | |||
"duplicate", | |||
"get_or_create_dataset", | |||
"sqllab_viz", |
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.
this can be removed
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! Concerns were addressed
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.
Looks good, just a comment on the Length()
validation that needs to be fixed.
bf1f48f
to
3ea64e6
Compare
1ec7906
to
cca9d8a
Compare
4c988c7
to
cca9d8a
Compare
This reverts commit fa8f984.
This reverts commit fa8f984.
@hughhhh @betodealmeida @jfrag1 @Antonio-RiveroMartnez this PR appears to have caused a nasty regression, namely it's now impossible to save a chart from a query that hasn't been saved as a dataset first: saving triggers an "Unknown field." error: Interestingly the "Save as dataset" flow works: This is happening, because in the main "Save" workflow we're sending a POST to As can be seen here, the schema doesn't support superset/superset/datasets/schemas.py Lines 79 to 87 in 3e76736
I think we need to DRY up these flows, as it feels unnecessary to have a different code path for saving the dataset in "Save as dataset" vs the main "Save" button.. |
SUMMARY
Migrating legacy endpoint that creates datasets (
superset/sqllab_viz)
to api v1BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION