You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/10/26 19:12:57 UTC
[GitHub] [arrow-datafusion] retikulum commented on issue #3152: Improve codebase readability and error messages by and consistently handle downcasting
retikulum commented on issue #3152:
URL: https://github.com/apache/arrow-datafusion/issues/3152#issuecomment-1292505183
Hi. While this issue is getting old, I might help but have some questions. . I will give `as_int32_array` as a generic example so you can think of those questions for all other types.
- In which file we should implement `as_int32_array` function? I have implemented it in `datafusion\common\src\lib.rs` but I am not quite sure about the architecture.
- Before opening pr, I want to be sure that this sample is implemented correctly. I added this function:
```rust
pub fn as_int32_array(array: &dyn Array) -> Result<&Int32Array> {
array.as_any().downcast_ref::<Int32Array>().ok_or(
DataFusionError::Execution(format!("Expected a Int32Array, got: {}", array.data_type()),
))
}
```
And change this:
https://github.com/apache/arrow-datafusion/blob/10e64dc013ba210ab1f6c2a3c02c66aef4a0e802/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs#L851-L854
To this:
```rust
let arg0 = as_int32_array(&args[0])?;
```
Is this the correct way? [`simplify_expressions::test_evaluator_udfs`](https://github.com/apache/arrow-datafusion/blob/10e64dc013ba210ab1f6c2a3c02c66aef4a0e802/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs#L976) test runs successfully after implementation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org