EnxDev commented on code in PR #43232:
URL: https://github.com/apache/superset/pull/43232#discussion_r4142912511


##########
superset/commands/dashboard/importers/v1/__init__.py:
##########
@@ -168,13 +176,21 @@ def _import(
                     "datasource_name": dataset.table_name,
                 }
 
+        # import annotation layers before charts so UUID→ID maps are ready
+        annotation_layer_ids: dict[str, int] = {}
+        for file_name, config in configs.items():
+            if file_name.startswith("annotation_layers/"):
+                layer = import_annotation_layer(config, 
overwrite=overwrite_assets)

Review Comment:
   Went ahead and did it in 87e98f9. `ImportAssetsCommand` now reads 
`annotation_layers/` and imports charts through the same `import_charts` 
helper, so NATIVE annotations survive an assets import on a fresh instance. 
Test is in `tests/integration_tests/commands_test.py`.
   



##########
superset/migrations/versions/2026-08-17_18-38_884a2115ebd3_add_uuid_to_annotation_layer_and_annotation.py:
##########
@@ -0,0 +1,126 @@
+# 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.
+"""add_uuid_to_annotation_layer_and_annotation
+
+Revision ID: 884a2115ebd3
+Revises: 95d8a99c822e
+Create Date: 2026-08-11 18:38:15.412396
+
+"""
+
+from uuid import uuid4
+
+import sqlalchemy as sa
+from alembic import op
+from sqlalchemy.exc import OperationalError
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy_utils import UUIDType
+
+from superset import db
+
+# revision identifiers, used by Alembic.
+revision = "884a2115ebd3"
+down_revision = "95d8a99c822e"
+
+Base = declarative_base()
+
+
+class ImportMixin:
+    id = sa.Column(sa.Integer, primary_key=True)
+    uuid = sa.Column(UUIDType(binary=True), primary_key=False, default=uuid4)
+
+
+class AnnotationLayer(ImportMixin, Base):
+    __tablename__ = "annotation_layer"
+
+
+class Annotation(ImportMixin, Base):
+    __tablename__ = "annotation"
+
+
+def _assign_missing_uuids(model: type[ImportMixin], session: sa.orm.Session) 
-> None:

Review Comment:
   Switched to `add_columns` and `assign_uuids` in 87e98f9, and the constraint 
steps check the inspector instead of catching `OperationalError`. That turned 
up a bug in `assign_uuids` itself: the non-native fallback assigned the `uuid4` 
function instead of a value, so it's fixed there too. Upgrade, re-upgrade and 
downgrade are clean on SQLite with existing rows.
   
   For the runtime estimate: about 31s for 100k annotation rows on SQLite 
(batched ORM path). Postgres and MySQL do one `UPDATE` per table, so they 
should be much faster.
   



-- 
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