Copilot commented on code in PR #13583:
URL: https://github.com/apache/ignite/pull/13583#discussion_r4044263485


##########
modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryEntityMerger.java:
##########
@@ -0,0 +1,261 @@
+/*
+ * 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.ignite.internal.processors.query;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import javax.cache.CacheException;
+import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.cache.QueryIndex;
+import org.apache.ignite.internal.util.typedef.F;
+
+/** Utility for merging compatible {@link QueryEntity} metadata. */
+public final class QueryEntityMerger {
+    /** */
+    private final String cacheName;
+
+    /** */
+    private QueryEntityMerger(String cacheName) {
+        this.cacheName = cacheName;
+    }
+
+    /**
+     * Merges incoming query entity metadata into existing entity.
+     *
+     * @param cacheName Cache name.
+     * @param existing Existing query entity.
+     * @param incoming Incoming query entity.
+     * @return Merged query entity.
+     * @throws CacheException If entities contain conflicting metadata.
+     */
+    public static QueryEntity merge(String cacheName, QueryEntity existing, 
QueryEntity incoming) {
+        return new QueryEntityMerger(cacheName).merge0(existing, incoming);
+    }
+
+    /** */
+    private QueryEntity merge0(QueryEntity ex, QueryEntity in) {
+        if (!Objects.equals(ex.findValueType(), in.findValueType())) {
+            throw new CacheException(
+                "Failed to merge query entities because value types differ " +
+                    "[cacheName=" + cacheName +
+                    ", existingValueType=" + ex.findValueType() +
+                    ", incomingValueType=" + in.findValueType() + ']'
+            );
+        }
+
+        QueryEntity res = new QueryEntity(ex);

Review Comment:
   This copy always turns the merged object into a plain `QueryEntity`. 
However, `setQueryEntities` is also used while applying schema-add patches, 
where configurations can contain `QueryEntityEx` instances; those carry 
`fillAbsentPKsWithDefaults`, `preserveKeysOrder`, `implicitPk`, SQL state, and 
primary/affinity inline sizes. The merged configuration will therefore lose 
those flags, and the query type setup will stop applying them. Preserve and 
merge the extended `QueryEntityEx` metadata whenever either input is an 
extended entity.



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