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(chart): non existent time grain no longer breaks the application #23441

Merged
merged 3 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion superset/db_engine_specs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,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