diff --git a/docs/installation.rst b/docs/installation.rst index e5606574fe..3264ab1707 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -1185,7 +1185,8 @@ You can enable or disable features with flag from ``superset_config.py``: DEFAULT_FEATURE_FLAGS = { 'CLIENT_CACHE': False, - 'ENABLE_EXPLORE_JSON_CSRF_PROTECTION': False + 'ENABLE_EXPLORE_JSON_CSRF_PROTECTION': False, + 'PRESTO_EXPAND_DATA': False, } Here is a list of flags and descriptions: @@ -1195,3 +1196,7 @@ Here is a list of flags and descriptions: * For some security concerns, you may need to enforce CSRF protection on all query request to explore_json endpoint. In Superset, we use `flask-csrf `_ add csrf protection for all POST requests, but this protection doesn't apply to GET method. * When ENABLE_EXPLORE_JSON_CSRF_PROTECTION is set to true, your users cannot make GET request to explore_json. The default value for this feature False (current behavior), explore_json accepts both GET and POST request. See `PR 7935 `_ for more details. + +* PRESTO_EXPAND_DATA + + * When this feature is enabled, nested types in Presto will be expanded into extra columns and/or arrays. This is experimental, and doesn't work with all nested types. diff --git a/superset/config.py b/superset/config.py index bcdd0f63c6..085c8e2e56 100644 --- a/superset/config.py +++ b/superset/config.py @@ -208,6 +208,7 @@ DEFAULT_FEATURE_FLAGS = { # Experimental feature introducing a client (browser) cache "CLIENT_CACHE": False, "ENABLE_EXPLORE_JSON_CSRF_PROTECTION": False, + "PRESTO_EXPAND_DATA": False, } # A function that receives a dict of all feature flags diff --git a/superset/db_engine_specs/presto.py b/superset/db_engine_specs/presto.py index 6708b0671a..a2b02cdcf4 100644 --- a/superset/db_engine_specs/presto.py +++ b/superset/db_engine_specs/presto.py @@ -30,6 +30,7 @@ from sqlalchemy.engine.reflection import Inspector from sqlalchemy.engine.result import RowProxy from sqlalchemy.sql.expression import ColumnClause +from superset import is_feature_enabled from superset.db_engine_specs.base import BaseEngineSpec from superset.exceptions import SupersetTemplateException from superset.models.sql_types.presto_sql_types import type_map as presto_type_map @@ -749,6 +750,9 @@ class PrestoEngineSpec(BaseEngineSpec): :return: list of all columns(selected columns and their nested fields), expanded data set, listed of nested fields """ + if not is_feature_enabled("PRESTO_EXPAND_DATA"): + return columns, data, [] + all_columns: List[dict] = [] # Get the list of all columns (selected fields and their nested fields) for column in columns: diff --git a/tests/db_engine_specs_test.py b/tests/db_engine_specs_test.py index a70c8cdb2a..acd7180f1c 100644 --- a/tests/db_engine_specs_test.py +++ b/tests/db_engine_specs_test.py @@ -614,6 +614,9 @@ class DbEngineSpecsTestCase(SupersetTestCase): } self.assertEqual(array_col_hierarchy, expected_array_col_hierarchy) + @mock.patch.dict( + "superset._feature_flags", {"PRESTO_EXPAND_DATA": True}, clear=True + ) def test_presto_expand_data_with_simple_structural_columns(self): cols = [ {"name": "row_column", "type": "ROW(NESTED_OBJ VARCHAR)"}, @@ -644,6 +647,9 @@ class DbEngineSpecsTestCase(SupersetTestCase): self.assertEqual(actual_data, expected_data) self.assertEqual(actual_expanded_cols, expected_expanded_cols) + @mock.patch.dict( + "superset._feature_flags", {"PRESTO_EXPAND_DATA": True}, clear=True + ) def test_presto_expand_data_with_complex_row_columns(self): cols = [ { @@ -684,6 +690,9 @@ class DbEngineSpecsTestCase(SupersetTestCase): self.assertEqual(actual_data, expected_data) self.assertEqual(actual_expanded_cols, expected_expanded_cols) + @mock.patch.dict( + "superset._feature_flags", {"PRESTO_EXPAND_DATA": True}, clear=True + ) def test_presto_expand_data_with_complex_array_columns(self): cols = [ {"name": "int_column", "type": "BIGINT"},