mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
refactor: migrate table chart to new API (#10270)
* refactor: migrate table chart to new API * chore: bump superset-ui to 0.17.0 * Fix Cypress tests * Apply soft-conversion to numeric metrics Fix time column formatting test * Add translation to chart does not exist error * Bump to 0.17.1
This commit is contained in:
8
tests/fixtures/query_context.py
vendored
8
tests/fixtures/query_context.py
vendored
@@ -21,13 +21,17 @@ from superset.utils.core import AnnotationType, DTTM_ALIAS
|
||||
from tests.base_tests import get_table_by_name
|
||||
|
||||
query_birth_names = {
|
||||
"extras": {"where": "", "time_range_endpoints": ["inclusive", "exclusive"]},
|
||||
"granularity": "ds",
|
||||
"extras": {
|
||||
"where": "",
|
||||
"time_range_endpoints": ["inclusive", "exclusive"],
|
||||
"time_grain_sqla": "P1D",
|
||||
},
|
||||
"groupby": ["name"],
|
||||
"metrics": [{"label": "sum__num"}],
|
||||
"order_desc": True,
|
||||
"orderby": [["sum__num", False]],
|
||||
"row_limit": 100,
|
||||
"granularity": "ds",
|
||||
"time_range": "100 years ago : now",
|
||||
"timeseries_limit": 0,
|
||||
"timeseries_limit_metric": None,
|
||||
|
||||
@@ -524,19 +524,40 @@ class TestPostProcessing(SupersetTestCase):
|
||||
"b": [1, 9],
|
||||
}
|
||||
)
|
||||
with pytest.raises(QueryObjectValidationError, match="not numeric"):
|
||||
proc.contribution(df, columns=[DTTM_ALIAS])
|
||||
|
||||
with pytest.raises(QueryObjectValidationError, match="same length"):
|
||||
proc.contribution(df, columns=["a"], rename_columns=["aa", "bb"])
|
||||
|
||||
# cell contribution across row
|
||||
row_df = proc.contribution(df, PostProcessingContributionOrientation.ROW)
|
||||
self.assertListEqual(df.columns.tolist(), [DTTM_ALIAS, "a", "b"])
|
||||
self.assertListEqual(series_to_list(row_df["a"]), [0.5, 0.25])
|
||||
self.assertListEqual(series_to_list(row_df["b"]), [0.5, 0.75])
|
||||
processed_df = proc.contribution(
|
||||
df, orientation=PostProcessingContributionOrientation.ROW,
|
||||
)
|
||||
self.assertListEqual(processed_df.columns.tolist(), [DTTM_ALIAS, "a", "b"])
|
||||
self.assertListEqual(processed_df["a"].tolist(), [0.5, 0.25])
|
||||
self.assertListEqual(processed_df["b"].tolist(), [0.5, 0.75])
|
||||
|
||||
# cell contribution across column without temporal column
|
||||
df.pop(DTTM_ALIAS)
|
||||
column_df = proc.contribution(df, PostProcessingContributionOrientation.COLUMN)
|
||||
self.assertListEqual(df.columns.tolist(), ["a", "b"])
|
||||
self.assertListEqual(series_to_list(column_df["a"]), [0.25, 0.75])
|
||||
self.assertListEqual(series_to_list(column_df["b"]), [0.1, 0.9])
|
||||
processed_df = proc.contribution(
|
||||
df, orientation=PostProcessingContributionOrientation.COLUMN
|
||||
)
|
||||
self.assertListEqual(processed_df.columns.tolist(), ["a", "b"])
|
||||
self.assertListEqual(processed_df["a"].tolist(), [0.25, 0.75])
|
||||
self.assertListEqual(processed_df["b"].tolist(), [0.1, 0.9])
|
||||
|
||||
# contribution only on selected columns
|
||||
processed_df = proc.contribution(
|
||||
df,
|
||||
orientation=PostProcessingContributionOrientation.COLUMN,
|
||||
columns=["a"],
|
||||
rename_columns=["pct_a"],
|
||||
)
|
||||
self.assertListEqual(processed_df.columns.tolist(), ["a", "b", "pct_a"])
|
||||
self.assertListEqual(processed_df["a"].tolist(), [1, 3])
|
||||
self.assertListEqual(processed_df["b"].tolist(), [1, 9])
|
||||
self.assertListEqual(processed_df["pct_a"].tolist(), [0.25, 0.75])
|
||||
|
||||
def test_prophet_valid(self):
|
||||
pytest.importorskip("fbprophet")
|
||||
|
||||
@@ -25,7 +25,6 @@ from superset.utils.core import (
|
||||
AdhocMetricExpressionType,
|
||||
ChartDataResultFormat,
|
||||
ChartDataResultType,
|
||||
FilterOperator,
|
||||
TimeRangeEndpoint,
|
||||
)
|
||||
from tests.base_tests import SupersetTestCase
|
||||
|
||||
@@ -20,7 +20,6 @@ from typing import Any, Dict, NamedTuple, List, Pattern, Tuple, Union
|
||||
from unittest.mock import patch
|
||||
import pytest
|
||||
|
||||
import tests.test_app
|
||||
from superset import db
|
||||
from superset.connectors.sqla.models import SqlaTable, TableColumn
|
||||
from superset.db_engine_specs.druid import DruidEngineSpec
|
||||
|
||||
Reference in New Issue
Block a user