Jackie-Jiang commented on code in PR #13916: URL: https://github.com/apache/pinot/pull/13916#discussion_r1739426678
########## pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/ArrayLiteralTransformFunction.java: ########## @@ -48,12 +48,15 @@ public class ArrayLiteralTransformFunction implements TransformFunction { private final double[] _doubleArrayLiteral; private final String[] _stringArrayLiteral; - // literals may be shared but values are intentionally not volatile as assignment races are benign - private int[][] _intArrayResult; - private long[][] _longArrayResult; - private float[][] _floatArrayResult; - private double[][] _doubleArrayResult; - private String[][] _stringArrayResult; + // NOTE: + // This class can be shared across multiple threads, and the result arrays are lazily initialized and cached. They + // need to be declared as volatile to ensure instructions are not reordered, or some threads might see uninitialized + // arrays. + private volatile int[][] _intArrayResult; + private volatile long[][] _longArrayResult; + private volatile float[][] _floatArrayResult; + private volatile double[][] _doubleArrayResult; + private volatile String[][] _stringArrayResult; Review Comment: Yes. The same literal is shared across the query, and we might read different value types from it. E.g. SUM('1') will try to read '1' as double -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org