github-code-scanning[bot] commented on code in PR #14249:
URL: https://github.com/apache/druid/pull/14249#discussion_r1190314822


##########
sql/src/main/java/org/apache/druid/sql/calcite/expression/OperatorConversions.java:
##########
@@ -522,34 +546,53 @@
     /**
      * Creates a {@link SqlFunction} from this builder.
      */
-    public SqlFunction build()
+    @SuppressWarnings("unchecked")
+    public T build()
+    {
+      final IntSet nullableOperands = buildNullableOperands();
+      return (T) new SqlFunction(
+          name,
+          kind,
+          Preconditions.checkNotNull(returnTypeInference, 
"returnTypeInference"),
+          buildOperandTypeInference(nullableOperands),
+          buildOperandTypeChecker(nullableOperands),
+          functionCategory
+      );
+    }
+
+    protected IntSet buildNullableOperands()
     {
       // Create "nullableOperands" set including all optional arguments.
       final IntSet nullableOperands = new IntArraySet();
-      if (requiredOperands != null) {
-        IntStream.range(requiredOperands, 
operandTypes.size()).forEach(nullableOperands::add);
+      if (requiredOperandCount != null) {
+        IntStream.range(requiredOperandCount, 
operandTypes.size()).forEach(nullableOperands::add);
       }
+      return nullableOperands;
+    }
 
-      final SqlOperandTypeChecker theOperandTypeChecker;
-
+    protected SqlOperandTypeChecker buildOperandTypeChecker(final IntSet 
nullableOperands)
+    {
       if (operandTypeChecker == null) {
-        theOperandTypeChecker = new DefaultOperandTypeChecker(
+        return new DefaultOperandTypeChecker(
             operandTypes,
-            requiredOperands == null ? operandTypes.size() : requiredOperands,
+            requiredOperandCount == null ? operandTypes.size() : 
requiredOperandCount,

Review Comment:
   ## Dereferenced variable may be null
   
   Variable [operandTypes](1) may be null at this access as suggested by 
[this](2) null guard.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/4944)



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