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: Add type specific date truncation functions to BigQuery #9238

Merged
merged 1 commit into from
Mar 5, 2020
Merged

fix: Add type specific date truncation functions to BigQuery #9238

merged 1 commit into from
Mar 5, 2020

Conversation

villebro
Copy link
Member

@villebro villebro commented Mar 4, 2020

CATEGORY

Choose one

  • Bug Fix
  • Enhancement (new features, refinement)
  • Refactor
  • Add tests
  • Build / Development Environment
  • Documentation

SUMMARY

Superset currently only supports having a common truncation function for time grain expressions. BigQuery, on the other hand, requires type-specific truncation functions for all temporal types:

https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#time_trunc
https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#date_trunc
https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#datetime_trunc
https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#timestamp_trunc

This PR adds the option to specify a type-specific truncation function denoted {func} in the time grain expression. For example, the time grain expression {func}({col}, HOUR) with type DATE will yield DATE_TRUNC(my_col, HOUR). Similarly, DATETIME will yield DATETIME_TRUNC(my_col, HOUR). This also renames the config option TIME_GRAIN_ADDON_FUNCTIONS to TIME_GRAIN_ADDON_EXPRESSIONS, as they weren't really functions, but rather expressions.

BEFORE

image

AFTER

(note DATETIME_TRUNC instead of TIMESTAMP_TRUNC)
image

TEST PLAN

CI + Tested locally.

ADDITIONAL INFORMATION

REVIEWERS

@willbarrett
Copy link
Member

Overall looks good but it appears you have some pylint and mypy issues to resolve. Thanks for taking this on!

@codecov-io
Copy link

Codecov Report

Merging #9238 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #9238   +/-   ##
=======================================
  Coverage   58.93%   58.93%           
=======================================
  Files         373      373           
  Lines       12014    12014           
  Branches     2945     2945           
=======================================
  Hits         7080     7080           
  Misses       4755     4755           
  Partials      179      179

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 7a91498...637e2e1. Read the comment docs.

@villebro
Copy link
Member Author

villebro commented Mar 4, 2020

Thanks @willbarrett ; fixed lint and added UPDATING.md comment

Copy link
Member

@willbarrett willbarrett 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 requested a review from john-bodley March 4, 2020 19:25
@villebro villebro merged commit ef2ebbd into apache:master Mar 5, 2020
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.36.0 labels Feb 28, 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/L 🚢 0.36.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Time Grain for BigQuery type: DATE & DATETIME is not available
5 participants