Skip to content

Commit

Permalink
fix(chart): non existent time grain no longer breaks the application (#…
Browse files Browse the repository at this point in the history
…23441)

Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
(cherry picked from commit 07a6328)
  • Loading branch information
rdubois authored and eschutho committed May 31, 2023
1 parent da157a7 commit 3f13463
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion superset/db_engine_specs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ def get_time_grain_expressions(cls) -> Dict[Optional[str], str]:
time_grain_expressions.update(grain_addon_expressions.get(cls.engine, {}))
denylist: List[str] = current_app.config["TIME_GRAIN_DENYLIST"]
for key in denylist:
time_grain_expressions.pop(key)
time_grain_expressions.pop(key, None)

return dict(
sorted(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,12 @@ def is_readonly(sql: str) -> bool:

def test_time_grain_denylist():
config = app.config.copy()
app.config["TIME_GRAIN_DENYLIST"] = ["PT1M"]
app.config["TIME_GRAIN_DENYLIST"] = ["PT1M", "SQLITE_NONEXISTENT_GRAIN"]

with app.app_context():
time_grain_functions = SqliteEngineSpec.get_time_grain_expressions()
assert not "PT1M" in time_grain_functions
assert not "SQLITE_NONEXISTENT_GRAIN" in time_grain_functions

app.config = config

Expand Down

0 comments on commit 3f13463

Please sign in to comment.