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(gsheets): file upload #24921

Merged
merged 7 commits into from
Aug 11, 2023
Merged

feat(gsheets): file upload #24921

merged 7 commits into from
Aug 11, 2023

Conversation

betodealmeida
Copy link
Member

SUMMARY

Add a df_to_sql method to the GSheets DB engine spec, so we can upload CSV files. When a file is uploaded, a new sheet is created, and the database catalog is updated to point the table name to the URL of the new sheet.

The user can also choose to replace an existing table, in which case the sheet gets cleared before the data is inserted.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Inserting some data:

Screenshot 2023-08-08 at 18-40-33 Superset

Querying the table:

Screenshot 2023-08-08 at 18-42-05 Superset

Uploading a different CSV and replacing the table:

Screenshot 2023-08-08 at 18-43-21 Superset

And querying it (note that the metadata is cached and shows the old schema):

Screenshot 2023-08-08 at 18-44-24 Superset

And the sheet after the second upload:

Screenshot 2023-08-08 at 18-44-46 upload_test

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

@codecov
Copy link

codecov bot commented Aug 9, 2023

Codecov Report

Merging #24921 (165a0c0) into master (81bf2f0) will decrease coverage by 1.74%.
Report is 1 commits behind head on master.
The diff coverage is 29.31%.

❗ Current head 165a0c0 differs from pull request most recent head 9472c76. Consider uploading reports for the commit 9472c76 to get more accurate results

@@            Coverage Diff             @@
##           master   #24921      +/-   ##
==========================================
- Coverage   69.00%   67.26%   -1.74%     
==========================================
  Files        1906     1906              
  Lines       74132    74183      +51     
  Branches     8208     8208              
==========================================
- Hits        51153    49902    -1251     
- Misses      20856    22158    +1302     
  Partials     2123     2123              
Flag Coverage Δ
hive 54.13% <29.82%> (-0.05%) ⬇️
mysql 79.12% <29.82%> (-0.09%) ⬇️
postgres 79.22% <29.31%> (-0.09%) ⬇️
presto 54.03% <29.82%> (-0.05%) ⬇️
python 79.72% <29.31%> (-3.65%) ⬇️
sqlite 77.81% <29.82%> (-0.09%) ⬇️
unit ?

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

Files Changed Coverage Δ
...tend/plugins/legacy-preset-chart-nvd3/src/utils.js 16.02% <ø> (+0.10%) ⬆️
superset/db_engine_specs/gsheets.py 38.82% <29.31%> (-37.65%) ⬇️

... and 97 files with indirect coverage changes

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

@@ -57,7 +71,7 @@ class GSheetsParametersSchema(Schema):

class GSheetsParametersType(TypedDict):
service_account_info: str
catalog: Optional[dict[str, str]]
catalog: dict[str, str] | None

Choose a reason for hiding this comment

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

Just curious why moving from Optional ? Because I see Optional being used in several other TypedDict classes. Want to confirm if this is a pattern we aim to follow moving forward, thanks.

Copy link
Member Author

Choose a reason for hiding this comment

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

We bumped the minimum Python version we support in Superset (I think to 3.9?), and in it we can use the syntax foo | None instead of Optional[foo]. This way we don't need to import Optional, and the type declaration looks more natural (for example, it's similar to Typescript's foo | null for an optional foo).

Choose a reason for hiding this comment

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

Oh cool! Good to know moving forward then. Thanks @betodealmeida

@betodealmeida betodealmeida merged commit f5ed407 into master Aug 11, 2023
54 checks passed
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.1.0 labels Mar 8, 2024
@mistercrunch mistercrunch deleted the upload_gsheets branch March 26, 2024 18:02
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 🚢 3.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants