jerryshao commented on code in PR #11036:
URL: https://github.com/apache/gravitino/pull/11036#discussion_r3232206820


##########
core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/base/OwnerMetaBaseSQLProvider.java:
##########
@@ -124,6 +125,35 @@ public String insertOwnerRel(@Param("ownerRelPO") 
OwnerRelPO ownerRelPO) {
         + ")";
   }
 
+  public String batchInsertOwnerRels(@Param("ownerRelPOs") List<OwnerRelPO> 
ownerRelPOs) {
+    return "<script>"
+        + "INSERT INTO "
+        + OWNER_TABLE_NAME
+        + " (metalake_id, metadata_object_id, metadata_object_type, owner_id, 
owner_type,"
+        + " audit_info, current_version, last_version, deleted_at, updated_at) 
VALUES "
+        + "<foreach collection='ownerRelPOs' item='po' separator=','>"
+        + "(#{po.metalakeId}, #{po.metadataObjectId}, 
#{po.metadataObjectType},"
+        + " #{po.ownerId}, #{po.ownerType}, #{po.auditInfo},"
+        + " #{po.currentVersion}, #{po.lastVersion}, #{po.deletedAt}, 
#{po.updatedAt})"
+        + "</foreach>"
+        + "</script>";
+  }
+
+  public String batchSoftDeleteOwnerRelByMetadataObjects(
+      @Param("deletions") List<OwnerRelForDeletion> deletions) {
+    return "<script>"
+        + "UPDATE "
+        + OWNER_TABLE_NAME
+        + " SET deleted_at = (UNIX_TIMESTAMP() * 1000.0)"

Review Comment:
   **MySQL soft-delete timestamp produces a `DOUBLE`, not `BIGINT`**
   
   `UNIX_TIMESTAMP()` (no argument) returns a plain integer — no sub-second 
precision. Adding `EXTRACT(MICROSECOND FROM CURRENT_TIMESTAMP(3)) / 1000` makes 
the expression a `DOUBLE`, which is then stored into the `BIGINT` `deleted_at` 
column via an implicit cast. MySQL silently truncates, but this is fragile and 
inconsistent with the PostgreSQL override which uses `CAST(... AS BIGINT)` 
explicitly.
   
   Consider wrapping with `FLOOR()` to make the truncation explicit:
   ```sql
   SET deleted_at = FLOOR((UNIX_TIMESTAMP() * 1000.0)
       + EXTRACT(MICROSECOND FROM CURRENT_TIMESTAMP(3)) / 1000)
   ```



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

Reply via email to