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

gortiz 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 3185e303f4 Improved null check for varargs (#12673)
3185e303f4 is described below

commit 3185e303f42e02bf3df80c7ddf16360e0fe2b197
Author: soumitra-st <127247229+soumitra...@users.noreply.github.com>
AuthorDate: Mon Apr 1 01:44:50 2024 -0700

    Improved null check for varargs (#12673)
    
    * Improved null check for varargs
    
    * Fixed the null check for varargs to not check the null inside the array
    
    * Filter out null values from varargs
---
 .../src/main/java/org/apache/pinot/client/BrokerCache.java          | 6 +++++-
 .../org/apache/pinot/common/function/scalar/ArrayFunctions.java     | 2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git 
a/pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/BrokerCache.java
 
b/pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/BrokerCache.java
index 759dd32084..6742174582 100644
--- 
a/pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/BrokerCache.java
+++ 
b/pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/BrokerCache.java
@@ -28,6 +28,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Properties;
 import java.util.Random;
 import java.util.Set;
@@ -190,7 +191,10 @@ public class BrokerCache {
 
   public String getBroker(String... tableNames) {
     List<String> brokers = null;
-    if (tableNames != null) {
+    // If tableNames is not-null, filter out nulls
+    tableNames =
+        tableNames == null ? tableNames : 
Arrays.stream(tableNames).filter(Objects::nonNull).toArray(String[]::new);
+    if (!(tableNames == null || tableNames.length == 0)) {
        // returning list of common brokers hosting all the tables.
        brokers = 
BrokerSelectorUtils.getTablesCommonBrokers(Arrays.asList(tableNames),
            _brokerData.getTableToBrokerMap());
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 32f115b51a..53e6bc76c2 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
@@ -230,7 +230,7 @@ public class ArrayFunctions {
 
   @ScalarFunction(names = {"array", "arrayValueConstructor"}, isVarArg = true)
   public static Object arrayValueConstructor(Object... arr) {
-    if (arr.length == 0) {
+    if (arr == null || arr.length == 0) {
       return arr;
     }
     Class<?> clazz = arr[0].getClass();


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to