Copilot commented on code in PR #19012:
URL: https://github.com/apache/pinot/pull/19012#discussion_r3609656021


##########
pinot-common/src/main/java/org/apache/pinot/common/function/TransformFunctionType.java:
##########
@@ -317,6 +319,41 @@ private static RelDataType 
positionalReturnTypeInferenceFromStringLiteral(SqlOpe
     return opBinding.getTypeFactory().createSqlType(defaultSqlType);
   }
 
+  private static RelDataType 
jsonExtractScalarReturnTypeInference(SqlOperatorBinding opBinding) {
+    if (opBinding.getOperandCount() > 2 && opBinding.isOperandLiteral(2, 
false)) {
+      String resultsType = opBinding.getOperandLiteralValue(2, 
String.class).toUpperCase();
+      RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
+      switch (resultsType) {
+        case "JSON":
+          return typeFactory.createSqlType(SqlTypeName.VARCHAR);
+        case "BOOLEAN_ARRAY":
+          return 
typeFactory.createArrayType(typeFactory.createSqlType(SqlTypeName.BOOLEAN), -1);
+        case "TIMESTAMP_ARRAY":
+          return 
typeFactory.createArrayType(typeFactory.createSqlType(SqlTypeName.TIMESTAMP), 
-1);
+        default:
+          break;
+      }

Review Comment:
   `jsonExtractScalarReturnTypeInference()` currently doesn't handle 
`resultsType='BIG_DECIMAL_ARRAY'`. Because `inferTypeFromStringLiteral()` has 
no `BIG_DECIMAL_ARRAY` case, a query like `jsonExtractScalar*(..., 
'BIG_DECIMAL_ARRAY')` will throw `IllegalArgumentException("Invalid type: 
BIG_DECIMAL_ARRAY")` during planning, even though the transform implementation 
advertises `BIG_DECIMAL_ARRAY` support.



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