yuqi1129 commented on code in PR #11074: URL: https://github.com/apache/gravitino/pull/11074#discussion_r3256088205
########## core/src/main/java/org/apache/gravitino/storage/relational/service/SchemaPOStorageOps.java: ########## @@ -0,0 +1,117 @@ +/* + * 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.service; + +import java.util.List; +import java.util.stream.Collectors; +import org.apache.gravitino.Entity; +import org.apache.gravitino.NameIdentifier; +import org.apache.gravitino.Namespace; +import org.apache.gravitino.exceptions.NoSuchEntityException; +import org.apache.gravitino.storage.relational.mapper.SchemaMetaMapper; +import org.apache.gravitino.storage.relational.po.SchemaPO; + +public class SchemaPOStorageOps extends BasePOStorageOps<SchemaPO, SchemaMetaMapper> { + + public SchemaPOStorageOps() {} + + @Override + public void batchInsertPOs(SchemaMetaMapper mapper, List<SchemaPO> schemaPOs, boolean overwrite) { + if (overwrite) { + mapper.batchInsertSchemaMetaOnDuplicateKeyUpdate(schemaPOs); + } else { + mapper.batchInsertSchemaMeta(schemaPOs); + } + } + + @Override + public Integer updatePO(SchemaMetaMapper mapper, SchemaPO oldPO, SchemaPO newPO) { Review Comment: `BasePOStorageOps.updatePO` defines the argument order as `(newPO, oldPO)`, and `HierarchicalConversionPOStorageOps.updatePO` preserves that order when delegating. This override reverses the semantic names and calls `mapper.updateSchemaMeta(oldPO, newPO)`, but `SchemaMetaMapper.updateSchemaMeta` expects `newSchemaMeta` first and `oldSchemaMeta` second. That makes schema updates use the old row as the SET values and the new row as the WHERE predicate, so a rename/property update can silently update zero rows or fail incorrectly. Please swap the parameters here to `updatePO(..., SchemaPO newPO, SchemaPO oldPO)` and call `mapper.updateSchemaMeta(newPO, oldPO)`, and add a schema update/rename test that catches this. -- 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]
