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

chore(data-table): make formatted dttm the default #20140

Merged
merged 1 commit into from
May 20, 2022

Conversation

villebro
Copy link
Member

@villebro villebro commented May 20, 2022

SUMMARY

This PR changes time formatting to be the default for temporal columns (previously defaulted to showing the original value). This is done by replacing the timeFormattedColumns with originalFormattedTimeColumns throughout the codebase, meaning if a dataset doesn't have defined values for them, they will default to using the time formatter.

In addition to changing the default, the DataTableTemporalHeaderCell will only be shown for tables where the first cell value isn't a string value. This is because some databases like Druid and SQLite return temporal data in string format, which causes the time formatter to convert the timestamp to UTC, causing x hours of offset. (For Finland, this would show all dates to show as 10 pm the previous day).

AFTER

Now the formatted option is the new default:
image

For datasets that have string-based temporal data, the regular non-temporal header is shown (screenshot from SQLite). Notice the first column ds which doesn't have the formatting cog:
image

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

Comment on lines -138 to -144
hook.result.current.forEach((col: JsonObject) => {
expect(col.Cell({ value: newData[0].col01 })).toBe(BOOL_TRUE_DISPLAY);
expect(col.Cell({ value: newData[0].col02 })).toBe(BOOL_FALSE_DISPLAY);
expect(col.Cell({ value: newData[0].col03 })).toBe('secret');
expect(col.Cell({ value: newData[0][asciiKey] })).toBe(asciiKey);
expect(col.Cell({ value: newData[0][unicodeKey] })).toBe(unicodeKey);
});
Copy link
Member Author

Choose a reason for hiding this comment

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

This logic was incorrect, and caused each cell formatter to process each value on the row

Copy link
Member

@kgabryje kgabryje left a comment

Choose a reason for hiding this comment

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

LGTM!

@codecov
Copy link

codecov bot commented May 20, 2022

Codecov Report

Merging #20140 (9b57993) into master (e2f11d3) will increase coverage by 0.00%.
The diff coverage is 50.00%.

@@           Coverage Diff           @@
##           master   #20140   +/-   ##
=======================================
  Coverage   66.45%   66.45%           
=======================================
  Files        1721     1721           
  Lines       64497    64500    +3     
  Branches     6805     6806    +1     
=======================================
+ Hits        42860    42863    +3     
  Misses      19905    19905           
  Partials     1732     1732           
Flag Coverage Δ
javascript 51.33% <50.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
...et-frontend/src/explore/reducers/exploreReducer.js 28.75% <0.00%> (ø)
...t-frontend/src/explore/reducers/getInitialState.ts 0.00% <ø> (ø)
superset-frontend/src/utils/localStorageHelpers.ts 90.00% <ø> (ø)
.../src/explore/components/DataTableControl/index.tsx 71.79% <72.72%> (+1.12%) ⬆️
...set-frontend/src/explore/actions/exploreActions.ts 50.00% <100.00%> (ø)
...nd/src/explore/components/DataTablesPane/index.tsx 71.55% <100.00%> (ø)
...lore/components/useOriginalFormattedTimeColumns.ts 75.00% <100.00%> (ø)

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 e2f11d3...9b57993. Read the comment docs.

{
col01: true,
col02: false,
col03: 'secret',
Copy link
Member Author

Choose a reason for hiding this comment

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

The data API never returns "suprise" values for columns that aren't listed in colnames, hence we don't need to test for this edge case.

@villebro villebro merged commit 0bcc21b into apache:master May 20, 2022
@villebro villebro deleted the villebro/formatted-column branch May 20, 2022 12:39
philipher29 pushed a commit to ValtechMobility/superset that referenced this pull request Jun 9, 2022
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.0.0 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 preset-io size/L 🚢 2.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants