You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by be...@apache.org on 2025/03/06 20:18:48 UTC
(superset) branch export-folders created (now 2b752c862d)
This is an automated email from the ASF dual-hosted git repository.
beto pushed a change to branch export-folders
in repository https://gitbox.apache.org/repos/asf/superset.git
at 2b752c862d feat: export/import for dataset folders
This branch includes the following new commits:
new 2b752c862d feat: export/import for dataset folders
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(superset) 01/01: feat: export/import for dataset folders
Posted by be...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
beto pushed a commit to branch export-folders
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 2b752c862dd67e0f23d8abf114b869e74beeccd1
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Thu Mar 6 13:10:15 2025 -0500
feat: export/import for dataset folders
---
superset/connectors/sqla/models.py | 1 +
tests/unit_tests/datasets/commands/export_test.py | 67 ++++++++++++++++
.../datasets/commands/importers/v1/import_test.py | 88 ++++++++++++++++++++++
3 files changed, 156 insertions(+)
diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py
index bbcf86d634..ecfbe6089f 100644
--- a/superset/connectors/sqla/models.py
+++ b/superset/connectors/sqla/models.py
@@ -1219,6 +1219,7 @@ class SqlaTable(
"extra",
"normalize_columns",
"always_filter_main_dttm",
+ "folders",
]
update_from_object_fields = [f for f in export_fields if f != "database_id"]
export_parent = "database"
diff --git a/tests/unit_tests/datasets/commands/export_test.py b/tests/unit_tests/datasets/commands/export_test.py
index f42bbfc9cb..04bc989ba5 100644
--- a/tests/unit_tests/datasets/commands/export_test.py
+++ b/tests/unit_tests/datasets/commands/export_test.py
@@ -16,6 +16,8 @@
# under the License.
# pylint: disable=import-outside-toplevel, unused-argument, unused-import
+from uuid import UUID
+
from sqlalchemy.orm.session import Session
from superset import db
@@ -47,6 +49,7 @@ def test_export(session: Session) -> None:
type="INTEGER",
expression="revenue-expenses",
extra=json.dumps({"certified_by": "User"}),
+ uuid=UUID("00000000-0000-0000-0000-000000000005"),
),
]
metrics = [
@@ -54,6 +57,7 @@ def test_export(session: Session) -> None:
metric_name="cnt",
expression="COUNT(*)",
extra=json.dumps({"warning_markdown": None}),
+ uuid=UUID("00000000-0000-0000-0000-000000000004"),
),
]
@@ -61,6 +65,46 @@ def test_export(session: Session) -> None:
table_name="my_table",
columns=columns,
metrics=metrics,
+ folders=[
+ {
+ "uuid": "00000000-0000-0000-0000-000000000000",
+ "type": "folder",
+ "name": "Engineering",
+ "children": [
+ {
+ "uuid": "00000000-0000-0000-0000-000000000001",
+ "type": "folder",
+ "name": "Core",
+ "children": [
+ {
+ "uuid": "00000000-0000-0000-0000-000000000004",
+ "type": "metric",
+ "name": "cnt",
+ },
+ ],
+ },
+ ],
+ },
+ {
+ "uuid": "00000000-0000-0000-0000-000000000002",
+ "type": "folder",
+ "name": "Sales",
+ "children": [
+ {
+ "uuid": "00000000-0000-0000-0000-000000000003",
+ "type": "folder",
+ "name": "Core",
+ "children": [
+ {
+ "uuid": "00000000-0000-0000-0000-000000000005",
+ "type": "column",
+ "name": "profit",
+ },
+ ],
+ },
+ ],
+ },
+ ],
main_dttm_col="ds",
database=database,
offset=-8,
@@ -126,6 +170,29 @@ extra:
warning_markdown: '*WARNING*'
normalize_columns: false
always_filter_main_dttm: false
+folders:
+- uuid: 00000000-0000-0000-0000-000000000000
+ type: folder
+ name: Engineering
+ children:
+ - uuid: 00000000-0000-0000-0000-000000000001
+ type: folder
+ name: Core
+ children:
+ - uuid: 00000000-0000-0000-0000-000000000004
+ type: metric
+ name: cnt
+- uuid: 00000000-0000-0000-0000-000000000002
+ type: folder
+ name: Sales
+ children:
+ - uuid: 00000000-0000-0000-0000-000000000003
+ type: folder
+ name: Core
+ children:
+ - uuid: 00000000-0000-0000-0000-000000000005
+ type: column
+ name: profit
uuid: {payload["uuid"]}
metrics:
- metric_name: cnt
diff --git a/tests/unit_tests/datasets/commands/importers/v1/import_test.py b/tests/unit_tests/datasets/commands/importers/v1/import_test.py
index 2a2038046d..e0dc90e41d 100644
--- a/tests/unit_tests/datasets/commands/importers/v1/import_test.py
+++ b/tests/unit_tests/datasets/commands/importers/v1/import_test.py
@@ -86,6 +86,7 @@ def test_import_dataset(mocker: MockerFixture, session: Session) -> None:
"d3format": None,
"extra": {"warning_markdown": None},
"warning_text": None,
+ "uuid": "00000000-0000-0000-0000-000000000001",
}
],
"columns": [
@@ -103,8 +104,49 @@ def test_import_dataset(mocker: MockerFixture, session: Session) -> None:
"extra": {
"certified_by": "User",
},
+ "uuid": "00000000-0000-0000-0000-000000000002",
}
],
+ "folders": [
+ {
+ "uuid": "00000000-0000-0000-0000-000000000000",
+ "type": "folder",
+ "name": "Engineering",
+ "children": [
+ {
+ "uuid": "00000000-0000-0000-0000-000000000001",
+ "type": "folder",
+ "name": "Core",
+ "children": [
+ {
+ "uuid": "00000000-0000-0000-0000-000000000004",
+ "type": "metric",
+ "name": "cnt",
+ },
+ ],
+ },
+ ],
+ },
+ {
+ "uuid": "00000000-0000-0000-0000-000000000002",
+ "type": "folder",
+ "name": "Sales",
+ "children": [
+ {
+ "uuid": "00000000-0000-0000-0000-000000000003",
+ "type": "folder",
+ "name": "Core",
+ "children": [
+ {
+ "uuid": "00000000-0000-0000-0000-000000000005",
+ "type": "column",
+ "name": "profit",
+ },
+ ],
+ },
+ ],
+ },
+ ],
"database_uuid": database.uuid,
"database_id": database.id,
}
@@ -136,6 +178,9 @@ def test_import_dataset(mocker: MockerFixture, session: Session) -> None:
assert sqla_table.metrics[0].d3format is None
assert sqla_table.metrics[0].extra == '{"warning_markdown": null}'
assert sqla_table.metrics[0].warning_text is None
+ assert sqla_table.metrics[0].uuid == uuid.UUID(
+ "00000000-0000-0000-0000-000000000001"
+ )
assert len(sqla_table.columns) == 1
assert sqla_table.columns[0].column_name == "profit"
assert sqla_table.columns[0].verbose_name is None
@@ -148,6 +193,49 @@ def test_import_dataset(mocker: MockerFixture, session: Session) -> None:
assert sqla_table.columns[0].description is None
assert sqla_table.columns[0].python_date_format is None
assert sqla_table.columns[0].extra == '{"certified_by": "User"}'
+ assert sqla_table.columns[0].uuid == uuid.UUID(
+ "00000000-0000-0000-0000-000000000002"
+ )
+ assert sqla_table.folders == [
+ {
+ "uuid": "00000000-0000-0000-0000-000000000000",
+ "type": "folder",
+ "name": "Engineering",
+ "children": [
+ {
+ "uuid": "00000000-0000-0000-0000-000000000001",
+ "type": "folder",
+ "name": "Core",
+ "children": [
+ {
+ "uuid": "00000000-0000-0000-0000-000000000004",
+ "type": "metric",
+ "name": "cnt",
+ },
+ ],
+ },
+ ],
+ },
+ {
+ "uuid": "00000000-0000-0000-0000-000000000002",
+ "type": "folder",
+ "name": "Sales",
+ "children": [
+ {
+ "uuid": "00000000-0000-0000-0000-000000000003",
+ "type": "folder",
+ "name": "Core",
+ "children": [
+ {
+ "uuid": "00000000-0000-0000-0000-000000000005",
+ "type": "column",
+ "name": "profit",
+ },
+ ],
+ },
+ ],
+ },
+ ]
assert sqla_table.database.uuid == database.uuid
assert sqla_table.database.id == database.id