mchades commented on code in PR #12602:
URL: https://github.com/apache/gravitino/pull/12602#discussion_r3871538710


##########
core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/postgresql/SemanticModelVersionInfoPostgreSQLProvider.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+package org.apache.gravitino.storage.relational.mapper.provider.postgresql;
+
+import 
org.apache.gravitino.storage.relational.mapper.provider.base.SemanticModelVersionInfoBaseSQLProvider;
+import org.apache.gravitino.storage.relational.po.SemanticModelVersionInfoPO;
+import org.apache.ibatis.annotations.Param;
+
+/** Provides PostgreSQL SQL for creating Semantic Model version snapshots. */
+public class SemanticModelVersionInfoPostgreSQLProvider
+    extends SemanticModelVersionInfoBaseSQLProvider {
+
+  @Override
+  public String insertSemanticModelVersionInfoOnDuplicateKeyUpdate(
+      @Param("semanticModelVersionInfo") SemanticModelVersionInfoPO 
versionInfoPO) {
+    return insertSemanticModelVersionInfo(versionInfoPO)
+        + " ON CONFLICT (semantic_model_id, version, deleted_at) DO UPDATE SET"
+        + " semantic_model_name = 
#{semanticModelVersionInfo.semanticModelName},"
+        + " semantic_model_comment = 
#{semanticModelVersionInfo.semanticModelComment},"
+        + " semantic_model_definition = 
#{semanticModelVersionInfo.semanticModelDefinition},"
+        + " properties = #{semanticModelVersionInfo.properties},"
+        + " audit_info = #{semanticModelVersionInfo.auditInfo},"
+        + " deleted_at = #{semanticModelVersionInfo.deletedAt}";

Review Comment:
   A row reaches `DO UPDATE` only when its existing `(semantic_model_id, 
version, deleted_at)` values match the incoming conflict key. Therefore, the 
assigned `deleted_at` value is necessarily equal to the existing value; if it 
differs, this conflict target is not matched and the update is not executed. 
This also follows the existing PostgreSQL version-provider pattern used by 
tables, views, functions, policies, and filesets. The assignment is redundant 
but cannot cause the described uniqueness violation, so I am keeping it for 
consistency.



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