You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2023/06/09 18:39:31 UTC

[superset] branch master updated: fix: Viz migration adjustments - 1 (#24341)

This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new 4e47771df1 fix: Viz migration adjustments - 1 (#24341)
4e47771df1 is described below

commit 4e47771df135e5f55fbbe5916a5e292a7804f5f9
Author: Michael S. Molina <70...@users.noreply.github.com>
AuthorDate: Fri Jun 9 15:39:23 2023 -0300

    fix: Viz migration adjustments - 1 (#24341)
---
 superset/migrations/shared/migrate_viz/base.py            | 2 ++
 superset/migrations/shared/migrate_viz/processors.py      | 4 +++-
 tests/unit_tests/migrations/viz/pivot_table_v1_v2_test.py | 2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/superset/migrations/shared/migrate_viz/base.py b/superset/migrations/shared/migrate_viz/base.py
index d3b2efa7a0..e277fcd208 100644
--- a/superset/migrations/shared/migrate_viz/base.py
+++ b/superset/migrations/shared/migrate_viz/base.py
@@ -25,6 +25,7 @@ from sqlalchemy import and_, Column, Integer, String, Text
 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()
@@ -95,6 +96,7 @@ class MigrateViz:
 
         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",
diff --git a/superset/migrations/shared/migrate_viz/processors.py b/superset/migrations/shared/migrate_viz/processors.py
index 1616154bf2..4044d9f4bc 100644
--- a/superset/migrations/shared/migrate_viz/processors.py
+++ b/superset/migrations/shared/migrate_viz/processors.py
@@ -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 = {
diff --git a/tests/unit_tests/migrations/viz/pivot_table_v1_v2_test.py b/tests/unit_tests/migrations/viz/pivot_table_v1_v2_test.py
index e7640f2b5e..ab357b62c3 100644
--- a/tests/unit_tests/migrations/viz/pivot_table_v1_v2_test.py
+++ b/tests/unit_tests/migrations/viz/pivot_table_v1_v2_test.py
@@ -45,7 +45,7 @@ TARGET_FORM_DATA = {
     "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,