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: pivot table timestamp grouping #10774

Merged
merged 2 commits into from
Sep 3, 2020

Conversation

villebro
Copy link
Member

@villebro villebro commented Sep 3, 2020

SUMMARY

With the introduction of making temporal column formattable on pivot-table (#10637), formatting only worked for some databases. This expands support and adds tests to ensure formatting is applied correctly.

AFTER (Postgres)

Smart formatting with monthly timegrain:
image

BEFORE (Postgres)

Smart formatting doesn't affect format:
image

TEST PLAN

Local testing on postgres + sqlite + 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

for column_name in groupby + columns:
column = self.datasource.get_column(column_name)
if column and column.type in ("DATE", "DATETIME", "TIMESTAMP"):
ts = df[column_name].apply(_format_datetime)
if column and column.is_temporal:
Copy link
Member Author

Choose a reason for hiding this comment

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

Without calling column.is_temporal, Postgres datasources were not able to identify temporal columns e.g. TIMESTAMP WITHOUT TIMEZONE.

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, just a comment

superset/viz.py Outdated
@@ -856,6 +856,30 @@ def get_aggfunc(
# only min and max work properly for non-numerics
return aggfunc if aggfunc in ("min", "max") else "max"

@staticmethod
def _format_datetime(value: Any) -> Any:
Copy link
Member

Choose a reason for hiding this comment

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

nit: def _format_datetime(value: Union[pd.Timestamp, datetime, date, str]) -> Union[pd.Timestamp, datetime, date, str]:

@villebro villebro merged commit 70c6764 into apache:master Sep 3, 2020
@villebro villebro deleted the villebro/pivot-date-pt2 branch September 3, 2020 16:49
villebro added a commit to preset-io/superset that referenced this pull request Sep 3, 2020
* fix: pivot table timestamp grouping

* address comments
villebro added a commit that referenced this pull request Sep 5, 2020
* fix: pivot table timestamp grouping

* address comments
amitmiran137 pushed a commit to ofekisr/incubator-superset that referenced this pull request Sep 7, 2020
…boards_permissions

* upstream/master: (32 commits)
  docs: Add a note to contributing.md on reporting security vulnerabilities (apache#10796)
  Fix: Include RLS filters for cache keys (apache#10805)
  feat: filters for database list view (apache#10772)
  fix: MVC show saved query (apache#10781)
  added creator column and adjusted order columns (apache#10789)
  security: disallow uuid package on jinja2 (apache#10794)
  feat: CRUD REST API for saved queries (apache#10777)
  fix: disable domain sharding on explore view (apache#10787)
  fix: can not type `0.05` in `TextControl` (apache#10778)
  fix: pivot table timestamp grouping (apache#10774)
  fix: add validator information to email/slack alerts (apache#10762)
  More Label touchups (margins) (apache#10722)
  fix: dashboard extra filters (apache#10692)
  fix: re-installing local superset in cache image (apache#10766)
  feat: SIP-34 table list view for databases (apache#10705)
  refactor: convert DatasetList schema filter to use new distinct api (apache#10746)
  chore: removing fsevents dependency (apache#10751)
  Fix precommit hook for docs/installation.rst (apache#10759)
  feat(database): POST, PUT, DELETE API endpoints (apache#10741)
  docs: Update OAuth configuration in installation.rst (apache#10748)
  ...
@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
* fix: pivot table timestamp grouping

* address comments
villebro added a commit to preset-io/superset that referenced this pull request Sep 11, 2020
* fix: pivot table timestamp grouping

* address comments
villebro added a commit that referenced this pull request Sep 11, 2020
* fix: pivot table timestamp grouping

* address comments
villebro added a commit that referenced this pull request Sep 16, 2020
* fix: pivot table timestamp grouping

* address comments
auxten pushed a commit to auxten/incubator-superset that referenced this pull request Nov 20, 2020
* fix: pivot table timestamp grouping

* address comments
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
* fix: pivot table timestamp grouping

* address comments
@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.

3 participants