mihaibudiu commented on code in PR #4844:
URL: https://github.com/apache/calcite/pull/4844#discussion_r3076409987


##########
babel/src/test/java/org/apache/calcite/test/BabelParserTest.java:
##########
@@ -301,6 +306,101 @@ private void checkParseInfixCast(String sqlType) {
     sql(sql).ok(expected);
   }
 
+  @Test void testColonFieldAccessWithInfixCast() {
+    final SqlParserFixture f =
+        fixture().withConformance(new SqlAbstractConformance() {
+          @Override public boolean isColonFieldAccessAllowed() {
+            return true;
+          }
+        });
+
+    // Bracket after :: binds to the type, not as subscript on the cast result
+    sql("select v::varchar[1] from t")
+        .ok("SELECT `V` :: VARCHAR[1]\nFROM `T`");
+    f.sql("select v::varchar[1] from t")
+        .ok("SELECT `V` :: VARCHAR[1]\nFROM `T`");
+
+    // Explicit parentheses make no difference — bracket still binds to the 
type
+    sql("select (v::varchar)[1] from t")
+        .ok("SELECT `V` :: VARCHAR[1]\nFROM `T`");
+    f.sql("select (v::varchar)[1] from t")
+        .ok("SELECT `V` :: VARCHAR[1]\nFROM `T`");
+
+    // Array type with bracket
+    sql("select v::integer array[1] from t")
+        .ok("SELECT `V` :: INTEGER ARRAY[1]\nFROM `T`");
+    f.sql("select v::integer array[1] from t")
+        .ok("SELECT `V` :: INTEGER ARRAY[1]\nFROM `T`");
+
+    // Parenthesized array type with bracket
+    sql("select (v::integer array)[1] from t")
+        .ok("SELECT `V` :: INTEGER ARRAY[1]\nFROM `T`");
+    f.sql("select (v::integer array)[1] from t")
+        .ok("SELECT `V` :: INTEGER ARRAY[1]\nFROM `T`");
+
+    // Multiple brackets bind to the type
+    sql("select v::varchar[1][2] from t")
+        .ok("SELECT `V` :: VARCHAR[1][2]\nFROM `T`");

Review Comment:
   But `VARCHAR[1]` is not a type. What does this mean?



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