FrankChen021 commented on code in PR #20702:
URL: https://github.com/apache/druid/pull/20702#discussion_r4367302957


##########
sql/src/main/codegen/includes/common.ftl:
##########
@@ -106,6 +106,32 @@ SqlTypeNameSpec DruidType() :
   }
 }
 
+// Parses the PostgreSQL-style infix cast operator (e.g. x::BIGINT).
+void InfixCast(List<Object> list, ExprContext exprContext, Span s) :
+{
+  final SqlDataTypeSpec dt;
+}
+{
+  <INFIX_CAST>
+  {
+    checkNonQueryExpression(exprContext);
+    list.add(new SqlParserUtil.ToTreeListItem(SqlLibraryOperators.INFIX_CAST, 
getPos()));
+  }
+  (
+    // Accept LONG as an alias for BIGINT, matching CAST(x AS LONG).
+    LOOKAHEAD(2)
+    <LONG>
+    {
+      dt = new SqlDataTypeSpec(new SqlBasicTypeNameSpec(SqlTypeName.BIGINT, 
getPos()), getPos());
+    }
+  |
+    dt = DataType()

Review Comment:
   [P2] Infix casts cannot target interval types
   
   **Finding:** InfixCast only accepts LONG or DataType(), while the existing 
CAST production has a separate INTERVAL/IntervalQualifier() branch. Therefore 
valid syntax such as CAST(x AS INTERVAL DAY) has no equivalent x::INTERVAL DAY 
form and fails during parsing.
   
   **Suggestion:** Mirror the existing interval qualifier branch in InfixCast 
and add a regression 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: [email protected]

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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to