Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

cherry pick bug fixes #157

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
13 changes: 0 additions & 13 deletions superset/assets/src/explore/components/ExploreViewContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ class ExploreViewContainer extends React.Component {

/* eslint no-unused-vars: 0 */
componentDidUpdate(prevProps, prevState) {
this.triggerQueryIfNeeded();

const changedControlKeys = this.findChangedControlKeys(prevProps.controls, this.props.controls);
if (this.hasDisplayControlChanged(changedControlKeys, this.props.controls)) {
this.addHistory({});
Expand Down Expand Up @@ -213,17 +211,6 @@ class ExploreViewContainer extends React.Component {
);
}

triggerQueryIfNeeded() {
if (this.props.chart.triggerQuery && !this.hasErrors()) {
this.props.actions.postChartFormData(
this.props.form_data,
false,
this.props.timeout,
this.props.chart.id,
);
}
}

addHistory({ isReplace = false, title }) {
const { payload } = getExploreUrlAndPayload({ formData: this.props.form_data });
const longUrl = getExploreLongUrl(this.props.form_data, null, false);
Expand Down
10 changes: 6 additions & 4 deletions superset/db_engine_specs/presto.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from typing import List, Set, Tuple
from urllib import parse

from sqlalchemy import Column, literal_column, types
from sqlalchemy import Column, literal_column
from sqlalchemy.engine.base import Engine
from sqlalchemy.engine.reflection import Inspector
from sqlalchemy.engine.result import RowProxy
Expand Down Expand Up @@ -231,7 +231,9 @@ def get_columns(
for column in columns:
try:
# parse column if it is a row or array
if "array" in column.Type or "row" in column.Type:
if is_feature_enabled("PRESTO_EXPAND_DATA") and (
"array" in column.Type or "row" in column.Type
):
structural_column_index = len(result)
cls._parse_structural_column(column.Column, column.Type, result)
result[structural_column_index]["nullable"] = getattr(
Expand All @@ -247,7 +249,7 @@ def get_columns(
column.Type, column.Column
)
)
column_type = types.NullType
column_type = "OTHER"
column_info = cls._create_column_info(column.Column, column_type)
column_info["nullable"] = getattr(column, "Null", True)
column_info["default"] = None
Expand Down Expand Up @@ -352,7 +354,7 @@ def select_star(
to an array's contents.
"""
presto_cols = cols
if show_cols:
if is_feature_enabled("PRESTO_EXPAND_DATA") and show_cols:
dot_regex = r"\.(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)"
presto_cols = [
col for col in presto_cols if not re.search(dot_regex, col["name"])
Expand Down
18 changes: 18 additions & 0 deletions tests/db_engine_specs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,16 +360,25 @@ def test_presto_get_column(self):
expected_results = [("column_name", "BOOLEAN")]
self.verify_presto_column(presto_column, expected_results)

@mock.patch.dict(
"superset._feature_flags", {"PRESTO_EXPAND_DATA": True}, clear=True
)
def test_presto_get_simple_row_column(self):
presto_column = ("column_name", "row(nested_obj double)", "")
expected_results = [("column_name", "ROW"), ("column_name.nested_obj", "FLOAT")]
self.verify_presto_column(presto_column, expected_results)

@mock.patch.dict(
"superset._feature_flags", {"PRESTO_EXPAND_DATA": True}, clear=True
)
def test_presto_get_simple_row_column_with_name_containing_whitespace(self):
presto_column = ("column name", "row(nested_obj double)", "")
expected_results = [("column name", "ROW"), ("column name.nested_obj", "FLOAT")]
self.verify_presto_column(presto_column, expected_results)

@mock.patch.dict(
"superset._feature_flags", {"PRESTO_EXPAND_DATA": True}, clear=True
)
def test_presto_get_simple_row_column_with_tricky_nested_field_name(self):
presto_column = ("column_name", 'row("Field Name(Tricky, Name)" double)', "")
expected_results = [
Expand All @@ -378,11 +387,17 @@ def test_presto_get_simple_row_column_with_tricky_nested_field_name(self):
]
self.verify_presto_column(presto_column, expected_results)

@mock.patch.dict(
"superset._feature_flags", {"PRESTO_EXPAND_DATA": True}, clear=True
)
def test_presto_get_simple_array_column(self):
presto_column = ("column_name", "array(double)", "")
expected_results = [("column_name", "ARRAY")]
self.verify_presto_column(presto_column, expected_results)

@mock.patch.dict(
"superset._feature_flags", {"PRESTO_EXPAND_DATA": True}, clear=True
)
def test_presto_get_row_within_array_within_row_column(self):
presto_column = (
"column_name",
Expand All @@ -397,6 +412,9 @@ def test_presto_get_row_within_array_within_row_column(self):
]
self.verify_presto_column(presto_column, expected_results)

@mock.patch.dict(
"superset._feature_flags", {"PRESTO_EXPAND_DATA": True}, clear=True
)
def test_presto_get_array_within_row_within_array_column(self):
presto_column = (
"column_name",
Expand Down