Skip to content

Commit

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

Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
  • Loading branch information
rdubois and villebro authored Mar 23, 2023
1 parent b077314 commit 07a6328
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 @@ -704,7 +704,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 07a6328

Please sign in to comment.