superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject [incubator-superset] branch master updated: Add feature flag for Presto expand data (#8056)
Date Fri, 16 Aug 2019 03:10:20 GMT
This is an automated email from the ASF dual-hosted git repository.

beto pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 478d096  Add feature flag for Presto expand data (#8056)
478d096 is described below

commit 478d0969a8285d49636c8441472ddcbc205da672
Author: Beto Dealmeida <roberto@dealmeida.net>
AuthorDate: Thu Aug 15 20:10:05 2019 -0700

    Add feature flag for Presto expand data (#8056)
    
    * Add feature flag for Presto expand data
    
    * Fix unit tests
    
    * Fix black
    
    * Revert temporary file change
---
 docs/installation.rst              | 7 ++++++-
 superset/config.py                 | 1 +
 superset/db_engine_specs/presto.py | 4 ++++
 tests/db_engine_specs_test.py      | 9 +++++++++
 4 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/docs/installation.rst b/docs/installation.rst
index e560657..3264ab1 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 <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.
diff --git a/superset/config.py b/superset/config.py
index bcdd0f6..085c8e2 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 6708b06..a2b02cd 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 a70c8cd..acd7180 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"},


Mime
View raw message