Skip to content

Commit

Permalink
fix greatest/least function non-vectorized processing to ignore null …
Browse files Browse the repository at this point in the history
…argument types (#16649)
  • Loading branch information
clintropolis authored Jun 26, 2024
1 parent ab76d85 commit d4f2636
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -622,11 +622,10 @@ public ExprEval apply(List<Expr> args, Expr.ObjectBinding bindings)
ExprEval<?> exprEval = expr.eval(bindings);
ExpressionType exprType = exprEval.type();

if (isValidType(exprType)) {
outputType = ExpressionTypeConversion.function(outputType, exprType);
}

if (exprEval.value() != null) {
if (isValidType(exprType)) {
outputType = ExpressionTypeConversion.function(outputType, exprType);
}
evals.add(exprEval);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ public void testGreatest()
assertExpr("greatest()", null);
assertExpr("greatest(null, null)", null);
assertExpr("greatest(1, null, 'A')", "A");
assertExpr("greatest(1.0, 1, null)", 1.0);
}

@Test
Expand All @@ -703,6 +704,7 @@ public void testLeast()
assertExpr("least()", null);
assertExpr("least(null, null)", null);
assertExpr("least(1, null, 'A')", "1");
assertExpr("least(1.0, 1, null)", 1.0);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public void testDecimal()
}

@Test
public void testDecimalWithNullShouldReturnString()
public void testDecimalWithNullShouldNotReturnString()
{
testExpression(
Arrays.asList(
Expand All @@ -227,7 +227,7 @@ public void testDecimalWithNullShouldReturnString()
null,
3.4
),
"3.4"
3.4
);
}
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public void testDecimal()
}

@Test
public void testDecimalWithNullShouldReturnString()
public void testDecimalWithNullShouldNotReturnString()
{
testExpression(
Arrays.asList(
Expand All @@ -227,7 +227,7 @@ public void testDecimalWithNullShouldReturnString()
3.4,
null
),
"1.2"
1.2
);
}

Expand Down

0 comments on commit d4f2636

Please sign in to comment.