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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to