Skip to content

Commit

Permalink
fix(dashboard): show_native_filters leftover (apache#23389)
Browse files Browse the repository at this point in the history
(cherry picked from commit 0222139)
  • Loading branch information
betodealmeida authored and jinghua-qa committed Mar 20, 2023
1 parent 845b2a7 commit 4bb3b9b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions superset/dashboards/commands/importers/v1/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ def import_dashboard(

# TODO (betodealmeida): move this logic to import_from_dict
config = config.copy()

# removed in https://github.com/apache/superset/pull/23228
if "metadata" in config and "show_native_filters" in config["metadata"]:
del config["metadata"]["show_native_filters"]

for key, new_name in JSON_KEYS.items():
if config.get(key) is not None:
value = config.pop(key)
Expand Down
19 changes: 18 additions & 1 deletion superset/dashboards/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import re
from typing import Any, Dict, Union

from marshmallow import fields, post_load, Schema
from marshmallow import fields, post_load, pre_load, Schema
from marshmallow.validate import Length, ValidationError

from superset.exceptions import SupersetException
Expand Down Expand Up @@ -135,6 +135,23 @@ class DashboardJSONMetadataSchema(Schema):
remote_id = fields.Integer()
filter_bar_orientation = fields.Str(allow_none=True)

@pre_load
def remove_show_native_filters( # pylint: disable=unused-argument, no-self-use
self,
data: Dict[str, Any],
**kwargs: Any,
) -> Dict[str, Any]:
"""
Remove ``show_native_filters`` from the JSON metadata.
This field was removed in https://github.com/apache/superset/pull/23228, but might
be present in old exports.
"""
if "show_native_filters" in data:
del data["show_native_filters"]

return data


class UserSchema(Schema):
id = fields.Int()
Expand Down

0 comments on commit 4bb3b9b

Please sign in to comment.