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/09 13:06:10 UTC

[GitHub] [arrow-datafusion] retikulum opened a new pull request, #4154: Improve error messages while downcasting Int64Array

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

   # 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 new PR of improving downcasting of `Int64Array`.
   # 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_int64_array` function is implemented in `datafusion\common\src\cast.rs`
   - Refactor necessary parts
   
   # 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 merged pull request #4154: Improve error messages while downcasting Int64Array

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


-- 
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] viirya commented on a diff in pull request #4154: Improve error messages while downcasting Int64Array

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


##########
datafusion/core/tests/user_defined_plan.rs:
##########
@@ -551,11 +552,7 @@ fn accumulate_batch(
         .downcast_ref::<StringArray>()
         .expect("Column 0 is not customer_id");
 
-    let revenue = input_batch
-        .column(1)
-        .as_any()
-        .downcast_ref::<Int64Array>()
-        .expect("Column 1 is not revenue");
+    let revenue = as_int64_array(input_batch.column(1)).unwrap();

Review Comment:
   As this is test code, I think if the test data is correct, it must return a Int64Array for column 1. `Column 1 is not revenue` as error message, I think its purpose is to indicate that.
   
   Both (previous and this PR) are fine. I'd keep it but it looks okay too for this change.



-- 
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 #4154: Improve error messages while downcasting Int64Array

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


##########
datafusion/core/tests/user_defined_plan.rs:
##########
@@ -551,11 +552,7 @@ fn accumulate_batch(
         .downcast_ref::<StringArray>()
         .expect("Column 0 is not customer_id");
 
-    let revenue = input_batch
-        .column(1)
-        .as_any()
-        .downcast_ref::<Int64Array>()
-        .expect("Column 1 is not revenue");
+    let revenue = as_int64_array(input_batch.column(1)).unwrap();

Review Comment:
   Yeah I agree with @viirya  



-- 
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 #4154: Improve error messages while downcasting Int64Array

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

   Benchmark runs are scheduled for baseline = 8f67d055be23493cc449b7b75c7e6beac6b85aef and contender = da76feba5ee27cdc31f602d04280ba6673be36f0. da76feba5ee27cdc31f602d04280ba6673be36f0 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/48e80e1b849e4c7fbddc33c0682c5c7f...df7c437cf79b44cfb86d08c278ad2dbb/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/2a19171c47b645d9afcee3e7e930c8a2...ea4349cfb894450a93f11fa7cdc4a5e6/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/29375de016aa435bb2b1c830ec706ae6...bdf26be357e342c19e9af906d8a764cc/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/45eb62d87a544c96872057d9144a01a0...e16b8f6ecc06430d9997443187b1c0ff/)
   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


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #4154: Improve error messages while downcasting Int64Array

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


##########
datafusion/core/tests/user_defined_plan.rs:
##########
@@ -551,11 +552,7 @@ fn accumulate_batch(
         .downcast_ref::<StringArray>()
         .expect("Column 0 is not customer_id");
 
-    let revenue = input_batch
-        .column(1)
-        .as_any()
-        .downcast_ref::<Int64Array>()
-        .expect("Column 1 is not revenue");
+    let revenue = as_int64_array(input_batch.column(1)).unwrap();

Review Comment:
   Yeah I agree with @viirya that keeping specific messages in `expect(..)` is preferred to `unwrap()` but given this is test code that shouldn't be erroring anyways I think it is fine for this PR



##########
datafusion/core/src/datasource/file_format/json.rs:
##########
@@ -228,11 +228,7 @@ mod tests {
         assert_eq!(1, batches[0].num_columns());
         assert_eq!(12, batches[0].num_rows());
 
-        let array = batches[0]
-            .column(0)
-            .as_any()
-            .downcast_ref::<Int64Array>()
-            .unwrap();
+        let array = as_int64_array(batches[0].column(0))?;

Review Comment:
   this is so much nicer



-- 
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] viirya commented on a diff in pull request #4154: Improve error messages while downcasting Int64Array

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


##########
datafusion/core/tests/user_defined_plan.rs:
##########
@@ -551,11 +552,7 @@ fn accumulate_batch(
         .downcast_ref::<StringArray>()
         .expect("Column 0 is not customer_id");
 
-    let revenue = input_batch
-        .column(1)
-        .as_any()
-        .downcast_ref::<Int64Array>()
-        .expect("Column 1 is not revenue");
+    let revenue = as_int64_array(input_batch.column(1)).unwrap();

Review Comment:
   I think that you can still keep `.expect("Column 1 is not revenue");`?



-- 
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] retikulum commented on a diff in pull request #4154: Improve error messages while downcasting Int64Array

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


##########
datafusion/core/tests/user_defined_plan.rs:
##########
@@ -551,11 +552,7 @@ fn accumulate_batch(
         .downcast_ref::<StringArray>()
         .expect("Column 0 is not customer_id");
 
-    let revenue = input_batch
-        .column(1)
-        .as_any()
-        .downcast_ref::<Int64Array>()
-        .expect("Column 1 is not revenue");
+    let revenue = as_int64_array(input_batch.column(1)).unwrap();

Review Comment:
   I agree but I am not sure if we will give specific error to user. If it is the preferred way, I will change it



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