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/11/01 16:56:42 UTC

[GitHub] [arrow-datafusion] retikulum opened a new pull request, #4061: Improve Error Handling and Readibility for downcasting `StructArray`

retikulum opened a new pull request, #4061:
URL: https://github.com/apache/arrow-datafusion/pull/4061

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Part of #3152.
   
   # Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   It is very clear in the issue but there are different schemas while downcasting an ArrayRef to a related arrow array type. This is the second PR of improving downcasting of `StructArray`.
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   - `as_struct_array` function is implemented in `datafusion\common\src\cast.rs`
   - Refactor necessary parts
   - Passed related test
   
   # Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   I don't think so.
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->


-- 
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


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #4061: Improve Error Handling and Readibility for downcasting `StructArray`

Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #4061:
URL: https://github.com/apache/arrow-datafusion/pull/4061#discussion_r1012028046


##########
datafusion/common/src/cast.rs:
##########
@@ -32,3 +32,13 @@ pub fn as_date32_array(array: &dyn Array) -> Result<&Date32Array, DataFusionErro
         ))
     })
 }
+
+// Downcast ArrayRef to Date32Array

Review Comment:
   ```suggestion
   // Downcast ArrayRef to StructArray
   ```



##########
benchmarks/src/tpch.rs:
##########
@@ -439,7 +439,10 @@ fn col_to_scalar(column: &ArrayRef, row_index: usize) -> ScalarValue {
             ScalarValue::Decimal128(Some(array.value(row_index)), *p, *s)
         }
         DataType::Date32 => {
-            let array = column.as_any().downcast_ref::<Date32Array>().unwrap();
+            let array = match as_date32_array(column) {
+                Ok(array) => array,
+                Err(e) => panic!("{}", e),
+            };

Review Comment:
   I think `unwrap` will also print the error message if called on an error:
   
   https://doc.rust-lang.org/std/result/enum.Result.html#panics-1
   
   > Panics if the value is an [Err](https://doc.rust-lang.org/std/result/enum.Result.html#variant.Err), with a panic message provided by the [Err](https://doc.rust-lang.org/std/result/enum.Result.html#variant.Err)’s value.
   
   
   ```suggestion
               let array = as_date32_array(column).unwrap();
   ```



##########
datafusion/common/src/scalar.rs:
##########
@@ -3611,7 +3604,10 @@ mod tests {
         // iter_to_array for struct scalars
         let array =
             ScalarValue::iter_to_array(vec![s0.clone(), s1.clone(), s2.clone()]).unwrap();
-        let array = array.as_any().downcast_ref::<StructArray>().unwrap();
+        let array = match as_struct_array(&array) {

Review Comment:
   see comment above



-- 
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


[GitHub] [arrow-datafusion] alamb merged pull request #4061: Improve Error Handling and Readibility for downcasting `StructArray`

Posted by GitBox <gi...@apache.org>.
alamb merged PR #4061:
URL: https://github.com/apache/arrow-datafusion/pull/4061


-- 
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


[GitHub] [arrow-datafusion] alamb commented on pull request #4061: Improve Error Handling and Readibility for downcasting `StructArray`

Posted by GitBox <gi...@apache.org>.
alamb commented on PR #4061:
URL: https://github.com/apache/arrow-datafusion/pull/4061#issuecomment-1302099693

   👍 Thanks again @retikulum 


-- 
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


[GitHub] [arrow-datafusion] ursabot commented on pull request #4061: Improve Error Handling and Readibility for downcasting `StructArray`

Posted by GitBox <gi...@apache.org>.
ursabot commented on PR #4061:
URL: https://github.com/apache/arrow-datafusion/pull/4061#issuecomment-1302109257

   Benchmark runs are scheduled for baseline = 61429f839eb07bf50f36147d5b1d065194a45114 and contender = 761e1671bd3c4988d21a38bb19e50bdac6cfaa61. 761e1671bd3c4988d21a38bb19e50bdac6cfaa61 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/c0ee28eb79324e82bf127aa8ae88e5ff...0d59a413a5d04edf83522562074aa29d/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/1247a805256b44c8a38a275c46e5519f...255e82fe6d1e495f8915941159a1d998/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/1f17037563224a41a00a38370fbf068e...b08ff4172b544543a14871abd9cae03a/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/96a0e6e609b04ad695719cbd7812119e...72338562f8d749c29bdb7be7a6d5c3ad/)
   Buildkite builds:
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
   test-mac-arm: Supported benchmark langs: C++, Python, R
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
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