Skip to content

Commit

Permalink
fix: Viz migration adjustments - 1 (#24341)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-s-molina authored Jun 9, 2023
1 parent 9adb023 commit 4e47771
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions superset/migrations/shared/migrate_viz/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from sqlalchemy.ext.declarative import declarative_base

from superset import conf, db, is_feature_enabled
from superset.constants import TimeGrain
from superset.migrations.shared.utils import paginated_update, try_load_json

Base = declarative_base()
Expand Down Expand Up @@ -95,6 +96,7 @@ def _migrate_temporal_filter(self, rv_data: dict[str, Any]) -> None:

if self.has_x_axis_control:
rv_data["x_axis"] = granularity_sqla
rv_data["time_grain_sqla"] = rv_data.get("time_grain_sqla") or TimeGrain.DAY

temporal_filter = {
"clause": "WHERE",
Expand Down
4 changes: 3 additions & 1 deletion superset/migrations/shared/migrate_viz/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@ class MigratePivotTable(MigrateViz):
def _pre_action(self) -> None:
if pivot_margins := self.data.get("pivot_margins"):
self.data["colTotals"] = pivot_margins
self.data["rowTotals"] = pivot_margins

if pandas_aggfunc := self.data.get("pandas_aggfunc"):
self.data["pandas_aggfunc"] = self.aggregation_mapping[pandas_aggfunc]

self.data["rowOrder"] = "value_z_to_a"


class MigrateDualLine(MigrateViz):
has_x_axis_control = True
source_viz_type = "dual_line"
target_viz_type = "mixed_timeseries"
rename_keys = {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/migrations/viz/pivot_table_v1_v2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"granularity_sqla": "ds",
"groupbyColumns": ["state"],
"groupbyRows": ["name"],
"rowTotals": True,
"rowOrder": "value_z_to_a",
"series_limit_metric": "count",
"time_range": "100 years ago : now",
"transposePivot": True,
Expand Down

0 comments on commit 4e47771

Please sign in to comment.