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

[bugfix] fix timegrain addon regression #8165

Merged
merged 8 commits into from
Sep 8, 2019
Merged

[bugfix] fix timegrain addon regression #8165

merged 8 commits into from
Sep 8, 2019

Conversation

villebro
Copy link
Member

@villebro villebro commented Sep 3, 2019

CATEGORY

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

SUMMARY

Custom timegrains defined in superset_config.py stopped working somewhere between 0.32 and 0.34. This fixes the regression, removes an unnecessary private function and renames some functions and variables to more clearly indicate what is public and private. The tests were also lacking, as they only tested private methods, not the actual end result of making changes to the config file. Now both blacklisted and addon grains are tested properly.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TEST PLAN

Local testing + CI

ADDITIONAL INFORMATION

REVIEWERS

@lilila @mistercrunch

@codecov-io
Copy link

codecov-io commented Sep 3, 2019

Codecov Report

Merging #8165 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #8165      +/-   ##
=========================================
+ Coverage   66.18%   66.2%   +0.02%     
=========================================
  Files         479     479              
  Lines       22931   22934       +3     
  Branches     2524    2524              
=========================================
+ Hits        15176   15184       +8     
+ Misses       7621    7616       -5     
  Partials      134     134
Impacted Files Coverage Δ
superset/db_engine_specs/bigquery.py 52.23% <100%> (ø) ⬆️
superset/db_engine_specs/presto.py 77.8% <100%> (ø) ⬆️
superset/db_engine_specs/drill.py 54.16% <100%> (ø) ⬆️
superset/db_engine_specs/kylin.py 53.84% <100%> (ø) ⬆️
superset/db_engine_specs/db2.py 85.71% <100%> (ø) ⬆️
superset/db_engine_specs/teradata.py 88.88% <100%> (ø) ⬆️
superset/db_engine_specs/athena.py 57.89% <100%> (ø) ⬆️
superset/db_engine_specs/druid.py 100% <100%> (ø) ⬆️
superset/db_engine_specs/impala.py 65% <100%> (ø) ⬆️
superset/db_engine_specs/snowflake.py 59.09% <100%> (ø) ⬆️
... and 9 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 be33934...f735e08. Read the comment docs.

@villebro villebro changed the title [bugfix] fix timegrain addon regression [WIP][bugfix] fix timegrain addon regression Sep 4, 2019
@pull-request-size pull-request-size bot added size/L and removed size/M labels Sep 4, 2019
@villebro villebro changed the title [WIP][bugfix] fix timegrain addon regression [bugfix] fix timegrain addon regression Sep 4, 2019
@villebro
Copy link
Member Author

villebro commented Sep 4, 2019

This should be ready for review.

@lilila
Copy link

lilila commented Sep 5, 2019

Thank you @villebro , it works well (at least for mysql db)

@@ -161,7 +138,7 @@ def get_timestamp_expr(
:return: TimestampExpression object
"""
if time_grain:
time_expr = cls.time_grain_functions.get(time_grain)
time_expr = cls.get_time_grain_functions().get(time_grain)
Copy link
Member

Choose a reason for hiding this comment

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

[optional] we may want to materialize the result of get_time_grain_functions() instead of re-computing it every time. This being a static class (all @classmethods) it's a bit funky to do (no constructor). Maybe the @memoize decorator we have around somewhere would work.

May be overkill as this method may not be called much...

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree; while this should be minimal overhead, stuff like this tends to cause problems down the line left untreated. To avoid the risk of introducing new regressions I will not refactor this now, but added a TODO that I will try to remove in the near future (will aim to kill this when removing name from TimeGrain).

Copy link
Member

@mistercrunch mistercrunch left a comment

Choose a reason for hiding this comment

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

Minor comment, otherwise LGTM, feel free to merge

@villebro villebro merged commit 3250c5a into apache:master Sep 8, 2019
@mistercrunch mistercrunch added 🍒 0.34.1 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.35.0 labels Feb 28, 2024
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
* Fix regression in time grain addons

* Revert privatization of time_grain_functions

* Fix test

* Rename variable

* Fix test

* Fix typing error

* Refactor and add tests

* Add TODO
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 v0.34 🍒 0.34.1 🚢 0.35.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TIME_GRAIN_ADDON_FUNCTIONS not working in superset 0.34
4 participants