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

fix(chart-data-api): support numeric temporal columns #13138

Merged
merged 1 commit into from
Feb 16, 2021

Conversation

villebro
Copy link
Member

@villebro villebro commented Feb 15, 2021

SUMMARY

Some database connectors (at least the native Pinot connector) return a numeric value (either as second or millisecord epoch) instead of a regular timestamp. This was working correctly on viz.py, but support was lacking on /api/v1/chart/data. This centralizes the logic in a util, simplifies the code and adds tests that were previously missing.

TEST PLAN

CI + new tests

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

@villebro villebro force-pushed the villebro/fix-numeric-timestamp branch 3 times, most recently from 3def36b to 5ba5a73 Compare February 15, 2021 20:35
@codecov-io
Copy link

codecov-io commented Feb 15, 2021

Codecov Report

Merging #13138 (5ba5a73) into master (2ce7982) will increase coverage by 13.73%.
The diff coverage is 42.36%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master   #13138       +/-   ##
===========================================
+ Coverage   53.06%   66.79%   +13.73%     
===========================================
  Files         489      492        +3     
  Lines       17314    29026    +11712     
  Branches     4482        0     -4482     
===========================================
+ Hits         9187    19389    +10202     
- Misses       8127     9637     +1510     
Flag Coverage Δ
cypress ?
python 66.79% <42.36%> (?)

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

Impacted Files Coverage Δ
superset/examples/birth_names.py 73.19% <ø> (ø)
...43f2fdb_add_granularity_to_charts_where_missing.py 0.00% <0.00%> (ø)
...s/260bf0649a77_migrate_x_dateunit_in_time_range.py 0.00% <0.00%> (ø)
...ons/versions/41ce8799acc3_rename_pie_label_type.py 0.00% <0.00%> (ø)
superset/connectors/sqla/views.py 62.43% <4.34%> (ø)
superset/views/datasource.py 88.70% <16.66%> (ø)
superset/viz.py 58.61% <27.27%> (ø)
superset/charts/commands/exceptions.py 92.85% <77.77%> (ø)
superset/utils/core.py 88.26% <87.50%> (ø)
superset/db_engine_specs/trino.py 90.47% <90.47%> (ø)
... and 936 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 2dbe92b...5ba5a73. Read the comment docs.

@junlincc junlincc added the api:charts Related to the REST endpoints of charts label Feb 15, 2021
Copy link
Member

@amitmiran137 amitmiran137 left a comment

Choose a reason for hiding this comment

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

left a comment.
also not sure if related or not but maybe this should be applied when importing a dataset?
https://github.com/apache/superset/blob/master/superset/datasets/commands/importers/v1/utils.py#L139
or it is only related to when loading the data into a viz

tests/utils_tests.py Outdated Show resolved Hide resolved
@villebro villebro force-pushed the villebro/fix-numeric-timestamp branch from 5ba5a73 to 3ea3022 Compare February 16, 2021 07:19
) -> pd.DataFrame:
if DTTM_ALIAS not in df.columns:
return df
df = df.copy()
Copy link
Member

Choose a reason for hiding this comment

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

Is the copy operation necessary here? This could be very expensive on memory for large result sets.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point @robdiciuccio . I'm a bit allergic to functions that mutate their inputs (even Pandas is moving away from this pattern), but this could in fact have a noticeable performance hit. I'm going to be touching this code in the coming days, so I'll make sure to address this then (either confirm that the copy is shallow enough to not cause a perf hit or remove the copy operation).

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, @villebro. DataFrame.copy() is deep by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api:charts Related to the REST endpoints of charts 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels preset-io size/L 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants