geido commented on code in PR #32520:
URL: https://github.com/apache/superset/pull/32520#discussion_r1993789505


##########
superset/commands/dataset/update.py:
##########
@@ -189,3 +204,60 @@ def _get_duplicates(data: list[dict[str, Any]], key: str) 
-> list[str]:
             if count > 1
         ]
         return duplicates
+
+
+def validate_folders(  # noqa: C901
+    folders: list[FolderSchema],
+    metrics: list[SqlMetric],
+    columns: list[TableColumn],
+) -> None:
+    """
+    Additional folder validation.
+
+    The marshmallow schema will validate the folder structure, but we still 
need to
+    check that UUIDs are valid, names are unique and not reserved, and that 
there are
+    no cycles.
+    """
+    if not is_feature_enabled("DATASET_FOLDERS"):
+        raise ValidationError("Dataset folders are not enabled")
+
+    existing = {
+        "metric": {metric.uuid: metric.metric_name for metric in metrics},
+        "column": {column.uuid: column.column_name for column in columns},
+    }
+
+    queue: list[tuple[FolderSchema, list[str]]] = [(folder, []) for folder in 
folders]

Review Comment:
   Nice!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to