Jackie-Jiang commented on code in PR #19586:
URL: https://github.com/apache/pinot/pull/19586#discussion_r4252706906


##########
pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/ArrayLiteralTransformFunction.java:
##########
@@ -134,86 +222,226 @@ public 
ArrayLiteralTransformFunction(List<ExpressionContext> literalContexts) {
       _longArrayLiteral = new long[0];
       _floatArrayLiteral = new float[0];
       _doubleArrayLiteral = new double[0];
+      _bigDecimalArrayLiteral = new BigDecimal[0];
       _stringArrayLiteral = new String[0];
       _bytesArrayLiteral = new byte[0][];
       return;
     }
+    List<LiteralContext> contexts = new ArrayList<>(literalContexts.size());
     for (ExpressionContext literalContext : literalContexts) {
-      Preconditions.checkState(literalContext.getType() == 
ExpressionContext.Type.LITERAL,
-          "ArrayLiteralTransformFunction only takes literals as arguments, 
found: %s", literalContext);
+      contexts.add(toLiteralContext(literalContext));
     }
-    _dataType = literalContexts.get(0).getLiteral().getType();
+    _dataType = contexts.get(0).getType();
     switch (_dataType) {
       case INT:
-        _intArrayLiteral = new int[literalContexts.size()];
+        _intArrayLiteral = new int[contexts.size()];
         for (int i = 0; i < _intArrayLiteral.length; i++) {
-          _intArrayLiteral[i] = 
literalContexts.get(i).getLiteral().getIntValue();
+          _intArrayLiteral[i] = contexts.get(i).getIntValue();
         }
         _longArrayLiteral = null;
         _floatArrayLiteral = null;
         _doubleArrayLiteral = null;
+        _bigDecimalArrayLiteral = null;
         _stringArrayLiteral = null;
         _bytesArrayLiteral = null;
         break;
       case LONG:
-        _longArrayLiteral = new long[literalContexts.size()];
+        _longArrayLiteral = new long[contexts.size()];
         for (int i = 0; i < _longArrayLiteral.length; i++) {
-          _longArrayLiteral[i] = 
literalContexts.get(i).getLiteral().getLongValue();
+          _longArrayLiteral[i] = contexts.get(i).getLongValue();
         }
         _intArrayLiteral = null;
         _floatArrayLiteral = null;
         _doubleArrayLiteral = null;
+        _bigDecimalArrayLiteral = null;
         _stringArrayLiteral = null;
         _bytesArrayLiteral = null;
         break;
       case FLOAT:
-        _floatArrayLiteral = new float[literalContexts.size()];
+        _floatArrayLiteral = new float[contexts.size()];
         for (int i = 0; i < _floatArrayLiteral.length; i++) {
-          _floatArrayLiteral[i] = 
literalContexts.get(i).getLiteral().getFloatValue();
+          _floatArrayLiteral[i] = contexts.get(i).getFloatValue();
         }
         _intArrayLiteral = null;
         _longArrayLiteral = null;
         _doubleArrayLiteral = null;
+        _bigDecimalArrayLiteral = null;
         _stringArrayLiteral = null;
         _bytesArrayLiteral = null;
         break;
       case DOUBLE:
-        _doubleArrayLiteral = new double[literalContexts.size()];
+        _doubleArrayLiteral = new double[contexts.size()];
         for (int i = 0; i < _doubleArrayLiteral.length; i++) {
-          _doubleArrayLiteral[i] = 
literalContexts.get(i).getLiteral().getDoubleValue();
+          _doubleArrayLiteral[i] = contexts.get(i).getDoubleValue();
         }
         _intArrayLiteral = null;
         _longArrayLiteral = null;
         _floatArrayLiteral = null;
+        _bigDecimalArrayLiteral = null;
+        _stringArrayLiteral = null;
+        _bytesArrayLiteral = null;
+        break;
+      case BIG_DECIMAL:
+        _bigDecimalArrayLiteral = new BigDecimal[contexts.size()];
+        for (int i = 0; i < _bigDecimalArrayLiteral.length; i++) {
+          _bigDecimalArrayLiteral[i] = contexts.get(i).getBigDecimalValue();
+        }
+        _intArrayLiteral = null;
+        _longArrayLiteral = null;
+        _floatArrayLiteral = null;
+        _doubleArrayLiteral = null;
+        _stringArrayLiteral = null;
+        _bytesArrayLiteral = null;
+        break;
+      case BOOLEAN:
+        _intArrayLiteral = new int[contexts.size()];
+        for (int i = 0; i < _intArrayLiteral.length; i++) {
+          _intArrayLiteral[i] = contexts.get(i).getBooleanValue() ? 1 : 0;
+        }
+        _longArrayLiteral = null;
+        _floatArrayLiteral = null;
+        _doubleArrayLiteral = null;
+        _bigDecimalArrayLiteral = null;
+        _stringArrayLiteral = null;
+        _bytesArrayLiteral = null;
+        break;
+      case TIMESTAMP:
+        _longArrayLiteral = new long[contexts.size()];
+        for (int i = 0; i < _longArrayLiteral.length; i++) {
+          _longArrayLiteral[i] = contexts.get(i).getLongValue();
+        }
+        _intArrayLiteral = null;
+        _floatArrayLiteral = null;
+        _doubleArrayLiteral = null;
+        _bigDecimalArrayLiteral = null;
         _stringArrayLiteral = null;
         _bytesArrayLiteral = null;
         break;
       case STRING:
-        _stringArrayLiteral = new String[literalContexts.size()];
+        _stringArrayLiteral = new String[contexts.size()];
         for (int i = 0; i < _stringArrayLiteral.length; i++) {
-          _stringArrayLiteral[i] = 
literalContexts.get(i).getLiteral().getStringValue();
+          _stringArrayLiteral[i] = contexts.get(i).getStringValue();
         }
         _intArrayLiteral = null;
         _longArrayLiteral = null;
         _floatArrayLiteral = null;
         _doubleArrayLiteral = null;
+        _bigDecimalArrayLiteral = null;
         _bytesArrayLiteral = null;
         break;
       case BYTES:
-        _bytesArrayLiteral = new byte[literalContexts.size()][];
+      case UUID:
+        _bytesArrayLiteral = new byte[contexts.size()][];
         for (int i = 0; i < _bytesArrayLiteral.length; i++) {
-          _bytesArrayLiteral[i] = 
literalContexts.get(i).getLiteral().getBytesValue();
+          _bytesArrayLiteral[i] = contexts.get(i).getBytesValue();
         }
         _intArrayLiteral = null;
         _longArrayLiteral = null;
         _floatArrayLiteral = null;
         _doubleArrayLiteral = null;
+        _bigDecimalArrayLiteral = null;
         _stringArrayLiteral = null;
         break;
       default:
         throw new IllegalStateException(
             "Illegal data type for ArrayLiteralTransformFunction: " + 
_dataType + ", literal contexts: "
-                + Arrays.toString(literalContexts.toArray()));
+                + Arrays.toString(contexts.toArray()));
+    }
+  }
+
+  private static LiteralContext toLiteralContext(ExpressionContext context) {
+    if (context.getType() == ExpressionContext.Type.LITERAL) {
+      return context.getLiteral();
+    }
+    if (context.getType() == ExpressionContext.Type.FUNCTION) {
+      FunctionContext function = context.getFunction();
+      if (function.getFunctionName().equalsIgnoreCase("cast")) {
+        List<ExpressionContext> arguments = function.getArguments();
+        Preconditions.checkArgument(arguments.size() == 2,
+            "CAST function inside array literal constructor expects 2 
arguments, got: %s", arguments.size());
+        LiteralContext sourceLiteral = toLiteralContext(arguments.get(0));
+        ExpressionContext targetTypeExpr = arguments.get(1);
+        Preconditions.checkArgument(targetTypeExpr.getType() == 
ExpressionContext.Type.LITERAL,
+            "CAST target type must be a literal string, got: %s", 
targetTypeExpr);
+        String targetType = 
targetTypeExpr.getLiteral().getStringValue().toUpperCase();
+        return castLiteralContext(sourceLiteral, targetType);
+      }
+    }
+    throw new IllegalStateException(
+        "ArrayLiteralTransformFunction only takes literals or cast functions 
as arguments, found: " + context);
+  }
+
+  private static LiteralContext castLiteralContext(LiteralContext source, 
String targetType) {
+    switch (targetType) {
+      case "TIMESTAMP":
+        if (source.isNull()) {
+          return new LiteralContext(DataType.TIMESTAMP, null);
+        }
+        if (source.getType() == DataType.TIMESTAMP) {
+          return source;
+        }
+        if (source.getType() == DataType.STRING) {
+          return new LiteralContext(DataType.TIMESTAMP, 
TimestampUtils.toTimestamp(source.getStringValue()));

Review Comment:
   MAJOR: The new array-specific CAST path loses the normal string trimming 
behavior. For example, `ARRAY[CAST(' 1577865600000 ' AS TIMESTAMP)]` now 
throws, as does `ARRAY[CAST(' 550e8400-e29b-41d4-a716-446655440000 ' AS UUID)]` 
through the UUID branch below. Both queries were previously accepted because 
the normal CAST conversion trims these inputs. Please reuse the existing 
conversion behavior or trim in both branches, and cover these cases in 
regression tests.



##########
pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/ArrayLiteralTransformFunction.java:
##########
@@ -134,86 +222,226 @@ public 
ArrayLiteralTransformFunction(List<ExpressionContext> literalContexts) {
       _longArrayLiteral = new long[0];
       _floatArrayLiteral = new float[0];
       _doubleArrayLiteral = new double[0];
+      _bigDecimalArrayLiteral = new BigDecimal[0];
       _stringArrayLiteral = new String[0];
       _bytesArrayLiteral = new byte[0][];
       return;
     }
+    List<LiteralContext> contexts = new ArrayList<>(literalContexts.size());
     for (ExpressionContext literalContext : literalContexts) {
-      Preconditions.checkState(literalContext.getType() == 
ExpressionContext.Type.LITERAL,
-          "ArrayLiteralTransformFunction only takes literals as arguments, 
found: %s", literalContext);
+      contexts.add(toLiteralContext(literalContext));
     }
-    _dataType = literalContexts.get(0).getLiteral().getType();
+    _dataType = contexts.get(0).getType();
     switch (_dataType) {
       case INT:
-        _intArrayLiteral = new int[literalContexts.size()];
+        _intArrayLiteral = new int[contexts.size()];
         for (int i = 0; i < _intArrayLiteral.length; i++) {
-          _intArrayLiteral[i] = 
literalContexts.get(i).getLiteral().getIntValue();
+          _intArrayLiteral[i] = contexts.get(i).getIntValue();
         }
         _longArrayLiteral = null;
         _floatArrayLiteral = null;
         _doubleArrayLiteral = null;
+        _bigDecimalArrayLiteral = null;
         _stringArrayLiteral = null;
         _bytesArrayLiteral = null;
         break;
       case LONG:
-        _longArrayLiteral = new long[literalContexts.size()];
+        _longArrayLiteral = new long[contexts.size()];
         for (int i = 0; i < _longArrayLiteral.length; i++) {
-          _longArrayLiteral[i] = 
literalContexts.get(i).getLiteral().getLongValue();
+          _longArrayLiteral[i] = contexts.get(i).getLongValue();
         }
         _intArrayLiteral = null;
         _floatArrayLiteral = null;
         _doubleArrayLiteral = null;
+        _bigDecimalArrayLiteral = null;
         _stringArrayLiteral = null;
         _bytesArrayLiteral = null;
         break;
       case FLOAT:
-        _floatArrayLiteral = new float[literalContexts.size()];
+        _floatArrayLiteral = new float[contexts.size()];
         for (int i = 0; i < _floatArrayLiteral.length; i++) {
-          _floatArrayLiteral[i] = 
literalContexts.get(i).getLiteral().getFloatValue();
+          _floatArrayLiteral[i] = contexts.get(i).getFloatValue();
         }
         _intArrayLiteral = null;
         _longArrayLiteral = null;
         _doubleArrayLiteral = null;
+        _bigDecimalArrayLiteral = null;
         _stringArrayLiteral = null;
         _bytesArrayLiteral = null;
         break;
       case DOUBLE:
-        _doubleArrayLiteral = new double[literalContexts.size()];
+        _doubleArrayLiteral = new double[contexts.size()];
         for (int i = 0; i < _doubleArrayLiteral.length; i++) {
-          _doubleArrayLiteral[i] = 
literalContexts.get(i).getLiteral().getDoubleValue();
+          _doubleArrayLiteral[i] = contexts.get(i).getDoubleValue();
         }
         _intArrayLiteral = null;
         _longArrayLiteral = null;
         _floatArrayLiteral = null;
+        _bigDecimalArrayLiteral = null;
+        _stringArrayLiteral = null;
+        _bytesArrayLiteral = null;
+        break;
+      case BIG_DECIMAL:
+        _bigDecimalArrayLiteral = new BigDecimal[contexts.size()];
+        for (int i = 0; i < _bigDecimalArrayLiteral.length; i++) {
+          _bigDecimalArrayLiteral[i] = contexts.get(i).getBigDecimalValue();
+        }
+        _intArrayLiteral = null;
+        _longArrayLiteral = null;
+        _floatArrayLiteral = null;
+        _doubleArrayLiteral = null;
+        _stringArrayLiteral = null;
+        _bytesArrayLiteral = null;
+        break;
+      case BOOLEAN:
+        _intArrayLiteral = new int[contexts.size()];
+        for (int i = 0; i < _intArrayLiteral.length; i++) {
+          _intArrayLiteral[i] = contexts.get(i).getBooleanValue() ? 1 : 0;
+        }
+        _longArrayLiteral = null;
+        _floatArrayLiteral = null;
+        _doubleArrayLiteral = null;
+        _bigDecimalArrayLiteral = null;
+        _stringArrayLiteral = null;
+        _bytesArrayLiteral = null;
+        break;
+      case TIMESTAMP:
+        _longArrayLiteral = new long[contexts.size()];
+        for (int i = 0; i < _longArrayLiteral.length; i++) {
+          _longArrayLiteral[i] = contexts.get(i).getLongValue();
+        }
+        _intArrayLiteral = null;
+        _floatArrayLiteral = null;
+        _doubleArrayLiteral = null;
+        _bigDecimalArrayLiteral = null;
         _stringArrayLiteral = null;
         _bytesArrayLiteral = null;
         break;
       case STRING:
-        _stringArrayLiteral = new String[literalContexts.size()];
+        _stringArrayLiteral = new String[contexts.size()];
         for (int i = 0; i < _stringArrayLiteral.length; i++) {
-          _stringArrayLiteral[i] = 
literalContexts.get(i).getLiteral().getStringValue();
+          _stringArrayLiteral[i] = contexts.get(i).getStringValue();
         }
         _intArrayLiteral = null;
         _longArrayLiteral = null;
         _floatArrayLiteral = null;
         _doubleArrayLiteral = null;
+        _bigDecimalArrayLiteral = null;
         _bytesArrayLiteral = null;
         break;
       case BYTES:
-        _bytesArrayLiteral = new byte[literalContexts.size()][];
+      case UUID:
+        _bytesArrayLiteral = new byte[contexts.size()][];
         for (int i = 0; i < _bytesArrayLiteral.length; i++) {
-          _bytesArrayLiteral[i] = 
literalContexts.get(i).getLiteral().getBytesValue();
+          _bytesArrayLiteral[i] = contexts.get(i).getBytesValue();
         }
         _intArrayLiteral = null;
         _longArrayLiteral = null;
         _floatArrayLiteral = null;
         _doubleArrayLiteral = null;
+        _bigDecimalArrayLiteral = null;
         _stringArrayLiteral = null;
         break;
       default:
         throw new IllegalStateException(
             "Illegal data type for ArrayLiteralTransformFunction: " + 
_dataType + ", literal contexts: "
-                + Arrays.toString(literalContexts.toArray()));
+                + Arrays.toString(contexts.toArray()));
+    }
+  }
+
+  private static LiteralContext toLiteralContext(ExpressionContext context) {
+    if (context.getType() == ExpressionContext.Type.LITERAL) {
+      return context.getLiteral();
+    }
+    if (context.getType() == ExpressionContext.Type.FUNCTION) {
+      FunctionContext function = context.getFunction();
+      if (function.getFunctionName().equalsIgnoreCase("cast")) {
+        List<ExpressionContext> arguments = function.getArguments();
+        Preconditions.checkArgument(arguments.size() == 2,
+            "CAST function inside array literal constructor expects 2 
arguments, got: %s", arguments.size());
+        LiteralContext sourceLiteral = toLiteralContext(arguments.get(0));
+        ExpressionContext targetTypeExpr = arguments.get(1);
+        Preconditions.checkArgument(targetTypeExpr.getType() == 
ExpressionContext.Type.LITERAL,
+            "CAST target type must be a literal string, got: %s", 
targetTypeExpr);
+        String targetType = 
targetTypeExpr.getLiteral().getStringValue().toUpperCase();
+        return castLiteralContext(sourceLiteral, targetType);
+      }
+    }
+    throw new IllegalStateException(
+        "ArrayLiteralTransformFunction only takes literals or cast functions 
as arguments, found: " + context);
+  }
+
+  private static LiteralContext castLiteralContext(LiteralContext source, 
String targetType) {
+    switch (targetType) {
+      case "TIMESTAMP":
+        if (source.isNull()) {
+          return new LiteralContext(DataType.TIMESTAMP, null);

Review Comment:
   CRITICAL: `ARRAY[CAST(NULL AS TIMESTAMP)]` now produces a TIMESTAMP_ARRAY 
containing `0` with no null marker. This typed-null context reaches 
`getLongValue()` in the array constructor, which substitutes the null 
placeholder, so the result contains Unix epoch instead of a null element. The 
query was previously rejected. Please reject null array elements or preserve 
their null state, and add a regression test.



##########
pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/ArrayLiteralTransformFunction.java:
##########
@@ -134,86 +222,226 @@ public 
ArrayLiteralTransformFunction(List<ExpressionContext> literalContexts) {
       _longArrayLiteral = new long[0];
       _floatArrayLiteral = new float[0];
       _doubleArrayLiteral = new double[0];
+      _bigDecimalArrayLiteral = new BigDecimal[0];
       _stringArrayLiteral = new String[0];
       _bytesArrayLiteral = new byte[0][];
       return;
     }
+    List<LiteralContext> contexts = new ArrayList<>(literalContexts.size());
     for (ExpressionContext literalContext : literalContexts) {
-      Preconditions.checkState(literalContext.getType() == 
ExpressionContext.Type.LITERAL,
-          "ArrayLiteralTransformFunction only takes literals as arguments, 
found: %s", literalContext);
+      contexts.add(toLiteralContext(literalContext));
     }
-    _dataType = literalContexts.get(0).getLiteral().getType();
+    _dataType = contexts.get(0).getType();
     switch (_dataType) {
       case INT:
-        _intArrayLiteral = new int[literalContexts.size()];
+        _intArrayLiteral = new int[contexts.size()];
         for (int i = 0; i < _intArrayLiteral.length; i++) {
-          _intArrayLiteral[i] = 
literalContexts.get(i).getLiteral().getIntValue();
+          _intArrayLiteral[i] = contexts.get(i).getIntValue();
         }
         _longArrayLiteral = null;
         _floatArrayLiteral = null;
         _doubleArrayLiteral = null;
+        _bigDecimalArrayLiteral = null;
         _stringArrayLiteral = null;
         _bytesArrayLiteral = null;
         break;
       case LONG:
-        _longArrayLiteral = new long[literalContexts.size()];
+        _longArrayLiteral = new long[contexts.size()];
         for (int i = 0; i < _longArrayLiteral.length; i++) {
-          _longArrayLiteral[i] = 
literalContexts.get(i).getLiteral().getLongValue();
+          _longArrayLiteral[i] = contexts.get(i).getLongValue();
         }
         _intArrayLiteral = null;
         _floatArrayLiteral = null;
         _doubleArrayLiteral = null;
+        _bigDecimalArrayLiteral = null;
         _stringArrayLiteral = null;
         _bytesArrayLiteral = null;
         break;
       case FLOAT:
-        _floatArrayLiteral = new float[literalContexts.size()];
+        _floatArrayLiteral = new float[contexts.size()];
         for (int i = 0; i < _floatArrayLiteral.length; i++) {
-          _floatArrayLiteral[i] = 
literalContexts.get(i).getLiteral().getFloatValue();
+          _floatArrayLiteral[i] = contexts.get(i).getFloatValue();
         }
         _intArrayLiteral = null;
         _longArrayLiteral = null;
         _doubleArrayLiteral = null;
+        _bigDecimalArrayLiteral = null;
         _stringArrayLiteral = null;
         _bytesArrayLiteral = null;
         break;
       case DOUBLE:
-        _doubleArrayLiteral = new double[literalContexts.size()];
+        _doubleArrayLiteral = new double[contexts.size()];
         for (int i = 0; i < _doubleArrayLiteral.length; i++) {
-          _doubleArrayLiteral[i] = 
literalContexts.get(i).getLiteral().getDoubleValue();
+          _doubleArrayLiteral[i] = contexts.get(i).getDoubleValue();
         }
         _intArrayLiteral = null;
         _longArrayLiteral = null;
         _floatArrayLiteral = null;
+        _bigDecimalArrayLiteral = null;
+        _stringArrayLiteral = null;
+        _bytesArrayLiteral = null;
+        break;
+      case BIG_DECIMAL:
+        _bigDecimalArrayLiteral = new BigDecimal[contexts.size()];
+        for (int i = 0; i < _bigDecimalArrayLiteral.length; i++) {
+          _bigDecimalArrayLiteral[i] = contexts.get(i).getBigDecimalValue();
+        }
+        _intArrayLiteral = null;
+        _longArrayLiteral = null;
+        _floatArrayLiteral = null;
+        _doubleArrayLiteral = null;
+        _stringArrayLiteral = null;
+        _bytesArrayLiteral = null;
+        break;
+      case BOOLEAN:
+        _intArrayLiteral = new int[contexts.size()];
+        for (int i = 0; i < _intArrayLiteral.length; i++) {
+          _intArrayLiteral[i] = contexts.get(i).getBooleanValue() ? 1 : 0;
+        }
+        _longArrayLiteral = null;
+        _floatArrayLiteral = null;
+        _doubleArrayLiteral = null;
+        _bigDecimalArrayLiteral = null;
+        _stringArrayLiteral = null;
+        _bytesArrayLiteral = null;
+        break;
+      case TIMESTAMP:
+        _longArrayLiteral = new long[contexts.size()];
+        for (int i = 0; i < _longArrayLiteral.length; i++) {
+          _longArrayLiteral[i] = contexts.get(i).getLongValue();
+        }
+        _intArrayLiteral = null;
+        _floatArrayLiteral = null;
+        _doubleArrayLiteral = null;
+        _bigDecimalArrayLiteral = null;
         _stringArrayLiteral = null;
         _bytesArrayLiteral = null;
         break;
       case STRING:
-        _stringArrayLiteral = new String[literalContexts.size()];
+        _stringArrayLiteral = new String[contexts.size()];
         for (int i = 0; i < _stringArrayLiteral.length; i++) {
-          _stringArrayLiteral[i] = 
literalContexts.get(i).getLiteral().getStringValue();
+          _stringArrayLiteral[i] = contexts.get(i).getStringValue();
         }
         _intArrayLiteral = null;
         _longArrayLiteral = null;
         _floatArrayLiteral = null;
         _doubleArrayLiteral = null;
+        _bigDecimalArrayLiteral = null;
         _bytesArrayLiteral = null;
         break;
       case BYTES:
-        _bytesArrayLiteral = new byte[literalContexts.size()][];
+      case UUID:
+        _bytesArrayLiteral = new byte[contexts.size()][];
         for (int i = 0; i < _bytesArrayLiteral.length; i++) {
-          _bytesArrayLiteral[i] = 
literalContexts.get(i).getLiteral().getBytesValue();
+          _bytesArrayLiteral[i] = contexts.get(i).getBytesValue();
         }
         _intArrayLiteral = null;
         _longArrayLiteral = null;
         _floatArrayLiteral = null;
         _doubleArrayLiteral = null;
+        _bigDecimalArrayLiteral = null;
         _stringArrayLiteral = null;
         break;
       default:
         throw new IllegalStateException(
             "Illegal data type for ArrayLiteralTransformFunction: " + 
_dataType + ", literal contexts: "
-                + Arrays.toString(literalContexts.toArray()));
+                + Arrays.toString(contexts.toArray()));
+    }
+  }
+
+  private static LiteralContext toLiteralContext(ExpressionContext context) {
+    if (context.getType() == ExpressionContext.Type.LITERAL) {
+      return context.getLiteral();
+    }
+    if (context.getType() == ExpressionContext.Type.FUNCTION) {
+      FunctionContext function = context.getFunction();
+      if (function.getFunctionName().equalsIgnoreCase("cast")) {
+        List<ExpressionContext> arguments = function.getArguments();
+        Preconditions.checkArgument(arguments.size() == 2,
+            "CAST function inside array literal constructor expects 2 
arguments, got: %s", arguments.size());
+        LiteralContext sourceLiteral = toLiteralContext(arguments.get(0));
+        ExpressionContext targetTypeExpr = arguments.get(1);
+        Preconditions.checkArgument(targetTypeExpr.getType() == 
ExpressionContext.Type.LITERAL,
+            "CAST target type must be a literal string, got: %s", 
targetTypeExpr);
+        String targetType = 
targetTypeExpr.getLiteral().getStringValue().toUpperCase();
+        return castLiteralContext(sourceLiteral, targetType);
+      }
+    }
+    throw new IllegalStateException(
+        "ArrayLiteralTransformFunction only takes literals or cast functions 
as arguments, found: " + context);
+  }
+
+  private static LiteralContext castLiteralContext(LiteralContext source, 
String targetType) {
+    switch (targetType) {

Review Comment:
   MINOR: Could we keep this new cast switch in the same type order as the 
other switches: INT, LONG, FLOAT, DOUBLE, BIG_DECIMAL, BOOLEAN, TIMESTAMP, 
STRING, BYTES, UUID? Keep each type's aliases together.



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