SEPURI-SAI-KRISHNA commented on code in PR #28994: URL: https://github.com/apache/flink/pull/28994#discussion_r3881550502
########## flink-table/flink-table-common/src/test/java/org/apache/flink/table/types/inference/strategies/ObjectUpdateTypeStrategyTest.java: ########## @@ -0,0 +1,91 @@ +/* + * 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.flink.table.types.inference.strategies; + +import org.apache.flink.table.api.DataTypes; +import org.apache.flink.table.types.inference.TypeStrategiesTestBase; + +import java.util.stream.Stream; + +/** Tests for {@link ObjectUpdateTypeStrategy}. */ +class ObjectUpdateTypeStrategyTest extends TypeStrategiesTestBase { + + private static final String USER_CLASS_PATH = "com.example.User"; + + @Override + protected Stream<TestSpec> testData() { + return Stream.of( + // The attribute names below are chosen such that their hash order differs from + // their declaration order. The inferred type must always follow the declaration + // order of the input type, because the runtime writes the updated values at the + // declared positions. + TestSpec.forStrategy( + "Attribute order is preserved when the updated value changes the type", Review Comment: Added nested object, array of objects, nested array, map with an object value, and variant cases. All eight specs fail without the fix. Adding them surfaced a second ordering issue in the same function: the validation error built its attribute list from a `HashMap`, so it reported the available attributes out of declaration order too. Fixed here with an ITCase case for it. The type strategy now iterates the declared attributes instead of depending on map order. -- 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]
