Skip to content

Commit

Permalink
Compare NULL types (apache#5158)
Browse files Browse the repository at this point in the history
  • Loading branch information
melgenek committed Feb 2, 2023
1 parent e41c4df commit 7d2d51b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,17 @@ select pg_typeof(false or true), pg_typeof(true or false);
bool bool


# TODO: run for DataFusion as well after #4335
onlyif postgres
query ??
select null and null, null or null;
----
NULL NULL


# TODO: uncomment after #4335
#onlyif DataFusion
#query ??
#select arrow_typeof(null and null), arrow_typeof(null or null);
#----
#Boolean Boolean
onlyif DataFusion
query ??
select arrow_typeof(null and null), arrow_typeof(null or null);
----
Boolean Boolean


onlyif postgres
Expand Down
6 changes: 3 additions & 3 deletions datafusion/expr/src/type_coercion/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub fn coerce_types(
Operator::And | Operator::Or => match (lhs_type, rhs_type) {
// logical binary boolean operators can only be evaluated in bools or nulls
(DataType::Boolean, DataType::Boolean) => Some(DataType::Boolean),
(DataType::Null, DataType::Null) => Some(DataType::Null),
(DataType::Null, DataType::Null) => Some(DataType::Boolean),
(DataType::Boolean, DataType::Null) | (DataType::Null, DataType::Boolean) => {
Some(DataType::Boolean)
}
Expand Down Expand Up @@ -1144,13 +1144,13 @@ mod tests {
DataType::Null,
DataType::Null,
Operator::Or,
DataType::Null
DataType::Boolean
);
test_coercion_binary_rule!(
DataType::Null,
DataType::Null,
Operator::And,
DataType::Null
DataType::Boolean
);
test_coercion_binary_rule!(
DataType::Null,
Expand Down

0 comments on commit 7d2d51b

Please sign in to comment.