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

refactor(database): use SupersetResultSet on SqlaTable.get_df() #10707

Merged
merged 3 commits into from
Aug 28, 2020

Conversation

villebro
Copy link
Member

@villebro villebro commented Aug 28, 2020

SUMMARY

Currently SqlaTable.get_df() is fetching data using cursor.fetchall() instead of BaseEngineSpec.fetch_data(), which contains critical customizations for multiple databases. In addition, instead of constructing the DataFrame using pd.DataFrame.from_records(), we can leverage SupersetResultSet which is already implemented on SQL Lab, and which behind the scenes is using PyArrow for storing the datastructure. This is a yet another step in the direction of using SupersetResultSet, and therefore PyArrow, instead of Pandas DataFrames whenever possible.

TEST PLAN

CI

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

Ping: @robdiciuccio

@codecov-commenter
Copy link

Codecov Report

Merging #10707 into master will decrease coverage by 4.53%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10707      +/-   ##
==========================================
- Coverage   64.76%   60.23%   -4.54%     
==========================================
  Files         789      789              
  Lines       37091    37077      -14     
  Branches     3555     3555              
==========================================
- Hits        24021    22332    -1689     
- Misses      12963    14558    +1595     
- Partials      107      187      +80     
Flag Coverage Δ
#cypress ?
#javascript 61.36% <ø> (ø)
#python 59.54% <100.00%> (-0.48%) ⬇️

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

Impacted Files Coverage Δ
superset/viz.py 57.25% <ø> (-0.03%) ⬇️
superset/db_engine_specs/base.py 87.87% <100.00%> (ø)
superset/models/core.py 87.50% <100.00%> (-0.28%) ⬇️
superset-frontend/src/SqlLab/App.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/explore/App.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/dashboard/App.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/explore/index.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/dashboard/index.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/setup/setupColors.js 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/chart/ChartContainer.jsx 0.00% <0.00%> (-100.00%) ⬇️
... and 171 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c715cad...8d5bc4d. Read the comment docs.

@pull-request-size pull-request-size bot added size/M and removed size/S labels Aug 28, 2020
@@ -25,7 +25,7 @@
str, str, Optional[str], Optional[str], Optional[int], Optional[int], bool
]
DbapiDescription = Union[List[DbapiDescriptionRow], Tuple[DbapiDescriptionRow, ...]]
DbapiResult = List[Union[List[Any], Tuple[Any, ...]]]
DbapiResult = Sequence[Union[List[Any], Tuple[Any, ...]]]
Copy link
Member Author

Choose a reason for hiding this comment

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

for some reason MyPy was giving me errors on this locally (I'm probably running a newer version than CI). As I know some Dbapis are actually returning tuples, I think this makes sense anyway.

Copy link
Member

@dpgaspar dpgaspar left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -119,7 +129,7 @@ describe('Visualization > Table', () => {
it('Test table with percent metrics and groupby', () => {
const formData = {
...VIZ_DEFAULTS,
percent_metrics: NUM_METRIC,
percent_metrics: PERCENT_METRIC,
Copy link
Member Author

Choose a reason for hiding this comment

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

For some weird reason this test was flaking out when run with NUM_METRIC (I replicated this test locally, but was not able to make it fail). Switching to PERCENT_METRIC below seems to have solved it.

Copy link
Member

@robdiciuccio robdiciuccio left a comment

Choose a reason for hiding this comment

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

LGTM!

@villebro villebro merged commit dd0bc47 into apache:master Aug 28, 2020
@villebro villebro deleted the villebro/viz-result-set branch August 28, 2020 18:12
villebro added a commit to preset-io/superset that referenced this pull request Aug 29, 2020
…he#10707)

* refactor(database): use SupersetResultSet on SqlaTable.get_df()

* lint

* change cypress test
villebro added a commit to preset-io/superset that referenced this pull request Sep 2, 2020
…he#10707)

* refactor(database): use SupersetResultSet on SqlaTable.get_df()

* lint

* change cypress test
villebro added a commit that referenced this pull request Sep 5, 2020
* refactor(database): use SupersetResultSet on SqlaTable.get_df()

* lint

* change cypress test
@dpgaspar dpgaspar added the v0.38 label Sep 9, 2020
dpgaspar pushed a commit to preset-io/superset that referenced this pull request Sep 10, 2020
…he#10707)

* refactor(database): use SupersetResultSet on SqlaTable.get_df()

* lint

* change cypress test
villebro added a commit to preset-io/superset that referenced this pull request Sep 11, 2020
…he#10707)

* refactor(database): use SupersetResultSet on SqlaTable.get_df()

* lint

* change cypress test
villebro added a commit that referenced this pull request Sep 11, 2020
* refactor(database): use SupersetResultSet on SqlaTable.get_df()

* lint

* change cypress test
villebro added a commit that referenced this pull request Sep 16, 2020
* refactor(database): use SupersetResultSet on SqlaTable.get_df()

* lint

* change cypress test
Ofeknielsen pushed a commit to ofekisr/incubator-superset that referenced this pull request Oct 5, 2020
…he#10707)

* refactor(database): use SupersetResultSet on SqlaTable.get_df()

* lint

* change cypress test
auxten pushed a commit to auxten/incubator-superset that referenced this pull request Nov 20, 2020
…he#10707)

* refactor(database): use SupersetResultSet on SqlaTable.get_df()

* lint

* change cypress test
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
…he#10707)

* refactor(database): use SupersetResultSet on SqlaTable.get_df()

* lint

* change cypress test
@mistercrunch mistercrunch added 🍒 0.37.2 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.38.0 labels Mar 12, 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/M v0.37 v0.37.2 v0.38 🍒 0.37.2 🚢 0.38.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants