Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ public static Block blockArrayMax(
return null;
}

if (block.isNull(0)) {
return null;
}

Block selectedValue = (Block) elementType.getObject(block, 0);
for (int i = 0; i < block.getPositionCount(); i++) {
for (int i = 1; i < block.getPositionCount(); i++) {
if (block.isNull(i)) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ public static Block blockArrayMin(
return null;
}

if (block.isNull(0)) {
return null;
}

Block selectedValue = (Block) elementType.getObject(block, 0);
for (int i = 0; i < block.getPositionCount(); i++) {
for (int i = 1; i < block.getPositionCount(); i++) {
if (block.isNull(i)) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,30 @@ public void testArrayMin()
assertDecimalFunction("ARRAY_MIN(ARRAY [2.22222222222222222, 2.3])", decimal("2.22222222222222222"));
}

@Test
public void testArrayMinWithNullsInBothArraysNotComparedFirstIsMin()
{
assertFunction("ARRAY_MIN(ARRAY [ARRAY[1, NULL], ARRAY[2, NULL]])", new ArrayType(INTEGER), Lists.newArrayList(1, null));
}

@Test
public void testArrayMinWithNullsInBothArraysNotComparedSecondIsMin()
{
assertFunction("ARRAY_MIN(ARRAY [ARRAY[2, NULL], ARRAY[1, NULL]])", new ArrayType(INTEGER), Lists.newArrayList(1, null));
}

@Test
public void testArrayMinWithNullInFirstArrayIsCompared()
{
assertInvalidFunction("ARRAY_MIN(ARRAY [ARRAY[1, NULL], ARRAY[1, 2]])", NOT_SUPPORTED);
}

@Test
public void testArrayMinWithNullInSecondArrayIsCompared()
{
assertInvalidFunction("ARRAY_MIN(ARRAY [ARRAY[1, 2], ARRAY[1, NULL]])", NOT_SUPPORTED);
}

@Test
public void testArrayMax()
{
Expand Down Expand Up @@ -726,6 +750,30 @@ public void testArrayMax()
assertDecimalFunction("ARRAY_MAX(ARRAY [2.22222222222222222, 2.3])", decimal("2.30000000000000000"));
}

@Test
public void testArrayMaxWithNullsInBothArraysNotComparedSecondIsMax()
{
assertFunction("ARRAY_MAX(ARRAY [ARRAY[1, NULL], ARRAY[2, NULL]])", new ArrayType(INTEGER), Lists.newArrayList(2, null));
}

@Test
public void testArrayMaxWithNullsInBothArraysNotComparedFirstIsMax()
{
assertFunction("ARRAY_MAX(ARRAY [ARRAY[2, NULL], ARRAY[1, NULL]])", new ArrayType(INTEGER), Lists.newArrayList(2, null));
}

@Test
public void testArrayMaxWithNullInFirstArrayIsCompared()
{
assertInvalidFunction("ARRAY_MAX(ARRAY [ARRAY[1, NULL], ARRAY[1, 2]])", NOT_SUPPORTED);
}

@Test
public void testArrayMaxWithNullInSecondArrayIsCompared()
{
assertInvalidFunction("ARRAY_MAX(ARRAY [ARRAY[1, 2], ARRAY[1, NULL]])", NOT_SUPPORTED);
}

@Test
public void testArrayPosition()
{
Expand Down