mirror of https://github.com/apache/superset.git
Add feature flag for Presto expand data (#8056)
* Add feature flag for Presto expand data * Fix unit tests * Fix black * Revert temporary file change
This commit is contained in:
parent
ef1d4a6aa1
commit
478d0969a8
|
@ -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 <https://sjl.bitbucket.io/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 <https://github.com/apache/incubator-superset/pull/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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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"},
|
||||
|
|
Loading…
Reference in New Issue