Skip to content

Commit

Permalink
Adds the migration processor
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-s-molina committed Jun 24, 2024
1 parent 85a22f2 commit ccce46a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions superset/cli/viz_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class VizType(str, Enum):
HISTOGRAM = "histogram"
LINE = "line"
PIVOT_TABLE = "pivot_table"
SANKEY = "sankey"

Check warning on line 36 in superset/cli/viz_migrations.py

View check run for this annotation

Codecov / codecov/patch

superset/cli/viz_migrations.py#L36

Added line #L36 was not covered by tests
SUNBURST = "sunburst"
TREEMAP = "treemap"

Expand Down Expand Up @@ -89,6 +90,7 @@ def migrate(viz_type: VizType, is_downgrade: bool = False) -> None:
MigrateHistogramChart,
MigrateLineChart,
MigratePivotTable,
MigrateSankey,
MigrateSunburst,
MigrateTreeMap,
)
Expand All @@ -103,6 +105,7 @@ def migrate(viz_type: VizType, is_downgrade: bool = False) -> None:
VizType.HISTOGRAM: MigrateHistogramChart,
VizType.LINE: MigrateLineChart,
VizType.PIVOT_TABLE: MigratePivotTable,
VizType.SANKEY: MigrateSankey,
VizType.SUNBURST: MigrateSunburst,
VizType.TREEMAP: MigrateTreeMap,
}
Expand Down
16 changes: 16 additions & 0 deletions superset/examples/configs/charts/Featured Charts/Sankey.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
slice_name: Sankey
description: null
certified_by: null
Expand Down
11 changes: 11 additions & 0 deletions superset/migrations/shared/migrate_viz/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,3 +303,14 @@ def _pre_action(self) -> None:
groupby = self.data.get("groupby")
if not groupby:
self.data["groupby"] = []


class MigrateSankey(MigrateViz):
source_viz_type = "sankey"
target_viz_type = "sankey_v2"
remove_keys = {"groupby"}

def _pre_action(self) -> None:
groupby = self.data.get("groupby")
self.data["source"] = groupby[0] if len(groupby) > 0 else None
self.data["target"] = groupby[1] if len(groupby) > 1 else None

Check warning on line 316 in superset/migrations/shared/migrate_viz/processors.py

View check run for this annotation

Codecov / codecov/patch

superset/migrations/shared/migrate_viz/processors.py#L314-L316

Added lines #L314 - L316 were not covered by tests

0 comments on commit ccce46a

Please sign in to comment.