Skip to content

Commit 7d2d51b

Browse files
authored
Compare NULL types (apache#5158)
1 parent e41c4df commit 7d2d51b

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

datafusion/core/tests/sqllogictests/test_files/pg_compat/pg_compat_type_coercion.slt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,17 @@ select pg_typeof(false or true), pg_typeof(true or false);
9595
bool bool
9696

9797

98-
# TODO: run for DataFusion as well after #4335
99-
onlyif postgres
10098
query ??
10199
select null and null, null or null;
102100
----
103101
NULL NULL
104102

105103

106-
# TODO: uncomment after #4335
107-
#onlyif DataFusion
108-
#query ??
109-
#select arrow_typeof(null and null), arrow_typeof(null or null);
110-
#----
111-
#Boolean Boolean
104+
onlyif DataFusion
105+
query ??
106+
select arrow_typeof(null and null), arrow_typeof(null or null);
107+
----
108+
Boolean Boolean
112109

113110

114111
onlyif postgres

datafusion/expr/src/type_coercion/binary.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub fn coerce_types(
100100
Operator::And | Operator::Or => match (lhs_type, rhs_type) {
101101
// logical binary boolean operators can only be evaluated in bools or nulls
102102
(DataType::Boolean, DataType::Boolean) => Some(DataType::Boolean),
103-
(DataType::Null, DataType::Null) => Some(DataType::Null),
103+
(DataType::Null, DataType::Null) => Some(DataType::Boolean),
104104
(DataType::Boolean, DataType::Null) | (DataType::Null, DataType::Boolean) => {
105105
Some(DataType::Boolean)
106106
}
@@ -1144,13 +1144,13 @@ mod tests {
11441144
DataType::Null,
11451145
DataType::Null,
11461146
Operator::Or,
1147-
DataType::Null
1147+
DataType::Boolean
11481148
);
11491149
test_coercion_binary_rule!(
11501150
DataType::Null,
11511151
DataType::Null,
11521152
Operator::And,
1153-
DataType::Null
1153+
DataType::Boolean
11541154
);
11551155
test_coercion_binary_rule!(
11561156
DataType::Null,

0 commit comments

Comments
 (0)