This is an automated email from the ASF dual-hosted git repository.

jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 0db63aac80 Use constant null place holder (#11615)
0db63aac80 is described below

commit 0db63aac803bd98bb1a32ada61be5f500c4caf35
Author: Xiaotian (Jackie) Jiang <[email protected]>
AuthorDate: Mon Sep 18 17:15:20 2023 -0700

    Use constant null place holder (#11615)
---
 .../common/function/scalar/ArrayFunctions.java     | 12 +++----
 .../org/apache/pinot/common/utils/DataSchema.java  | 37 +++++++++++-----------
 .../transform/function/BaseTransformFunction.java  | 28 ++++++++--------
 .../transform/function/CaseTransformFunction.java  | 30 +++++++++---------
 .../function/CoalesceTransformFunction.java        | 14 ++++----
 .../function/ScalarTransformFunctionWrapper.java   | 19 +++++------
 .../function/InTransformFunctionTest.java          |  4 +--
 .../ScalarTransformFunctionWrapperTest.java        | 17 ++++------
 .../apache/pinot/spi/utils/CommonConstants.java    | 11 +++++--
 9 files changed, 88 insertions(+), 84 deletions(-)

diff --git 
a/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/ArrayFunctions.java
 
b/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/ArrayFunctions.java
index 454fbe5912..a15cc931b4 100644
--- 
a/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/ArrayFunctions.java
+++ 
b/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/ArrayFunctions.java
@@ -25,8 +25,8 @@ import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet;
 import it.unimi.dsi.fastutil.objects.ObjectSet;
 import java.util.Arrays;
 import org.apache.commons.lang3.ArrayUtils;
-import org.apache.pinot.common.utils.DataSchema;
 import org.apache.pinot.spi.annotations.ScalarFunction;
+import org.apache.pinot.spi.utils.CommonConstants.NullValuePlaceHolder;
 
 
 /**
@@ -155,26 +155,26 @@ public class ArrayFunctions {
 
   @ScalarFunction
   public static int arrayElementAtInt(int[] arr, int idx) {
-    return idx > 0 && idx <= arr.length ? arr[idx - 1] : (int) 
DataSchema.ColumnDataType.INT.getNullPlaceholder();
+    return idx > 0 && idx <= arr.length ? arr[idx - 1] : 
NullValuePlaceHolder.INT;
   }
 
   @ScalarFunction
   public static long arrayElementAtLong(long[] arr, int idx) {
-    return idx > 0 && idx <= arr.length ? arr[idx - 1] : (long) 
DataSchema.ColumnDataType.LONG.getNullPlaceholder();
+    return idx > 0 && idx <= arr.length ? arr[idx - 1] : 
NullValuePlaceHolder.LONG;
   }
 
   @ScalarFunction
   public static float arrayElementAtFloat(float[] arr, int idx) {
-    return idx > 0 && idx <= arr.length ? arr[idx - 1] : (float) 
DataSchema.ColumnDataType.FLOAT.getNullPlaceholder();
+    return idx > 0 && idx <= arr.length ? arr[idx - 1] : 
NullValuePlaceHolder.FLOAT;
   }
 
   @ScalarFunction
   public static double arrayElementAtDouble(double[] arr, int idx) {
-    return idx > 0 && idx <= arr.length ? arr[idx - 1] : (double) 
DataSchema.ColumnDataType.DOUBLE.getNullPlaceholder();
+    return idx > 0 && idx <= arr.length ? arr[idx - 1] : 
NullValuePlaceHolder.DOUBLE;
   }
 
   @ScalarFunction
   public static String arrayElementAtString(String[] arr, int idx) {
-    return idx > 0 && idx <= arr.length ? arr[idx - 1] : (String) 
DataSchema.ColumnDataType.STRING.getNullPlaceholder();
+    return idx > 0 && idx <= arr.length ? arr[idx - 1] : 
NullValuePlaceHolder.STRING;
   }
 }
diff --git 
a/pinot-common/src/main/java/org/apache/pinot/common/utils/DataSchema.java 
b/pinot-common/src/main/java/org/apache/pinot/common/utils/DataSchema.java
index 1785dffb57..fabad7a049 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/DataSchema.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/DataSchema.java
@@ -37,6 +37,7 @@ import org.apache.pinot.common.datatable.DataTable;
 import org.apache.pinot.spi.data.FieldSpec.DataType;
 import org.apache.pinot.spi.utils.ByteArray;
 import org.apache.pinot.spi.utils.BytesUtils;
+import org.apache.pinot.spi.utils.CommonConstants.NullValuePlaceHolder;
 import org.apache.pinot.spi.utils.EqualityUtils;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
@@ -191,25 +192,25 @@ public class DataSchema {
   }
 
   public enum ColumnDataType {
-    INT(0),
-    LONG(0L),
-    FLOAT(0f),
-    DOUBLE(0d),
-    BIG_DECIMAL(BigDecimal.ZERO),
-    BOOLEAN(INT, 0),
-    TIMESTAMP(LONG, 0L),
-    STRING(""),
-    JSON(STRING, ""),
-    BYTES(new ByteArray(new byte[0])),
+    INT(NullValuePlaceHolder.INT),
+    LONG(NullValuePlaceHolder.LONG),
+    FLOAT(NullValuePlaceHolder.FLOAT),
+    DOUBLE(NullValuePlaceHolder.DOUBLE),
+    BIG_DECIMAL(NullValuePlaceHolder.BIG_DECIMAL),
+    BOOLEAN(INT, NullValuePlaceHolder.INT),
+    TIMESTAMP(LONG, NullValuePlaceHolder.LONG),
+    STRING(NullValuePlaceHolder.STRING),
+    JSON(STRING, NullValuePlaceHolder.STRING),
+    BYTES(NullValuePlaceHolder.INTERNAL_BYTES),
     OBJECT(null),
-    INT_ARRAY(new int[0]),
-    LONG_ARRAY(new long[0]),
-    FLOAT_ARRAY(new float[0]),
-    DOUBLE_ARRAY(new double[0]),
-    BOOLEAN_ARRAY(INT_ARRAY, new int[0]),
-    TIMESTAMP_ARRAY(LONG_ARRAY, new long[0]),
-    STRING_ARRAY(new String[0]),
-    BYTES_ARRAY(new byte[0][]),
+    INT_ARRAY(NullValuePlaceHolder.INT_ARRAY),
+    LONG_ARRAY(NullValuePlaceHolder.LONG_ARRAY),
+    FLOAT_ARRAY(NullValuePlaceHolder.FLOAT_ARRAY),
+    DOUBLE_ARRAY(NullValuePlaceHolder.DOUBLE_ARRAY),
+    BOOLEAN_ARRAY(INT_ARRAY, NullValuePlaceHolder.INT_ARRAY),
+    TIMESTAMP_ARRAY(LONG_ARRAY, NullValuePlaceHolder.LONG_ARRAY),
+    STRING_ARRAY(NullValuePlaceHolder.STRING_ARRAY),
+    BYTES_ARRAY(NullValuePlaceHolder.BYTES_ARRAY),
     UNKNOWN(null);
 
     private static final EnumSet<ColumnDataType> NUMERIC_TYPES = 
EnumSet.of(INT, LONG, FLOAT, DOUBLE, BIG_DECIMAL);
diff --git 
a/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/BaseTransformFunction.java
 
b/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/BaseTransformFunction.java
index caa97f60bc..5afc55549c 100644
--- 
a/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/BaseTransformFunction.java
+++ 
b/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/BaseTransformFunction.java
@@ -23,13 +23,13 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import javax.annotation.Nullable;
-import org.apache.pinot.common.utils.DataSchema;
 import org.apache.pinot.core.operator.ColumnContext;
 import org.apache.pinot.core.operator.blocks.ValueBlock;
 import org.apache.pinot.core.operator.transform.TransformResultMetadata;
 import org.apache.pinot.segment.spi.index.reader.Dictionary;
 import org.apache.pinot.spi.data.FieldSpec.DataType;
 import org.apache.pinot.spi.utils.ArrayCopyUtils;
+import org.apache.pinot.spi.utils.CommonConstants.NullValuePlaceHolder;
 import org.roaringbitmap.RoaringBitmap;
 
 
@@ -104,7 +104,7 @@ public abstract class BaseTransformFunction implements 
TransformFunction {
 
   protected void fillResultUnknown(int length) {
     for (int i = 0; i < length; i++) {
-      _intValuesSV[i] = (int) 
DataSchema.ColumnDataType.INT.getNullPlaceholder();
+      _intValuesSV[i] = NullValuePlaceHolder.INT;
     }
   }
 
@@ -184,7 +184,7 @@ public abstract class BaseTransformFunction implements 
TransformFunction {
         case UNKNOWN:
           // Copy the values to ensure behaviour consistency with non 
null-handling.
           for (int i = 0; i < length; i++) {
-            _intValuesSV[i] = (int) 
DataSchema.ColumnDataType.INT.getNullPlaceholder();
+            _intValuesSV[i] = NullValuePlaceHolder.INT;
           }
           break;
         default:
@@ -234,7 +234,7 @@ public abstract class BaseTransformFunction implements 
TransformFunction {
         case UNKNOWN:
           // Copy the values to ensure behaviour consistency with non 
null-handling.
           for (int i = 0; i < length; i++) {
-            _longValuesSV[i] = (long) 
DataSchema.ColumnDataType.LONG.getNullPlaceholder();
+            _longValuesSV[i] = NullValuePlaceHolder.LONG;
           }
           break;
         default:
@@ -284,7 +284,7 @@ public abstract class BaseTransformFunction implements 
TransformFunction {
         case UNKNOWN:
           // Copy the values to ensure behaviour consistency with non 
null-handling.
           for (int i = 0; i < length; i++) {
-            _floatValuesSV[i] = (float) 
DataSchema.ColumnDataType.FLOAT.getNullPlaceholder();
+            _floatValuesSV[i] = NullValuePlaceHolder.FLOAT;
           }
           break;
         default:
@@ -334,7 +334,7 @@ public abstract class BaseTransformFunction implements 
TransformFunction {
         case UNKNOWN:
           // Copy the values to ensure behaviour consistency with non 
null-handling.
           for (int i = 0; i < length; i++) {
-            _doubleValuesSV[i] = (double) 
DataSchema.ColumnDataType.DOUBLE.getNullPlaceholder();
+            _doubleValuesSV[i] = NullValuePlaceHolder.DOUBLE;
           }
           break;
         default:
@@ -388,7 +388,7 @@ public abstract class BaseTransformFunction implements 
TransformFunction {
         case UNKNOWN:
           // Copy the values to ensure behaviour consistency with non 
null-handling.
           for (int i = 0; i < length; i++) {
-            _bigDecimalValuesSV[i] = (BigDecimal) 
DataSchema.ColumnDataType.BIG_DECIMAL.getNullPlaceholder();
+            _bigDecimalValuesSV[i] = NullValuePlaceHolder.BIG_DECIMAL;
           }
           break;
         default:
@@ -442,7 +442,7 @@ public abstract class BaseTransformFunction implements 
TransformFunction {
         case UNKNOWN:
           // Copy the values to ensure behaviour consistency with non 
null-handling.
           for (int i = 0; i < length; i++) {
-            _stringValuesSV[i] = (String) 
DataSchema.ColumnDataType.STRING.getNullPlaceholder();
+            _stringValuesSV[i] = NullValuePlaceHolder.STRING;
           }
           break;
         default:
@@ -480,7 +480,7 @@ public abstract class BaseTransformFunction implements 
TransformFunction {
         case UNKNOWN:
           // Copy the values to ensure behaviour consistency with non 
null-handling.
           for (int i = 0; i < length; i++) {
-            _bytesValuesSV[i] = (byte[]) 
DataSchema.ColumnDataType.BYTES.getNullPlaceholder();
+            _bytesValuesSV[i] = NullValuePlaceHolder.BYTES;
           }
           break;
         default:
@@ -532,7 +532,7 @@ public abstract class BaseTransformFunction implements 
TransformFunction {
         case UNKNOWN:
           // Copy the values to ensure behaviour consistency with non 
null-handling.
           for (int i = 0; i < length; i++) {
-            _intValuesMV[i] = (int[]) 
DataSchema.ColumnDataType.INT_ARRAY.getNullPlaceholder();
+            _intValuesMV[i] = NullValuePlaceHolder.INT_ARRAY;
           }
           break;
         default:
@@ -584,7 +584,7 @@ public abstract class BaseTransformFunction implements 
TransformFunction {
         case UNKNOWN:
           // Copy the values to ensure behaviour consistency with non 
null-handling.
           for (int i = 0; i < length; i++) {
-            _longValuesMV[i] = (long[]) 
DataSchema.ColumnDataType.LONG_ARRAY.getNullPlaceholder();
+            _longValuesMV[i] = NullValuePlaceHolder.LONG_ARRAY;
           }
           break;
         default:
@@ -636,7 +636,7 @@ public abstract class BaseTransformFunction implements 
TransformFunction {
         case UNKNOWN:
           // Copy the values to ensure behaviour consistency with non 
null-handling.
           for (int i = 0; i < length; i++) {
-            _floatValuesMV[i] = (float[]) 
DataSchema.ColumnDataType.FLOAT_ARRAY.getNullPlaceholder();
+            _floatValuesMV[i] = NullValuePlaceHolder.FLOAT_ARRAY;
           }
           break;
         default:
@@ -688,7 +688,7 @@ public abstract class BaseTransformFunction implements 
TransformFunction {
         case UNKNOWN:
           // Copy the values to ensure behaviour consistency with non 
null-handling.
           for (int i = 0; i < length; i++) {
-            _doubleValuesMV[i] = (double[]) 
DataSchema.ColumnDataType.DOUBLE_ARRAY.getNullPlaceholder();
+            _doubleValuesMV[i] = NullValuePlaceHolder.DOUBLE_ARRAY;
           }
           break;
         default:
@@ -740,7 +740,7 @@ public abstract class BaseTransformFunction implements 
TransformFunction {
         case UNKNOWN:
           // Copy the values to ensure behaviour consistency with non 
null-handling.
           for (int i = 0; i < length; i++) {
-            _stringValuesMV[i] = (String[]) 
DataSchema.ColumnDataType.STRING_ARRAY.getNullPlaceholder();
+            _stringValuesMV[i] = NullValuePlaceHolder.STRING_ARRAY;
           }
           break;
         default:
diff --git 
a/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/CaseTransformFunction.java
 
b/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/CaseTransformFunction.java
index aff6b460c9..1adb1312b8 100644
--- 
a/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/CaseTransformFunction.java
+++ 
b/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/CaseTransformFunction.java
@@ -28,11 +28,11 @@ import java.util.List;
 import java.util.Map;
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.commons.lang3.tuple.Pair;
-import org.apache.pinot.common.utils.DataSchema;
 import org.apache.pinot.core.operator.ColumnContext;
 import org.apache.pinot.core.operator.blocks.ValueBlock;
 import org.apache.pinot.core.operator.transform.TransformResultMetadata;
 import org.apache.pinot.spi.data.FieldSpec.DataType;
+import org.apache.pinot.spi.utils.CommonConstants.NullValuePlaceHolder;
 import org.roaringbitmap.RoaringBitmap;
 
 
@@ -346,7 +346,7 @@ public class CaseTransformFunction extends 
ComputeDifferentlyWhenNullHandlingEna
     if (!unselectedDocs.isEmpty()) {
       if (_elseStatement == null) {
         for (int docId = unselectedDocs.nextSetBit(0); docId >= 0; docId = 
unselectedDocs.nextSetBit(docId + 1)) {
-          _intValuesSV[docId] = (int) 
DataSchema.ColumnDataType.INT.getNullPlaceholder();
+          _intValuesSV[docId] = NullValuePlaceHolder.INT;
         }
       } else {
         int[] intValuesSV = _elseStatement.transformToIntValuesSV(valueBlock);
@@ -391,7 +391,7 @@ public class CaseTransformFunction extends 
ComputeDifferentlyWhenNullHandlingEna
     if (!unselectedDocs.isEmpty()) {
       if (_elseStatement == null) {
         for (int docId = unselectedDocs.nextSetBit(0); docId >= 0; docId = 
unselectedDocs.nextSetBit(docId + 1)) {
-          _intValuesSV[docId] = (int) 
DataSchema.ColumnDataType.INT.getNullPlaceholder();
+          _intValuesSV[docId] = NullValuePlaceHolder.INT;
           bitmap.add(docId);
         }
       } else {
@@ -431,7 +431,7 @@ public class CaseTransformFunction extends 
ComputeDifferentlyWhenNullHandlingEna
     if (!unselectedDocs.isEmpty()) {
       if (_elseStatement == null) {
         for (int docId = unselectedDocs.nextSetBit(0); docId >= 0; docId = 
unselectedDocs.nextSetBit(docId + 1)) {
-          _longValuesSV[docId] = (long) 
DataSchema.ColumnDataType.LONG.getNullPlaceholder();
+          _longValuesSV[docId] = NullValuePlaceHolder.LONG;
         }
       } else {
         long[] longValuesSV = 
_elseStatement.transformToLongValuesSV(valueBlock);
@@ -476,7 +476,7 @@ public class CaseTransformFunction extends 
ComputeDifferentlyWhenNullHandlingEna
     if (!unselectedDocs.isEmpty()) {
       if (_elseStatement == null) {
         for (int docId = unselectedDocs.nextSetBit(0); docId >= 0; docId = 
unselectedDocs.nextSetBit(docId + 1)) {
-          _longValuesSV[docId] = (long) 
DataSchema.ColumnDataType.LONG.getNullPlaceholder();
+          _longValuesSV[docId] = NullValuePlaceHolder.LONG;
           bitmap.add(docId);
         }
       } else {
@@ -516,7 +516,7 @@ public class CaseTransformFunction extends 
ComputeDifferentlyWhenNullHandlingEna
     if (!unselectedDocs.isEmpty()) {
       if (_elseStatement == null) {
         for (int docId = unselectedDocs.nextSetBit(0); docId >= 0; docId = 
unselectedDocs.nextSetBit(docId + 1)) {
-          _floatValuesSV[docId] = (float) 
DataSchema.ColumnDataType.FLOAT.getNullPlaceholder();
+          _floatValuesSV[docId] = NullValuePlaceHolder.FLOAT;
         }
       } else {
         float[] floatValuesSV = 
_elseStatement.transformToFloatValuesSV(valueBlock);
@@ -561,7 +561,7 @@ public class CaseTransformFunction extends 
ComputeDifferentlyWhenNullHandlingEna
     if (!unselectedDocs.isEmpty()) {
       if (_elseStatement == null) {
         for (int docId = unselectedDocs.nextSetBit(0); docId >= 0; docId = 
unselectedDocs.nextSetBit(docId + 1)) {
-          _floatValuesSV[docId] = (float) 
DataSchema.ColumnDataType.FLOAT.getNullPlaceholder();
+          _floatValuesSV[docId] = NullValuePlaceHolder.FLOAT;
           bitmap.add(docId);
         }
       } else {
@@ -601,7 +601,7 @@ public class CaseTransformFunction extends 
ComputeDifferentlyWhenNullHandlingEna
     if (!unselectedDocs.isEmpty()) {
       if (_elseStatement == null) {
         for (int docId = unselectedDocs.nextSetBit(0); docId >= 0; docId = 
unselectedDocs.nextSetBit(docId + 1)) {
-          _doubleValuesSV[docId] = (double) 
DataSchema.ColumnDataType.DOUBLE.getNullPlaceholder();
+          _doubleValuesSV[docId] = NullValuePlaceHolder.DOUBLE;
         }
       } else {
         float[] doubleValuesSV = 
_elseStatement.transformToFloatValuesSV(valueBlock);
@@ -647,7 +647,7 @@ public class CaseTransformFunction extends 
ComputeDifferentlyWhenNullHandlingEna
     if (!unselectedDocs.isEmpty()) {
       if (_elseStatement == null) {
         for (int docId = unselectedDocs.nextSetBit(0); docId >= 0; docId = 
unselectedDocs.nextSetBit(docId + 1)) {
-          _doubleValuesSV[docId] = (double) 
DataSchema.ColumnDataType.DOUBLE.getNullPlaceholder();
+          _doubleValuesSV[docId] = NullValuePlaceHolder.DOUBLE;
           bitmap.add(docId);
         }
       } else {
@@ -687,7 +687,7 @@ public class CaseTransformFunction extends 
ComputeDifferentlyWhenNullHandlingEna
     if (!unselectedDocs.isEmpty()) {
       if (_elseStatement == null) {
         for (int docId = unselectedDocs.nextSetBit(0); docId >= 0; docId = 
unselectedDocs.nextSetBit(docId + 1)) {
-          _bigDecimalValuesSV[docId] = (BigDecimal) 
DataSchema.ColumnDataType.BIG_DECIMAL.getNullPlaceholder();
+          _bigDecimalValuesSV[docId] = NullValuePlaceHolder.BIG_DECIMAL;
         }
       } else {
         BigDecimal[] bigDecimalValuesSV = 
_elseStatement.transformToBigDecimalValuesSV(valueBlock);
@@ -733,7 +733,7 @@ public class CaseTransformFunction extends 
ComputeDifferentlyWhenNullHandlingEna
     if (!unselectedDocs.isEmpty()) {
       if (_elseStatement == null) {
         for (int docId = unselectedDocs.nextSetBit(0); docId >= 0; docId = 
unselectedDocs.nextSetBit(docId + 1)) {
-          _bigDecimalValuesSV[docId] = (BigDecimal) 
DataSchema.ColumnDataType.BIG_DECIMAL.getNullPlaceholder();
+            _bigDecimalValuesSV[docId] = NullValuePlaceHolder.BIG_DECIMAL;
           bitmap.add(docId);
         }
       } else {
@@ -773,7 +773,7 @@ public class CaseTransformFunction extends 
ComputeDifferentlyWhenNullHandlingEna
     if (!unselectedDocs.isEmpty()) {
       if (_elseStatement == null) {
         for (int docId = unselectedDocs.nextSetBit(0); docId >= 0; docId = 
unselectedDocs.nextSetBit(docId + 1)) {
-          _stringValuesSV[docId] = (String) 
DataSchema.ColumnDataType.STRING.getNullPlaceholder();
+          _stringValuesSV[docId] = NullValuePlaceHolder.STRING;
         }
       } else {
         String[] stringValuesSV = 
_elseStatement.transformToStringValuesSV(valueBlock);
@@ -819,7 +819,7 @@ public class CaseTransformFunction extends 
ComputeDifferentlyWhenNullHandlingEna
     if (!unselectedDocs.isEmpty()) {
       if (_elseStatement == null) {
         for (int docId = unselectedDocs.nextSetBit(0); docId >= 0; docId = 
unselectedDocs.nextSetBit(docId + 1)) {
-          _stringValuesSV[docId] = (String) 
DataSchema.ColumnDataType.STRING.getNullPlaceholder();
+          _stringValuesSV[docId] = NullValuePlaceHolder.STRING;
           bitmap.add(docId);
         }
       } else {
@@ -859,7 +859,7 @@ public class CaseTransformFunction extends 
ComputeDifferentlyWhenNullHandlingEna
     if (!unselectedDocs.isEmpty()) {
       if (_elseStatement == null) {
         for (int docId = unselectedDocs.nextSetBit(0); docId >= 0; docId = 
unselectedDocs.nextSetBit(docId + 1)) {
-          _bytesValuesSV[docId] = (byte[]) 
DataSchema.ColumnDataType.BYTES.getNullPlaceholder();
+          _bytesValuesSV[docId] = NullValuePlaceHolder.BYTES;
         }
       } else {
         byte[][] byteValuesSV = 
_elseStatement.transformToBytesValuesSV(valueBlock);
@@ -904,7 +904,7 @@ public class CaseTransformFunction extends 
ComputeDifferentlyWhenNullHandlingEna
     if (!unselectedDocs.isEmpty()) {
       if (_elseStatement == null) {
         for (int docId = unselectedDocs.nextSetBit(0); docId >= 0; docId = 
unselectedDocs.nextSetBit(docId + 1)) {
-          _bytesValuesSV[docId] = (byte[]) 
DataSchema.ColumnDataType.BYTES.getNullPlaceholder();
+          _bytesValuesSV[docId] = NullValuePlaceHolder.BYTES;
           bitmap.add(docId);
         }
       } else {
diff --git 
a/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/CoalesceTransformFunction.java
 
b/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/CoalesceTransformFunction.java
index ba677c2579..6769116040 100644
--- 
a/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/CoalesceTransformFunction.java
+++ 
b/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/CoalesceTransformFunction.java
@@ -23,11 +23,11 @@ import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 import org.apache.pinot.common.function.TransformFunctionType;
-import org.apache.pinot.common.utils.DataSchema;
 import org.apache.pinot.core.operator.ColumnContext;
 import org.apache.pinot.core.operator.blocks.ValueBlock;
 import org.apache.pinot.core.operator.transform.TransformResultMetadata;
 import org.apache.pinot.spi.data.FieldSpec.DataType;
+import org.apache.pinot.spi.utils.CommonConstants.NullValuePlaceHolder;
 import org.roaringbitmap.RoaringBitmap;
 
 
@@ -121,7 +121,7 @@ public class CoalesceTransformFunction extends 
BaseTransformFunction {
         break;
       }
       if (!hasNonNullValue) {
-        _intValuesSV[i] = (int) 
DataSchema.ColumnDataType.INT.getNullPlaceholder();
+        _intValuesSV[i] = NullValuePlaceHolder.INT;
       }
     }
     return _intValuesSV;
@@ -151,7 +151,7 @@ public class CoalesceTransformFunction extends 
BaseTransformFunction {
         break;
       }
       if (!hasNonNullValue) {
-        _longValuesSV[i] = (long) 
DataSchema.ColumnDataType.LONG.getNullPlaceholder();
+        _longValuesSV[i] = NullValuePlaceHolder.LONG;
       }
     }
     return _longValuesSV;
@@ -181,7 +181,7 @@ public class CoalesceTransformFunction extends 
BaseTransformFunction {
         break;
       }
       if (!hasNonNullValue) {
-        _floatValuesSV[i] = (float) 
DataSchema.ColumnDataType.FLOAT.getNullPlaceholder();
+        _floatValuesSV[i] = NullValuePlaceHolder.FLOAT;
       }
     }
     return _floatValuesSV;
@@ -211,7 +211,7 @@ public class CoalesceTransformFunction extends 
BaseTransformFunction {
         break;
       }
       if (!hasNonNullValue) {
-        _doubleValuesSV[i] = (double) 
DataSchema.ColumnDataType.DOUBLE.getNullPlaceholder();
+        _doubleValuesSV[i] = NullValuePlaceHolder.DOUBLE;
       }
     }
     return _doubleValuesSV;
@@ -241,7 +241,7 @@ public class CoalesceTransformFunction extends 
BaseTransformFunction {
         break;
       }
       if (!hasNonNullValue) {
-        _bigDecimalValuesSV[i] = (BigDecimal) 
DataSchema.ColumnDataType.BIG_DECIMAL.getNullPlaceholder();
+        _bigDecimalValuesSV[i] = NullValuePlaceHolder.BIG_DECIMAL;
       }
     }
     return _bigDecimalValuesSV;
@@ -271,7 +271,7 @@ public class CoalesceTransformFunction extends 
BaseTransformFunction {
         break;
       }
       if (!hasNonNullValue) {
-        _stringValuesSV[i] = (String) 
DataSchema.ColumnDataType.STRING.getNullPlaceholder();
+        _stringValuesSV[i] = NullValuePlaceHolder.STRING;
       }
     }
     return _stringValuesSV;
diff --git 
a/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/ScalarTransformFunctionWrapper.java
 
b/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/ScalarTransformFunctionWrapper.java
index 2ef8d76e15..d8ea23b492 100644
--- 
a/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/ScalarTransformFunctionWrapper.java
+++ 
b/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/ScalarTransformFunctionWrapper.java
@@ -34,6 +34,7 @@ import org.apache.pinot.core.operator.blocks.ValueBlock;
 import org.apache.pinot.core.operator.transform.TransformResultMetadata;
 import org.apache.pinot.spi.data.FieldSpec.DataType;
 import org.apache.pinot.spi.utils.ByteArray;
+import org.apache.pinot.spi.utils.CommonConstants.NullValuePlaceHolder;
 
 
 /**
@@ -169,7 +170,7 @@ public class ScalarTransformFunctionWrapper extends 
BaseTransformFunction {
         _scalarArguments[_nonLiteralIndices[j]] = _nonLiteralValues[j][i];
       }
       Object value = _functionInvoker.invoke(_scalarArguments);
-      _intValuesSV[i] = value != null ? (int) _resultType.toInternal(value) : 
(int) _resultType.getNullPlaceholder();
+      _intValuesSV[i] = value != null ? (int) _resultType.toInternal(value) : 
NullValuePlaceHolder.INT;
     }
     return _intValuesSV;
   }
@@ -187,7 +188,7 @@ public class ScalarTransformFunctionWrapper extends 
BaseTransformFunction {
         _scalarArguments[_nonLiteralIndices[j]] = _nonLiteralValues[j][i];
       }
       Object value = _functionInvoker.invoke(_scalarArguments);
-      _longValuesSV[i] = value != null ? (long) _resultType.toInternal(value) 
: (long) _resultType.getNullPlaceholder();
+      _longValuesSV[i] = value != null ? (long) _resultType.toInternal(value) 
: NullValuePlaceHolder.LONG;
     }
     return _longValuesSV;
   }
@@ -206,7 +207,7 @@ public class ScalarTransformFunctionWrapper extends 
BaseTransformFunction {
       }
       Object value = _functionInvoker.invoke(_scalarArguments);
       _floatValuesSV[i] =
-          value != null ? (float) _resultType.toInternal(value) : (float) 
_resultType.getNullPlaceholder();
+          value != null ? (float) _resultType.toInternal(value) : 
NullValuePlaceHolder.FLOAT;
     }
     return _floatValuesSV;
   }
@@ -225,7 +226,7 @@ public class ScalarTransformFunctionWrapper extends 
BaseTransformFunction {
       }
       Object value = _functionInvoker.invoke(_scalarArguments);
       _doubleValuesSV[i] =
-          value != null ? (double) _resultType.toInternal(value) : (double) 
_resultType.getNullPlaceholder();
+          value != null ? (double) _resultType.toInternal(value) : 
NullValuePlaceHolder.DOUBLE;
     }
     return _doubleValuesSV;
   }
@@ -244,7 +245,7 @@ public class ScalarTransformFunctionWrapper extends 
BaseTransformFunction {
       }
       Object value = _functionInvoker.invoke(_scalarArguments);
       _bigDecimalValuesSV[i] =
-          value != null ? (BigDecimal) _resultType.toInternal(value) : 
(BigDecimal) _resultType.getNullPlaceholder();
+          value != null ? (BigDecimal) _resultType.toInternal(value) : 
NullValuePlaceHolder.BIG_DECIMAL;
     }
     return _bigDecimalValuesSV;
   }
@@ -263,7 +264,7 @@ public class ScalarTransformFunctionWrapper extends 
BaseTransformFunction {
       }
       Object value = _functionInvoker.invoke(_scalarArguments);
       _stringValuesSV[i] =
-          value != null ? (String) _resultType.toInternal(value) : (String) 
_resultType.getNullPlaceholder();
+          value != null ? (String) _resultType.toInternal(value) : 
NullValuePlaceHolder.STRING;
     }
     return _stringValuesSV;
   }
@@ -281,9 +282,9 @@ public class ScalarTransformFunctionWrapper extends 
BaseTransformFunction {
         _scalarArguments[_nonLiteralIndices[j]] = _nonLiteralValues[j][i];
       }
       Object value = _functionInvoker.invoke(_scalarArguments);
-      ByteArray byteArray =
-          value != null ? (ByteArray) _resultType.toInternal(value) : 
(ByteArray) _resultType.getNullPlaceholder();
-      _bytesValuesSV[i] = byteArray.getBytes();
+      byte[] bytes =
+          value != null ? ((ByteArray) 
_resultType.toInternal(value)).getBytes() : NullValuePlaceHolder.BYTES;
+      _bytesValuesSV[i] = bytes;
     }
     return _bytesValuesSV;
   }
diff --git 
a/pinot-core/src/test/java/org/apache/pinot/core/operator/transform/function/InTransformFunctionTest.java
 
b/pinot-core/src/test/java/org/apache/pinot/core/operator/transform/function/InTransformFunctionTest.java
index f33b1138bd..983758c3fc 100644
--- 
a/pinot-core/src/test/java/org/apache/pinot/core/operator/transform/function/InTransformFunctionTest.java
+++ 
b/pinot-core/src/test/java/org/apache/pinot/core/operator/transform/function/InTransformFunctionTest.java
@@ -25,9 +25,9 @@ import java.util.stream.Collectors;
 import org.apache.pinot.common.function.TransformFunctionType;
 import org.apache.pinot.common.request.context.ExpressionContext;
 import org.apache.pinot.common.request.context.RequestContextUtils;
-import org.apache.pinot.common.utils.DataSchema;
 import org.apache.pinot.spi.utils.ByteArray;
 import org.apache.pinot.spi.utils.BytesUtils;
+import org.apache.pinot.spi.utils.CommonConstants.NullValuePlaceHolder;
 import org.roaringbitmap.RoaringBitmap;
 import org.testng.annotations.Test;
 
@@ -241,7 +241,7 @@ public class InTransformFunctionTest extends 
BaseTransformFunctionTest {
     ExpressionContext expression = 
RequestContextUtils.getExpression(expressionStr);
     TransformFunction transformFunction = 
TransformFunctionFactory.get(expression, _dataSourceMap);
     int[] expectedIntValues = new int[NUM_ROWS];
-    Arrays.fill(expectedIntValues, (int) 
DataSchema.ColumnDataType.INT.getNullPlaceholder());
+    Arrays.fill(expectedIntValues, NullValuePlaceHolder.INT);
 
     assertEquals(transformFunction.transformToIntValuesSV(_projectionBlock), 
expectedIntValues);
   }
diff --git 
a/pinot-core/src/test/java/org/apache/pinot/core/operator/transform/function/ScalarTransformFunctionWrapperTest.java
 
b/pinot-core/src/test/java/org/apache/pinot/core/operator/transform/function/ScalarTransformFunctionWrapperTest.java
index 117779acac..c16f0e9c23 100644
--- 
a/pinot-core/src/test/java/org/apache/pinot/core/operator/transform/function/ScalarTransformFunctionWrapperTest.java
+++ 
b/pinot-core/src/test/java/org/apache/pinot/core/operator/transform/function/ScalarTransformFunctionWrapperTest.java
@@ -30,10 +30,10 @@ import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.pinot.common.request.context.ExpressionContext;
 import org.apache.pinot.common.request.context.RequestContextUtils;
-import org.apache.pinot.common.utils.DataSchema;
 import org.apache.pinot.spi.data.FieldSpec.DataType;
 import org.apache.pinot.spi.utils.ArrayCopyUtils;
 import org.apache.pinot.spi.utils.BigDecimalUtils;
+import org.apache.pinot.spi.utils.CommonConstants.NullValuePlaceHolder;
 import org.roaringbitmap.RoaringBitmap;
 import org.testng.annotations.Test;
 
@@ -880,8 +880,7 @@ public class ScalarTransformFunctionWrapperTest extends 
BaseTransformFunctionTes
     assertTrue(transformFunction.getResultMetadata().isSingleValue());
     int[] expectedValues = new int[NUM_ROWS];
     for (int i = 0; i < NUM_ROWS; i++) {
-      expectedValues[i] = _intMVValues[i].length > index ? 
_intMVValues[i][index]
-          : (Integer) DataSchema.ColumnDataType.INT.getNullPlaceholder();
+      expectedValues[i] = _intMVValues[i].length > index ? 
_intMVValues[i][index] : NullValuePlaceHolder.INT;
     }
     testTransformFunction(transformFunction, expectedValues);
   }
@@ -898,8 +897,7 @@ public class ScalarTransformFunctionWrapperTest extends 
BaseTransformFunctionTes
     assertTrue(transformFunction.getResultMetadata().isSingleValue());
     long[] expectedValues = new long[NUM_ROWS];
     for (int i = 0; i < NUM_ROWS; i++) {
-      expectedValues[i] = _longMVValues[i].length > index ? 
_longMVValues[i][index]
-          : (Long) DataSchema.ColumnDataType.LONG.getNullPlaceholder();
+      expectedValues[i] = _longMVValues[i].length > index ? 
_longMVValues[i][index] : NullValuePlaceHolder.LONG;
     }
     testTransformFunction(transformFunction, expectedValues);
   }
@@ -916,8 +914,7 @@ public class ScalarTransformFunctionWrapperTest extends 
BaseTransformFunctionTes
     assertTrue(transformFunction.getResultMetadata().isSingleValue());
     float[] expectedValues = new float[NUM_ROWS];
     for (int i = 0; i < NUM_ROWS; i++) {
-      expectedValues[i] = _floatMVValues[i].length > index ? 
_floatMVValues[i][index]
-          : (Float) DataSchema.ColumnDataType.FLOAT.getNullPlaceholder();
+      expectedValues[i] = _floatMVValues[i].length > index ? 
_floatMVValues[i][index] : NullValuePlaceHolder.FLOAT;
     }
     testTransformFunction(transformFunction, expectedValues);
   }
@@ -934,8 +931,7 @@ public class ScalarTransformFunctionWrapperTest extends 
BaseTransformFunctionTes
     assertTrue(transformFunction.getResultMetadata().isSingleValue());
     double[] expectedValues = new double[NUM_ROWS];
     for (int i = 0; i < NUM_ROWS; i++) {
-      expectedValues[i] = _doubleMVValues[i].length > index ? 
_doubleMVValues[i][index]
-          : (Double) DataSchema.ColumnDataType.DOUBLE.getNullPlaceholder();
+      expectedValues[i] = _doubleMVValues[i].length > index ? 
_doubleMVValues[i][index] : NullValuePlaceHolder.DOUBLE;
     }
     testTransformFunction(transformFunction, expectedValues);
   }
@@ -952,8 +948,7 @@ public class ScalarTransformFunctionWrapperTest extends 
BaseTransformFunctionTes
     assertTrue(transformFunction.getResultMetadata().isSingleValue());
     String[] expectedValues = new String[NUM_ROWS];
     for (int i = 0; i < NUM_ROWS; i++) {
-      expectedValues[i] = _stringMVValues[i].length > index ? 
_stringMVValues[i][index]
-          : (String) DataSchema.ColumnDataType.STRING.getNullPlaceholder();
+      expectedValues[i] = _stringMVValues[i].length > index ? 
_stringMVValues[i][index] : NullValuePlaceHolder.STRING;
     }
     testTransformFunction(transformFunction, expectedValues);
   }
diff --git 
a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java 
b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java
index 95cd091381..91755df8fa 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java
@@ -305,8 +305,8 @@ public class CommonConstants {
         "pinot.broker.instance.enableThreadAllocatedBytesMeasurement";
     public static final boolean DEFAULT_ENABLE_THREAD_CPU_TIME_MEASUREMENT = 
false;
     public static final boolean DEFAULT_THREAD_ALLOCATED_BYTES_MEASUREMENT = 
false;
-    public static final String CONFIG_OF_BROKER_RESULT_REWRITER_CLASS_NAMES
-        = "pinot.broker.result.rewriter.class.names";
+    public static final String CONFIG_OF_BROKER_RESULT_REWRITER_CLASS_NAMES =
+        "pinot.broker.result.rewriter.class.names";
 
     public static final String CONFIG_OF_ENABLE_PARTITION_METADATA_MANAGER =
         "pinot.broker.enable.partition.metadata.manager";
@@ -1075,5 +1075,12 @@ public class CommonConstants {
     public static final BigDecimal BIG_DECIMAL = BigDecimal.ZERO;
     public static final String STRING = "";
     public static final byte[] BYTES = new byte[0];
+    public static final ByteArray INTERNAL_BYTES = new ByteArray(BYTES);
+    public static final int[] INT_ARRAY = new int[0];
+    public static final long[] LONG_ARRAY = new long[0];
+    public static final float[] FLOAT_ARRAY = new float[0];
+    public static final double[] DOUBLE_ARRAY = new double[0];
+    public static final String[] STRING_ARRAY = new String[0];
+    public static final byte[][] BYTES_ARRAY = new byte[0][];
   }
 }


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


Reply via email to