-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: casting Int64 to Float64 unsuccessfully caused tpch8 to fail #1601
Conversation
TPCH 8
TPCH 14
|
One problem with this modification is that I checked Postgres' behavior, it can process reasonably. postgres=# SELECT * FROM test;
a
---
1
2
3
(3 rows)
postgres=# SELECT a,
CASE WHEN a=1 THEN 1.2
ELSE 0
END
FROM test;
a | case
---+------
1 | 1.2
2 | 0
3 | 0
(3 rows)
postgres=# SELECT a,
CASE WHEN a=1 THEN 12
ELSE 5.4
END
FROM test;
a | case
---+------
1 | 12
2 | 5.4
3 | 5.4
(3 rows) |
I agree, better to take both branches into account. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job unlocking more TPCH queries!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @xudong963 !
@@ -324,7 +325,10 @@ impl CaseExpr { | |||
|
|||
// start with the else condition, or nulls | |||
let mut current_value: Option<ArrayRef> = if let Some(e) = &self.else_expr { | |||
Some(e.evaluate(batch)?.into_array(batch.num_rows())) | |||
// keep `else_expr`'s data type and return type consistent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually it would be great to separate out the coercion
logic into the `
/// Create a CASE expression
pub fn case(
expr: Option<Arc<dyn PhysicalExpr>>,
when_thens: &[WhenThen],
else_expr: Option<Arc<dyn PhysicalExpr>>,
) -> Result<Arc<dyn PhysicalExpr>> {
Ok(Arc::new(CaseExpr::try_new(expr, when_thens, else_expr)?))
}
function the way it is done with BinaryExpr
and binary_cast
But this is better than master so 👍
Next PR I'll do the thing and keep consistent with Postgres. cc @alamb |
Filed #1609 to track |
Which issue does this PR close?
Closes #1576 #165
Rationale for this change
What changes are included in this PR?
Are there any user-facing changes?