Make codes more readable.
@@ -115,13 +115,11 @@ pub fn register(registry: &mut FunctionRegistry) {
},
// value = lhs & rhs, valid = (lhs_v & rhs_v) | (!lhs & lhs_v) | (!rhs & rhs_v))
vectorize_2_arg::<NullableType<BooleanType>, NullableType<BooleanType>, NullableType<BooleanType>>(|lhs, rhs, _| {
- let lhs_v = lhs.is_some();
- let rhs_v = rhs.is_some();
- let valid = (lhs_v & rhs_v) | (lhs == Some(false)) | (rhs == Some(false));
- if valid {
- Some(lhs.unwrap_or_default() & rhs.unwrap_or_default())
- } else {
- None
+ match (lhs, rhs) {
+ (Some(false), _) => Some(false),
+ (_, Some(false)) => Some(false),
+ (Some(true), Some(true)) => Some(true),
+ _ => None
}
}),
);
@@ -147,13 +145,11 @@ pub fn register(registry: &mut FunctionRegistry) {
},
// value = lhs | rhs, valid = (lhs_v & rhs_v) | (lhs_v & lhs) | (rhs_v & rhs)
vectorize_2_arg::<NullableType<BooleanType>, NullableType<BooleanType>, NullableType<BooleanType>>(|lhs, rhs, _| {
- let lhs_v = lhs.is_some();
- let rhs_v = rhs.is_some();
- let valid = (lhs_v & rhs_v) | (lhs_v & lhs.unwrap_or_default()) | (rhs_v & rhs.unwrap_or_default());
- if valid {
- Some(lhs.unwrap_or_default() | rhs.unwrap_or_default())
- } else {
- None
+ match (lhs, rhs) {
+ (Some(true), _) => Some(true),
+ (_, Some(true)) => Some(true),
+ (Some(false), Some(false)) => Some(false),
+ _ => None
}
}),
);
