Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect IsNull predicate for row of nulls #20209

Closed
wants to merge 1 commit into from
Closed
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 @@ -439,6 +439,15 @@ protected Object visitIsNullPredicate(IsNullPredicate node, Object context)
return new IsNullPredicate(toExpression(value, type(node.getValue())));
}

if (value instanceof SqlRow sqlRow) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also needs to be fixed in the code generator (io.trino.sql.gen.IsNullCodeGenerator) and IrExpressionInterpreter, and for IsNotNullPredicate in all places.

for (int i = 0; i < sqlRow.getRawFieldBlocks().size(); i++) {
if (!sqlRow.getRawFieldBlock(i).isNull(0)) {
return false;
}
}
return true;
}

return value == null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ public void testIsNull()
assertOptimizedEquals("9876543210.9874561203 IS NULL", "false");
assertOptimizedEquals("bound_decimal_short IS NULL", "false");
assertOptimizedEquals("bound_decimal_long IS NULL", "false");

assertOptimizedEquals("(null, 1) is null", "false");
assertOptimizedEquals("(1) is null", "false");
assertOptimizedEquals("(null, null) is null", "true");
assertOptimizedEquals("(null) is null", "true");
}

@Test
Expand Down
Loading