You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "twalthr (via GitHub)" <gi...@apache.org> on 2026/02/25 14:31:47 UTC
[PR] [FLINK-39157][table-common] Add ColumnList.hashCode()/equals() [flink]
twalthr opened a new pull request, #27674:
URL: https://github.com/apache/flink/pull/27674
## What is the purpose of the change
Improves the quality of `ColumnList`.
## Brief change log
- hashCode/equals
- error behavior
## Verifying this change
This change added tests and can be verified as follows:
- `ColumnListTest`
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): no
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: yes
- The serializers: no
- The runtime per-record code paths (performance sensitive): no
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
- The S3 file system connector: no
## Documentation
- Does this pull request introduce a new feature? no
- If yes, how is the feature documented? not applicable
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39157][table-common] Add ColumnList.hashCode()/equals() [flink]
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #27674:
URL: https://github.com/apache/flink/pull/27674#issuecomment-3959740957
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "0b024da4b91551c432b8b4f663fece1f16b87f8b",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "0b024da4b91551c432b8b4f663fece1f16b87f8b",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 0b024da4b91551c432b8b4f663fece1f16b87f8b UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39157][table-common] Add ColumnList.hashCode()/equals() [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #27674:
URL: https://github.com/apache/flink/pull/27674#discussion_r2853428313
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/types/ColumnList.java:
##########
@@ -46,15 +47,20 @@ public final class ColumnList implements Serializable {
private final List<DataType> dataTypes;
private ColumnList(List<String> names, List<DataType> dataTypes) {
- this.names = Preconditions.checkNotNull(names, "Names must not be null.");
- this.dataTypes = Preconditions.checkNotNull(dataTypes, "Data types must be null.");
+ Preconditions.checkNotNull(names, "Names must not be null.");
Review Comment:
should we have a check here that all names are unique?
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39157][table-common] Add ColumnList.hashCode()/equals() [flink]
Posted by "twalthr (via GitHub)" <gi...@apache.org>.
twalthr merged PR #27674:
URL: https://github.com/apache/flink/pull/27674
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39157][table-common] Add ColumnList.hashCode()/equals() [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #27674:
URL: https://github.com/apache/flink/pull/27674#discussion_r2853412330
##########
flink-table/flink-table-common/src/test/java/org/apache/flink/types/ColumnListTest.java:
##########
@@ -0,0 +1,164 @@
+/*
+ * 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.types;
+
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.types.DataType;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/** Tests for {@link ColumnList}. */
+class ColumnListTest {
+
+ @Test
+ void testWithNamesAndDataTypes() {
+ final List<String> names = Arrays.asList("a", "b", "c");
+ final List<DataType> dataTypes =
+ Arrays.asList(DataTypes.INT(), DataTypes.STRING(), DataTypes.BOOLEAN());
+
+ final ColumnList columnList = ColumnList.of(names, dataTypes);
+
+ assertThat(columnList.getNames()).isEqualTo(names);
+ assertThat(columnList.getDataTypes()).isEqualTo(dataTypes);
+ }
+
+ @Test
+ void testWithNamesOnly() {
+ final List<String> names = Arrays.asList("a", "b", "c");
+
+ final ColumnList columnList = ColumnList.of(names);
+
+ assertThat(columnList.getNames()).isEqualTo(names);
+ assertThat(columnList.getDataTypes()).isEmpty();
+ }
+
+ @Test
+ void testWithEmptyLists() {
+ final ColumnList columnList =
+ ColumnList.of(Collections.emptyList(), Collections.emptyList());
+
+ assertThat(columnList.getNames()).isEmpty();
+ assertThat(columnList.getDataTypes()).isEmpty();
+ }
+
+ @Test
+ void testToStringWithNamesOnly() {
+ final ColumnList columnList = ColumnList.of("a", "b", "c");
+
+ assertThat(columnList.toString()).isEqualTo("(`a`, `b`, `c`)");
+ }
+
+ @Test
+ void testToStringWithNamesAndDataTypes() {
+ final List<String> names = Arrays.asList("a", "b", "c");
+ final List<DataType> dataTypes =
+ Arrays.asList(DataTypes.INT(), DataTypes.STRING(), DataTypes.BOOLEAN());
+
+ final ColumnList columnList = ColumnList.of(names, dataTypes);
+
+ assertThat(columnList.toString()).isEqualTo("(`a` INT, `b` STRING, `c` BOOLEAN)");
+ }
+
+ @Test
+ void testEqualsAndHashCode() {
+ final List<String> names = Arrays.asList("a", "b");
+ final List<DataType> dataTypes = Arrays.asList(DataTypes.INT(), DataTypes.STRING());
+
+ final ColumnList columnList1 = ColumnList.of(names, dataTypes);
+ final ColumnList columnList2 = ColumnList.of(names, dataTypes);
+ final ColumnList columnList3 = ColumnList.of(Arrays.asList("a", "b"));
+
+ assertThat(columnList1).isEqualTo(columnList2);
+ assertThat(columnList1.hashCode()).isEqualTo(columnList2.hashCode());
+ assertThat(columnList1).isNotEqualTo(columnList3);
+ }
+
+ @Test
+ void testNullNamesThrowsException() {
+ assertThatThrownBy(() -> ColumnList.of(null, Collections.emptyList()))
+ .isInstanceOf(NullPointerException.class)
+ .hasMessageContaining("Names must not be null");
+ }
+
+ @Test
+ void testNullDataTypesThrowsException() {
+ assertThatThrownBy(() -> ColumnList.of(Arrays.asList("a"), null))
+ .isInstanceOf(NullPointerException.class)
+ .hasMessageContaining("Data types must not be null");
+ }
+
+ @Test
+ void testMismatchedDataTypesAndNamesThrowsException() {
+ final List<String> names = Arrays.asList("a", "b", "c");
+ final List<DataType> dataTypes = Arrays.asList(DataTypes.INT(), DataTypes.STRING());
+
+ assertThatThrownBy(() -> ColumnList.of(names, dataTypes))
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("Mismatch between data types and names");
+ }
+
+ @Test
+ void testNullElementInNamesThrowsException() {
+ final List<String> names = Arrays.asList("a", null, "c");
+
+ assertThatThrownBy(() -> ColumnList.of(names))
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("Names must not contain null elements");
+ }
+
+ @Test
+ void testNullElementInDataTypesThrowsException() {
+ final List<String> names = Arrays.asList("a", "b", "c");
+ final List<DataType> dataTypes = Arrays.asList(DataTypes.INT(), null, DataTypes.BOOLEAN());
+
+ assertThatThrownBy(() -> ColumnList.of(names, dataTypes))
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("Data types must not contain null elements");
+ }
+
+ @Test
+ void testImmutabilityOfNames() {
+ final List<String> names = new ArrayList<>(Arrays.asList("a", "b"));
Review Comment:
```suggestion
final List<String> names = List.of("a", "b"));
```
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39157][table-common] Add ColumnList.hashCode()/equals() [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #27674:
URL: https://github.com/apache/flink/pull/27674#discussion_r2853411061
##########
flink-table/flink-table-common/src/test/java/org/apache/flink/types/ColumnListTest.java:
##########
@@ -0,0 +1,164 @@
+/*
+ * 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.types;
+
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.types.DataType;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/** Tests for {@link ColumnList}. */
+class ColumnListTest {
+
+ @Test
+ void testWithNamesAndDataTypes() {
+ final List<String> names = Arrays.asList("a", "b", "c");
+ final List<DataType> dataTypes =
+ Arrays.asList(DataTypes.INT(), DataTypes.STRING(), DataTypes.BOOLEAN());
+
+ final ColumnList columnList = ColumnList.of(names, dataTypes);
+
+ assertThat(columnList.getNames()).isEqualTo(names);
+ assertThat(columnList.getDataTypes()).isEqualTo(dataTypes);
+ }
+
+ @Test
+ void testWithNamesOnly() {
+ final List<String> names = Arrays.asList("a", "b", "c");
+
+ final ColumnList columnList = ColumnList.of(names);
+
+ assertThat(columnList.getNames()).isEqualTo(names);
+ assertThat(columnList.getDataTypes()).isEmpty();
+ }
+
+ @Test
+ void testWithEmptyLists() {
+ final ColumnList columnList =
+ ColumnList.of(Collections.emptyList(), Collections.emptyList());
+
+ assertThat(columnList.getNames()).isEmpty();
+ assertThat(columnList.getDataTypes()).isEmpty();
+ }
+
+ @Test
+ void testToStringWithNamesOnly() {
+ final ColumnList columnList = ColumnList.of("a", "b", "c");
+
+ assertThat(columnList.toString()).isEqualTo("(`a`, `b`, `c`)");
+ }
+
+ @Test
+ void testToStringWithNamesAndDataTypes() {
+ final List<String> names = Arrays.asList("a", "b", "c");
+ final List<DataType> dataTypes =
+ Arrays.asList(DataTypes.INT(), DataTypes.STRING(), DataTypes.BOOLEAN());
+
+ final ColumnList columnList = ColumnList.of(names, dataTypes);
+
+ assertThat(columnList.toString()).isEqualTo("(`a` INT, `b` STRING, `c` BOOLEAN)");
+ }
+
+ @Test
+ void testEqualsAndHashCode() {
+ final List<String> names = Arrays.asList("a", "b");
+ final List<DataType> dataTypes = Arrays.asList(DataTypes.INT(), DataTypes.STRING());
+
+ final ColumnList columnList1 = ColumnList.of(names, dataTypes);
+ final ColumnList columnList2 = ColumnList.of(names, dataTypes);
+ final ColumnList columnList3 = ColumnList.of(Arrays.asList("a", "b"));
+
+ assertThat(columnList1).isEqualTo(columnList2);
+ assertThat(columnList1.hashCode()).isEqualTo(columnList2.hashCode());
+ assertThat(columnList1).isNotEqualTo(columnList3);
+ }
+
+ @Test
+ void testNullNamesThrowsException() {
+ assertThatThrownBy(() -> ColumnList.of(null, Collections.emptyList()))
+ .isInstanceOf(NullPointerException.class)
+ .hasMessageContaining("Names must not be null");
+ }
+
+ @Test
+ void testNullDataTypesThrowsException() {
+ assertThatThrownBy(() -> ColumnList.of(Arrays.asList("a"), null))
+ .isInstanceOf(NullPointerException.class)
+ .hasMessageContaining("Data types must not be null");
+ }
+
+ @Test
+ void testMismatchedDataTypesAndNamesThrowsException() {
+ final List<String> names = Arrays.asList("a", "b", "c");
+ final List<DataType> dataTypes = Arrays.asList(DataTypes.INT(), DataTypes.STRING());
+
+ assertThatThrownBy(() -> ColumnList.of(names, dataTypes))
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("Mismatch between data types and names");
+ }
+
+ @Test
+ void testNullElementInNamesThrowsException() {
+ final List<String> names = Arrays.asList("a", null, "c");
+
+ assertThatThrownBy(() -> ColumnList.of(names))
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("Names must not contain null elements");
+ }
+
+ @Test
+ void testNullElementInDataTypesThrowsException() {
+ final List<String> names = Arrays.asList("a", "b", "c");
+ final List<DataType> dataTypes = Arrays.asList(DataTypes.INT(), null, DataTypes.BOOLEAN());
+
+ assertThatThrownBy(() -> ColumnList.of(names, dataTypes))
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("Data types must not contain null elements");
+ }
+
+ @Test
+ void testImmutabilityOfNames() {
+ final List<String> names = new ArrayList<>(Arrays.asList("a", "b"));
+ final ColumnList columnList = ColumnList.of(names);
+
+ names.add("c");
+
+ assertThat(columnList.getNames()).containsExactly("a", "b");
+ }
+
+ @Test
+ void testImmutabilityOfDataTypes() {
+ final List<String> names = new ArrayList<>(Arrays.asList("a", "b"));
+ final List<DataType> dataTypes =
+ new ArrayList<>(Arrays.asList(DataTypes.INT(), DataTypes.STRING()));
Review Comment:
```suggestion
List.of(DataTypes.INT(), DataTypes.STRING()));
```
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39157][table-common] Add ColumnList.hashCode()/equals() [flink]
Posted by "twalthr (via GitHub)" <gi...@apache.org>.
twalthr commented on code in PR #27674:
URL: https://github.com/apache/flink/pull/27674#discussion_r2853446828
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/types/ColumnList.java:
##########
@@ -46,15 +47,20 @@ public final class ColumnList implements Serializable {
private final List<DataType> dataTypes;
private ColumnList(List<String> names, List<DataType> dataTypes) {
- this.names = Preconditions.checkNotNull(names, "Names must not be null.");
- this.dataTypes = Preconditions.checkNotNull(dataTypes, "Data types must be null.");
+ Preconditions.checkNotNull(names, "Names must not be null.");
Review Comment:
This is not a requirement for DESCRIPTOR as far as I know
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org