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

feat(api): Add option to enable sync on import #20312

Merged
merged 5 commits into from
Oct 7, 2022

Conversation

reesercollins
Copy link
Contributor

SUMMARY

In order to bring the API more in line with the CLI, I have added the ability to specify sync_columns and sync_metrics when using the API.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

Set sync_columns or sync_metrics to true. The API should behave like the CLI when those flags are set.

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

@codecov
Copy link

codecov bot commented Jun 8, 2022

Codecov Report

Merging #20312 (225521a) into master (f1fbaf8) will decrease coverage by 0.35%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master   #20312      +/-   ##
==========================================
- Coverage   66.82%   66.47%   -0.36%     
==========================================
  Files        1799     1763      -36     
  Lines       68884    67720    -1164     
  Branches     7319     7052     -267     
==========================================
- Hits        46031    45014    -1017     
+ Misses      20966    20907      -59     
+ Partials     1887     1799      -88     
Flag Coverage Δ
hive 52.91% <0.00%> (-0.01%) ⬇️
mysql 78.25% <100.00%> (?)
postgres 78.31% <100.00%> (+<0.01%) ⬆️
presto 52.81% <0.00%> (-0.01%) ⬇️
python 81.45% <100.00%> (+0.04%) ⬆️
sqlite 76.79% <0.00%> (-0.01%) ⬇️
unit 50.95% <0.00%> (-0.01%) ⬇️

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

Impacted Files Coverage Δ
superset/datasets/api.py 87.39% <100.00%> (+0.10%) ⬆️
superset-frontend/src/setup/setupFormatters.ts 0.00% <0.00%> (-100.00%) ⬇️
...-chart-table/src/DataTable/utils/useMountedMemo.ts 0.00% <0.00%> (-87.50%) ⬇️
.../shared-controls/components/RadioButtonControl.tsx 0.00% <0.00%> (-83.34%) ⬇️
...hart-table/src/DataTable/utils/getScrollBarSize.ts 7.14% <0.00%> (-78.58%) ⬇️
...t-frontend/src/components/DropdownButton/index.tsx 10.00% <0.00%> (-75.00%) ⬇️
superset-frontend/src/setup/setupClient.ts 0.00% <0.00%> (-70.00%) ⬇️
...qlLab/components/EstimateQueryCostButton/index.tsx 5.26% <0.00%> (-58.38%) ⬇️
...ugin-chart-table/src/DataTable/hooks/useSticky.tsx 4.21% <0.00%> (-47.37%) ⬇️
superset-frontend/src/preamble.ts 0.00% <0.00%> (-44.00%) ⬇️
... and 324 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

passwords=passwords,
overwrite=overwrite,
sync_columns=sync_columns,
sync_metrics=sync_metrics,
Copy link
Member

Choose a reason for hiding this comment

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

Side note, I see that V0.ImportDatasetsCommand will use the sync kwargs but not V1.

Copy link
Member

@eschutho eschutho Aug 15, 2022

Choose a reason for hiding this comment

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

cc @betodealmeida is that intentional? ☝️ Or do we need to port over the sync functionality to V1 as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It appears that V1 uses the overwrite flag to denote syncing columns and metrics.

Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit confused here... passing sync_columns and sync_metrics to ImportDatasetsCommand has no effect, as far as I can see. Can you explain more the use case for this, @reesercollins?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sync_columns and sync_metrics means the import command will remove columns and metrics which don't appear in the dataset YAML.

if kwargs.get("sync_columns"):
self.sync.append("columns")
if kwargs.get("sync_metrics"):
self.sync.append("metrics")

Copy link
Member

Choose a reason for hiding this comment

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

Ah, that makes sense, it's for the v0 API! Yeah, in this case it should be fine... the v1 API will ignore these extra arguments, and should be fine.

But then my next question is... any reason why you're still using the v0 API, instead of enabling the VERSIONED_EXPORT feature flag? The v0 import IMHO is very buggy, the code is incomplete and non-standard across asset types, and we should deprecated it as soon as possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have some automation we haven't gotten around to updating which generates the YAML files. We very rarely do any exporting.

Copy link
Member

@eschutho eschutho left a comment

Choose a reason for hiding this comment

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

@reesercollins This looks good. Do you mind writing a test that validates that passing in this kwarg to the api will work? 🙏

@rusackas
Copy link
Member

@eschutho looks like this might be ready to merge if it meets your standards :)

Copy link
Member

@eschutho eschutho left a comment

Choose a reason for hiding this comment

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

Thanks @reesercollins!

@rusackas
Copy link
Member

@reesercollins sorry, this slipped under my/our radar again 🤦
If you could rebase/resolve the conflicts, we'll merge the thing pronto.

@michael-s-molina michael-s-molina merged commit a5ff094 into apache:master Oct 7, 2022
@reesercollins reesercollins deleted the fix/CLDN-1464 branch October 27, 2022 14:10
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 and removed 🚢 2.1.3 labels Mar 13, 2024
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 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants