Repository navigation
CaseWhen: coerce the all then and else data type to a common data type - #2819
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2819 +/- ##
==========================================
+ Coverage 85.18% 85.19% +0.01%
==========================================
Files 275 275
Lines 48564 48634 +70
==========================================
+ Hits 41367 41434 +67
- Misses 7197 7200 +3
Continue to review full report at Codecov.
|
50fd76b to
00edadf
Compare
alamb
left a comment
There was a problem hiding this comment.
Looks good to me -- I had some style suggestions but nothing major. Thank you @liukun4515
| pub fn try_new( | ||
| expr: Option<Arc<dyn PhysicalExpr>>, | ||
| when_then_expr: &[WhenThen], | ||
| when_then_expr: Vec<WhenThen>, |
|
|
||
| fn get_case_common_type( | ||
| when_thens: &[WhenThen], | ||
| else_expr: Option<Arc<dyn PhysicalExpr>>, |
There was a problem hiding this comment.
| else_expr: Option<Arc<dyn PhysicalExpr>>, | |
| else_expr: Option<&PhysicalExpr>, |
I wonder if there is a reason it needs to get a copy, or would a reference work too?
There was a problem hiding this comment.
The reference is not work for this.
| let left = when_thens | ||
| .into_iter() | ||
| .map(|(when, then)| { | ||
| let then = try_cast(then, input_schema, data_type.clone()).unwrap(); | ||
| (when, then) | ||
| }) | ||
| .collect::<Vec<WhenThen>>(); |
There was a problem hiding this comment.
Are we sure this will always return without error (aka that this will not panic)?
Since this function can return an Result anyways, would it be better to return it. Something like (untested):
| let left = when_thens | |
| .into_iter() | |
| .map(|(when, then)| { | |
| let then = try_cast(then, input_schema, data_type.clone()).unwrap(); | |
| (when, then) | |
| }) | |
| .collect::<Vec<WhenThen>>(); | |
| let left = when_thens | |
| .into_iter() | |
| .map(|(when, then)| { | |
| let then = try_cast(then, input_schema, data_type.clone())? | |
| Ok((when, then)) | |
| }) | |
| .collect::<Result<Vec<WhenThen>>>()?; |
| let when1 = binary( | ||
| col("a", &schema)?, | ||
| Operator::Eq, | ||
| lit(ScalarValue::Utf8(Some("foo".to_string()))), |
There was a problem hiding this comment.
It would be nice if the the lit in the physical expr could use lit("foo") as well. But I tried it and it doesn't work
| lit(ScalarValue::Utf8(Some("foo".to_string()))), | |
| lit("foo"), |
There was a problem hiding this comment.
I will rebase this pr after #2828 merged
There was a problem hiding this comment.
changed the code to use lit("foo") with merged #2828
00b0c39 to
d50c671
Compare
|
I accidentally pushed commits to this branch -- I think I have removed them now. My apologies |
Which issue does this PR close?
Closes #2818
Rationale for this change
What changes are included in this PR?
Are there any user-facing changes?