13
13
// limitations under the License.
14
14
15
15
use common_expression:: types:: boolean:: BooleanDomain ;
16
+ use common_expression:: types:: nullable:: NullableDomain ;
16
17
use common_expression:: types:: BooleanType ;
17
18
use common_expression:: types:: NullableType ;
18
19
use common_expression:: vectorize_2_arg;
@@ -73,7 +74,20 @@ pub fn register(registry: &mut FunctionRegistry) {
73
74
registry. register_2_arg_core :: < NullableType < BooleanType > , NullableType < BooleanType > , NullableType < BooleanType > , _ , _ > (
74
75
"and" ,
75
76
FunctionProperty :: default ( ) ,
76
- |_, _| {
77
+ |lhs, rhs| {
78
+ if !lhs. has_null && !rhs. has_null {
79
+ let bools = match ( & lhs. value , & rhs. value ) {
80
+ ( Some ( a) , Some ( b) ) => Some ( Box :: new ( BooleanDomain {
81
+ has_false : a. has_false || b. has_false ,
82
+ has_true : a. has_true && b. has_true ,
83
+ } ) ) ,
84
+ _ => None ,
85
+ } ;
86
+ return Some ( NullableDomain :: < BooleanType > {
87
+ has_null : false ,
88
+ value : bools,
89
+ } ) ;
90
+ }
77
91
None
78
92
} ,
79
93
vectorize_2_arg :: < NullableType < BooleanType > , NullableType < BooleanType > , NullableType < BooleanType > > ( |lhs, rhs| {
@@ -91,7 +105,20 @@ pub fn register(registry: &mut FunctionRegistry) {
91
105
registry. register_2_arg_core :: < NullableType < BooleanType > , NullableType < BooleanType > , NullableType < BooleanType > , _ , _ > (
92
106
"or" ,
93
107
FunctionProperty :: default ( ) ,
94
- |_, _| {
108
+ |lhs, rhs| {
109
+ if !lhs. has_null && !rhs. has_null {
110
+ let bools = match ( & lhs. value , & rhs. value ) {
111
+ ( Some ( a) , Some ( b) ) => Some ( Box :: new ( BooleanDomain {
112
+ has_false : a. has_false && b. has_false ,
113
+ has_true : a. has_true || b. has_true ,
114
+ } ) ) ,
115
+ _ => None ,
116
+ } ;
117
+ return Some ( NullableDomain :: < BooleanType > {
118
+ has_null : false ,
119
+ value : bools,
120
+ } ) ;
121
+ }
95
122
None
96
123
} ,
97
124
vectorize_2_arg :: < NullableType < BooleanType > , NullableType < BooleanType > , NullableType < BooleanType > > ( |lhs, rhs| {
0 commit comments