You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "davidradl (via GitHub)" <gi...@apache.org> on 2026/01/16 13:21:57 UTC
[PR] [FLINK-38913][table-planner] ArrayIndexOutOfBoundsException unparsing CAST. [flink]
davidradl opened a new pull request, #27431:
URL: https://github.com/apache/flink/pull/27431
## What is the purpose of the change
The table planner gets an ArrayIndexOutOfBoundsException while unparsing a CAST. The error occurs [here](https://github.com/apache/flink/blob/0261d498cb4538aefc4bb2f14ef08d0dec6db812/flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/type/ExtendedSqlRowTypeNameSpec.java#L124)
due to an empty comments list being passed [here](https://github.com/apache/flink/blob/a8544c44345282f6e1136beeeaa95f47d8ef93d6/flink-table/flink-table-planner/src/main/java/org/apache/calcite/sql/type/SqlTypeUtil.java#L1103)) )
Normally this code would have null elements for each field as per the [grammar](https://github.com/apache/flink/blob/4def6efb47ebc2dff46f444a3319d3c2ae02c3a6/flink-table/flink-sql-parser/src/main/codegen/includes/parserImpls.ftl#L2588)shows).
The change is to bounds check to ensure that there is a comments element before addressing it.
The rejected alternative is to fill the list with nulls in the caller for the failing case.
## Brief change log
- add bounds check to comments if in unparse.
## Verifying this change
Please make sure both new and modified tests in this PR follow [the conventions for tests defined in our code quality guide](https://flink.apache.org/how-to-contribute/code-style-and-quality-common/#7-testing).
This change added tests and can be verified as follows:
- added a unit test, this had to be in the table planner, as the parser unit tests added the commnets as per the grammar, so were not testing the fix.
- can be verified in the SQL client by issuing
"CREATE TABLE orders (
`const_requestBody_arrayOfObjectsOfObjects` AS ARRAY[ROW(ROW('I''m happy', CAST(NULL AS BOOLEAN))), ROW(CAST(NULL AS ROW<`string` STRING, `boolean` BOOLEAN>))]
) WITH (
'connector' = 'filesystem',
'path' = 'file:///Users/davidradley/bashscripts/sqlscripts/json/test_avro.json',
'format' = 'avro'
);"
Prior to the fix this get the ArrayIndexOutOfBoundsException
## 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)`: (no)
- 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)
--
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-38913][table-planner] ArrayIndexOutOfBoundsException unparsing CAST. [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #27431:
URL: https://github.com/apache/flink/pull/27431#discussion_r2708024607
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/calcite/SqlTypeUtilTest.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.planner.calcite;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlDataTypeSpec;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.pretty.SqlPrettyWriter;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.sql.type.SqlTypeUtil;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link SqlTypeUtil}. */
+class SqlTypeUtilTest {
+
+ @Test
+ void testConvertRowTypeToSpecAndUnparse() {
+ // Create a ROW type with 2 fields
+ FlinkTypeFactory typeFactory =
+ new FlinkTypeFactory(
+ Thread.currentThread().getContextClassLoader(), FlinkTypeSystem.INSTANCE);
+ RelDataType intType = typeFactory.createSqlType(SqlTypeName.INTEGER);
+ RelDataType varcharType = typeFactory.createSqlType(SqlTypeName.VARCHAR);
+
+ RelDataType rowType =
+ typeFactory.createStructType(
+ Arrays.asList(intType, varcharType), Arrays.asList("f0", "f1"));
+
Review Comment:
these lines could be replaced with
```java
RowType rowType = RowType.of(new LogicalType[]{new IntType(), new VarCharType(1)},
new String[]{"a", "b"});
RelDataType relDataType = LogicalRelDataTypeConverter.toRelDataType(rowType, typeFactory);
```
--
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-38913][table-planner] ArrayIndexOutOfBoundsException unparsing CAST. [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #27431:
URL: https://github.com/apache/flink/pull/27431#discussion_r2701088914
##########
flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/type/ExtendedSqlRowTypeNameSpec.java:
##########
@@ -121,7 +121,8 @@ public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
if (p.right.getNullable() != null && !p.right.getNullable()) {
writer.keyword("NOT NULL");
}
- if (comments.get(i) != null) {
+ // With bounds check - prevents IndexOutOfBoundsException
+ if (i < comments.size() && comments.get(i) != null) {
Review Comment:
is the logic correctly working if some fields is the middle without comments and fields in the beginning and end are with comments?
--
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-38913][table-planner] ArrayIndexOutOfBoundsException unparsing CAST. [flink]
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on PR #27431:
URL: https://github.com/apache/flink/pull/27431#issuecomment-3777596101
@flinkbot run azure
--
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-38913][table-planner] ArrayIndexOutOfBoundsException unparsing CAST. [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #27431:
URL: https://github.com/apache/flink/pull/27431#discussion_r2708037178
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/calcite/SqlTypeUtilTest.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.planner.calcite;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlDataTypeSpec;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.pretty.SqlPrettyWriter;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.sql.type.SqlTypeUtil;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link SqlTypeUtil}. */
+class SqlTypeUtilTest {
+
+ @Test
+ void testConvertRowTypeToSpecAndUnparse() {
+ // Create a ROW type with 2 fields
+ FlinkTypeFactory typeFactory =
+ new FlinkTypeFactory(
+ Thread.currentThread().getContextClassLoader(), FlinkTypeSystem.INSTANCE);
+ RelDataType intType = typeFactory.createSqlType(SqlTypeName.INTEGER);
+ RelDataType varcharType = typeFactory.createSqlType(SqlTypeName.VARCHAR);
+
+ RelDataType rowType =
+ typeFactory.createStructType(
+ Arrays.asList(intType, varcharType), Arrays.asList("f0", "f1"));
+
+ SqlDataTypeSpec typeSpec = SqlTypeUtil.convertTypeToSpec(rowType);
+
+ // Try to unparse - without the bounds check fix, this throws IndexOutOfBoundsException
Review Comment:
not sure we need this line since it doesn't give any clearance to reader outside of this PR
if you still want to have a list you can put a comment for the method something like
```java
/** Test case for <a href="https://issues.apache.org/jira/browse/FLINK-38913">[FLINK-38913]
ArrayIndexOutOfBoundsException when creating a table with computed rows including casts to null</a>. */
```
--
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-38913][table-planner] ArrayIndexOutOfBoundsException unparsing CAST. [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #27431:
URL: https://github.com/apache/flink/pull/27431#discussion_r2708024607
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/calcite/SqlTypeUtilTest.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.planner.calcite;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlDataTypeSpec;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.pretty.SqlPrettyWriter;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.sql.type.SqlTypeUtil;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link SqlTypeUtil}. */
+class SqlTypeUtilTest {
+
+ @Test
+ void testConvertRowTypeToSpecAndUnparse() {
+ // Create a ROW type with 2 fields
+ FlinkTypeFactory typeFactory =
+ new FlinkTypeFactory(
+ Thread.currentThread().getContextClassLoader(), FlinkTypeSystem.INSTANCE);
+ RelDataType intType = typeFactory.createSqlType(SqlTypeName.INTEGER);
+ RelDataType varcharType = typeFactory.createSqlType(SqlTypeName.VARCHAR);
+
+ RelDataType rowType =
+ typeFactory.createStructType(
+ Arrays.asList(intType, varcharType), Arrays.asList("f0", "f1"));
+
Review Comment:
these lines could be replaced with
```java
RelDataType rowType =
LogicalRelDataTypeConverter.toRelDataType(
RowType.of(
new LogicalType[] {new IntType(), new VarCharType(1)},
new String[] {"a", "b"}),
typeFactory);
```
--
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-38913][table-planner] ArrayIndexOutOfBoundsException unparsing CAST. [flink]
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #27431:
URL: https://github.com/apache/flink/pull/27431#issuecomment-3760026069
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "f4238f0597623a034861db0006501b043fe44408",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "f4238f0597623a034861db0006501b043fe44408",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* f4238f0597623a034861db0006501b043fe44408 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-38913][table-planner] ArrayIndexOutOfBoundsException unparsing CAST. [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #27431:
URL: https://github.com/apache/flink/pull/27431#discussion_r2708024607
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/calcite/SqlTypeUtilTest.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.planner.calcite;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlDataTypeSpec;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.pretty.SqlPrettyWriter;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.sql.type.SqlTypeUtil;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link SqlTypeUtil}. */
+class SqlTypeUtilTest {
+
+ @Test
+ void testConvertRowTypeToSpecAndUnparse() {
+ // Create a ROW type with 2 fields
+ FlinkTypeFactory typeFactory =
+ new FlinkTypeFactory(
+ Thread.currentThread().getContextClassLoader(), FlinkTypeSystem.INSTANCE);
+ RelDataType intType = typeFactory.createSqlType(SqlTypeName.INTEGER);
+ RelDataType varcharType = typeFactory.createSqlType(SqlTypeName.VARCHAR);
+
+ RelDataType rowType =
+ typeFactory.createStructType(
+ Arrays.asList(intType, varcharType), Arrays.asList("f0", "f1"));
+
Review Comment:
these lines could be replaced with
```java
RowType rowType = RowType.of( LogicalType[] {new IntType(), new VarCharType(1)},
new String[] {"a", "b"});
RelDataType rowType = LogicalRelDataTypeConverter.toRelDataType(rowType, typeFactory);
```
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/calcite/SqlTypeUtilTest.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.planner.calcite;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlDataTypeSpec;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.pretty.SqlPrettyWriter;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.sql.type.SqlTypeUtil;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link SqlTypeUtil}. */
+class SqlTypeUtilTest {
+
+ @Test
+ void testConvertRowTypeToSpecAndUnparse() {
+ // Create a ROW type with 2 fields
+ FlinkTypeFactory typeFactory =
+ new FlinkTypeFactory(
+ Thread.currentThread().getContextClassLoader(), FlinkTypeSystem.INSTANCE);
+ RelDataType intType = typeFactory.createSqlType(SqlTypeName.INTEGER);
+ RelDataType varcharType = typeFactory.createSqlType(SqlTypeName.VARCHAR);
+
+ RelDataType rowType =
+ typeFactory.createStructType(
+ Arrays.asList(intType, varcharType), Arrays.asList("f0", "f1"));
+
Review Comment:
these lines could be replaced with
```java
RowType rowType = RowType.of(LogicalType[] {new IntType(), new VarCharType(1)},
new String[] {"a", "b"});
RelDataType rowType = LogicalRelDataTypeConverter.toRelDataType(rowType, typeFactory);
```
--
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-38913][table-planner] ArrayIndexOutOfBoundsException unparsing CAST. [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #27431:
URL: https://github.com/apache/flink/pull/27431#discussion_r2708028486
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/calcite/SqlTypeUtilTest.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.planner.calcite;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlDataTypeSpec;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.pretty.SqlPrettyWriter;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.sql.type.SqlTypeUtil;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link SqlTypeUtil}. */
+class SqlTypeUtilTest {
+
+ @Test
+ void testConvertRowTypeToSpecAndUnparse() {
+ // Create a ROW type with 2 fields
+ FlinkTypeFactory typeFactory =
+ new FlinkTypeFactory(
+ Thread.currentThread().getContextClassLoader(), FlinkTypeSystem.INSTANCE);
+ RelDataType intType = typeFactory.createSqlType(SqlTypeName.INTEGER);
+ RelDataType varcharType = typeFactory.createSqlType(SqlTypeName.VARCHAR);
+
+ RelDataType rowType =
+ typeFactory.createStructType(
+ Arrays.asList(intType, varcharType), Arrays.asList("f0", "f1"));
+
+ SqlDataTypeSpec typeSpec = SqlTypeUtil.convertTypeToSpec(rowType);
+
+ // Try to unparse - without the bounds check fix, this throws IndexOutOfBoundsException
+ SqlWriter writer =
+ new SqlPrettyWriter(
+ SqlPrettyWriter.config()
+ .withAlwaysUseParentheses(false)
+ .withSelectListItemsOnSeparateLines(false)
+ .withIndentation(0));
+ // unparse that will end up passing no comments through
+ typeSpec.unparse(writer, 0, 0);
+ String result = writer.toSqlString().getSql();
+ assertThat(result).contains("ROW").contains("f0").contains("f1");
Review Comment:
```suggestion
assertThat(result)
.hasToString("ROW(\"a\" INTEGER, \"b\" VARCHAR(1) CHARACTER SET \"UTF-16LE\")");
```
can we instead compare the whole line?
--
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-38913][table-planner] ArrayIndexOutOfBoundsException unparsing CAST. [flink]
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on PR #27431:
URL: https://github.com/apache/flink/pull/27431#issuecomment-3778210591
@flinkbot run azure
--
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-38913][table-planner] ArrayIndexOutOfBoundsException unparsing CAST. [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #27431:
URL: https://github.com/apache/flink/pull/27431#discussion_r2701089719
##########
flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/type/ExtendedSqlRowTypeNameSpec.java:
##########
@@ -121,7 +121,8 @@ public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
if (p.right.getNullable() != null && !p.right.getNullable()) {
writer.keyword("NOT NULL");
}
- if (comments.get(i) != null) {
+ // With bounds check - prevents IndexOutOfBoundsException
+ if (i < comments.size() && comments.get(i) != null) {
Review Comment:
probably also need a test for that
--
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-38913][table-planner] ArrayIndexOutOfBoundsException unparsing CAST. [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #27431:
URL: https://github.com/apache/flink/pull/27431#discussion_r2708024607
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/calcite/SqlTypeUtilTest.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.planner.calcite;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlDataTypeSpec;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.pretty.SqlPrettyWriter;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.sql.type.SqlTypeUtil;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link SqlTypeUtil}. */
+class SqlTypeUtilTest {
+
+ @Test
+ void testConvertRowTypeToSpecAndUnparse() {
+ // Create a ROW type with 2 fields
+ FlinkTypeFactory typeFactory =
+ new FlinkTypeFactory(
+ Thread.currentThread().getContextClassLoader(), FlinkTypeSystem.INSTANCE);
+ RelDataType intType = typeFactory.createSqlType(SqlTypeName.INTEGER);
+ RelDataType varcharType = typeFactory.createSqlType(SqlTypeName.VARCHAR);
+
+ RelDataType rowType =
+ typeFactory.createStructType(
+ Arrays.asList(intType, varcharType), Arrays.asList("f0", "f1"));
+
Review Comment:
these lines could be replaced with
```java
RowType rowType = RowType.of(LogicalType[] {new IntType(), new VarCharType(1)},
new String[] {"a", "b"});
RelDataType relDataType = LogicalRelDataTypeConverter.toRelDataType(rowType, typeFactory);
```
--
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-38913][table-planner] ArrayIndexOutOfBoundsException unparsing CAST. [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #27431:
URL: https://github.com/apache/flink/pull/27431#discussion_r2705571671
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/calcite/SqlTypeUtilTest.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.planner.calcite;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlDataTypeSpec;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.pretty.SqlPrettyWriter;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.sql.type.SqlTypeUtil;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link SqlTypeUtil}. */
+class SqlTypeUtilTest {
Review Comment:
I disagree here.
I submitted a PR to your branch with example of such test in parser
https://github.com/davidradl/flink/pull/4
--
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-38913][table-planner] ArrayIndexOutOfBoundsException unparsing CAST. [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on PR #27431:
URL: https://github.com/apache/flink/pull/27431#issuecomment-3780351617
commits in this PR were containing merge commit which shouldn't be present before merge
so I rebased the whole PR to avoid it
--
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-38913][table-planner] ArrayIndexOutOfBoundsException unparsing CAST. [flink]
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #27431:
URL: https://github.com/apache/flink/pull/27431#discussion_r2707802829
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/calcite/SqlTypeUtilTest.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.planner.calcite;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlDataTypeSpec;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.pretty.SqlPrettyWriter;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.sql.type.SqlTypeUtil;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link SqlTypeUtil}. */
+class SqlTypeUtilTest {
Review Comment:
@snuyanzin thanks,I will have a look.
--
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-38913][table-planner] ArrayIndexOutOfBoundsException unparsing CAST. [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on PR #27431:
URL: https://github.com/apache/flink/pull/27431#issuecomment-3781686408
Thanks for your contribution @davidradl
feel free to create a backport PR
--
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-38913][table-planner] ArrayIndexOutOfBoundsException unparsing CAST. [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin merged PR #27431:
URL: https://github.com/apache/flink/pull/27431
--
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-38913][table-planner] ArrayIndexOutOfBoundsException unparsing CAST. [flink]
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #27431:
URL: https://github.com/apache/flink/pull/27431#discussion_r2705201878
##########
flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/type/ExtendedSqlRowTypeNameSpec.java:
##########
@@ -121,7 +121,8 @@ public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
if (p.right.getNullable() != null && !p.right.getNullable()) {
writer.keyword("NOT NULL");
}
- if (comments.get(i) != null) {
+ // With bounds check - prevents IndexOutOfBoundsException
+ if (i < comments.size() && comments.get(i) != null) {
Review Comment:
It should be fine, each field will have a null comment or a value as per the grammar. This case is when there is a CAST and an empty comments list is sent through in the constructor of this class, as I assume that in the CAST case we do not support comments. The permutations of comments tests you are suggesting already are covered in `SqlDdlToOperationConverterTest` (if you search for `.withComment `in this file you will see the column comment test permutations).
Happy to make any amendments, if I have missed something in my understanding.
--
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-38913][table-planner] ArrayIndexOutOfBoundsException unparsing CAST. [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #27431:
URL: https://github.com/apache/flink/pull/27431#discussion_r2701085580
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/calcite/SqlTypeUtilTest.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.planner.calcite;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlDataTypeSpec;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.pretty.SqlPrettyWriter;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.sql.type.SqlTypeUtil;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link SqlTypeUtil}. */
+class SqlTypeUtilTest {
Review Comment:
if the issue is fixed in parser, can we have tests in parser?
--
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-38913][table-planner] ArrayIndexOutOfBoundsException unparsing CAST. [flink]
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #27431:
URL: https://github.com/apache/flink/pull/27431#discussion_r2707855111
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/calcite/SqlTypeUtilTest.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.planner.calcite;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlDataTypeSpec;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.pretty.SqlPrettyWriter;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.sql.type.SqlTypeUtil;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link SqlTypeUtil}. */
+class SqlTypeUtilTest {
Review Comment:
Thank you very much @snuyanzin - yes this does drive the code. I tested it drives the error prior to the fix. I have merged your test. I suggest leaving the planner test in.
--
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-38913][table-planner] ArrayIndexOutOfBoundsException unparsing CAST. [flink]
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #27431:
URL: https://github.com/apache/flink/pull/27431#discussion_r2708964201
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/calcite/SqlTypeUtilTest.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.planner.calcite;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlDataTypeSpec;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.pretty.SqlPrettyWriter;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.sql.type.SqlTypeUtil;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link SqlTypeUtil}. */
+class SqlTypeUtilTest {
+
+ @Test
+ void testConvertRowTypeToSpecAndUnparse() {
+ // Create a ROW type with 2 fields
+ FlinkTypeFactory typeFactory =
+ new FlinkTypeFactory(
+ Thread.currentThread().getContextClassLoader(), FlinkTypeSystem.INSTANCE);
+ RelDataType intType = typeFactory.createSqlType(SqlTypeName.INTEGER);
+ RelDataType varcharType = typeFactory.createSqlType(SqlTypeName.VARCHAR);
+
+ RelDataType rowType =
+ typeFactory.createStructType(
+ Arrays.asList(intType, varcharType), Arrays.asList("f0", "f1"));
+
+ SqlDataTypeSpec typeSpec = SqlTypeUtil.convertTypeToSpec(rowType);
+
+ // Try to unparse - without the bounds check fix, this throws IndexOutOfBoundsException
Review Comment:
ok - that is better - thanks.
--
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-38913][table-planner] ArrayIndexOutOfBoundsException unparsing CAST. [flink]
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #27431:
URL: https://github.com/apache/flink/pull/27431#discussion_r2705208481
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/calcite/SqlTypeUtilTest.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.planner.calcite;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlDataTypeSpec;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.pretty.SqlPrettyWriter;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.sql.type.SqlTypeUtil;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link SqlTypeUtil}. */
+class SqlTypeUtilTest {
Review Comment:
I tried this, but the parser tests always honorred the grammar and populated the comments with null elements. The only way I could get tests to pass through an empty comments list was from the planner test.
--
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-38913][table-planner] ArrayIndexOutOfBoundsException unparsing CAST. [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #27431:
URL: https://github.com/apache/flink/pull/27431#discussion_r2708037178
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/calcite/SqlTypeUtilTest.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.planner.calcite;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlDataTypeSpec;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.pretty.SqlPrettyWriter;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.sql.type.SqlTypeUtil;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link SqlTypeUtil}. */
+class SqlTypeUtilTest {
+
+ @Test
+ void testConvertRowTypeToSpecAndUnparse() {
+ // Create a ROW type with 2 fields
+ FlinkTypeFactory typeFactory =
+ new FlinkTypeFactory(
+ Thread.currentThread().getContextClassLoader(), FlinkTypeSystem.INSTANCE);
+ RelDataType intType = typeFactory.createSqlType(SqlTypeName.INTEGER);
+ RelDataType varcharType = typeFactory.createSqlType(SqlTypeName.VARCHAR);
+
+ RelDataType rowType =
+ typeFactory.createStructType(
+ Arrays.asList(intType, varcharType), Arrays.asList("f0", "f1"));
+
+ SqlDataTypeSpec typeSpec = SqlTypeUtil.convertTypeToSpec(rowType);
+
+ // Try to unparse - without the bounds check fix, this throws IndexOutOfBoundsException
Review Comment:
not sure we need this line since it doesn't give any clearance to reader outside of this PR
if you still want to have a link you can put a comment for the method something like
```java
/** Test case for <a href="https://issues.apache.org/jira/browse/FLINK-38913">[FLINK-38913]
ArrayIndexOutOfBoundsException when creating a table with computed rows including casts to null</a>. */
```
--
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