File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
datafusion/physical-expr/src/coercion_rule Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ pub(crate) fn coerce_types(
56
56
Operator :: Plus | Operator :: Minus => {
57
57
mathematics_numerical_coercion ( op, lhs_type, rhs_type)
58
58
. or_else ( || interval_coercion ( op, lhs_type, rhs_type) )
59
+ . or_else ( || date_coercion ( op, lhs_type, rhs_type) )
59
60
}
60
61
// Same as Plus & Minus
61
62
Operator :: Modulo | Operator :: Divide | Operator :: Multiply => {
@@ -591,6 +592,25 @@ pub fn interval_coercion(
591
592
}
592
593
}
593
594
595
+ /// Coercion rule for dates
596
+ pub fn date_coercion (
597
+ op : & Operator ,
598
+ lhs_type : & DataType ,
599
+ rhs_type : & DataType ,
600
+ ) -> Option < DataType > {
601
+ use arrow:: datatypes:: DataType :: * ;
602
+
603
+ // these are ordered from most informative to least informative so
604
+ // that the coercion removes the least amount of information
605
+ match op {
606
+ Operator :: Minus => match ( lhs_type, rhs_type) {
607
+ ( Date32 , Date32 ) => Some ( Int32 ) ,
608
+ _ => None ,
609
+ } ,
610
+ _ => None ,
611
+ }
612
+ }
613
+
594
614
/// coercion rules from NULL type. Since NULL can be casted to most of types in arrow,
595
615
/// either lhs or rhs is NULL, if NULL can be casted to type of the other side, the coecion is valid.
596
616
fn null_coercion ( lhs_type : & DataType , rhs_type : & DataType ) -> Option < DataType > {
You can’t perform that action at this time.
0 commit comments