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/23 23:50:54 UTC

[GitHub] [arrow-datafusion] retikulum opened a new pull request, #4352: Improve error handling and add some more types for proper downcasting

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

   # 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.
   -->
   
   This is discussed in #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.  
   -->
   This is the new PR of improving error handling for downcasting. In #4261 we found out that there is a `downcast_value!` macro which also covers our casting functions. Implementing `as_xxx_array` function with `downcast_value!` is nearly decided for now for future PRs. 
   # 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.
   -->
   
   - Refactor previous casting functions.
   - Add some more types for downcasting.
   - I remove some macros and use my downcasting functions in [string_expression.rs](https://github.com/apache/arrow-datafusion/blob/master/datafusion/physical-expr/src/string_expressions.rs). Please review it carefully. I don't want to break crucial parts.


-- 
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 #4352: Improve error handling and add some more types for proper downcasting

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


##########
datafusion/common/src/scalar.rs:
##########
@@ -720,7 +722,7 @@ fn get_dict_value<K: ArrowDictionaryKeyType>(
     array: &ArrayRef,
     index: usize,
 ) -> (&ArrayRef, Option<usize>) {
-    let dict_array = as_dictionary_array::<K>(array);
+    let dict_array = as_dictionary_array::<K>(array).unwrap();

Review Comment:
   for other reviewers, the rationale here is that arrow cast kernels used previously panic internally if the type is incorrect -- the ones in DataFusion return an error instead



##########
datafusion/physical-expr/src/string_expressions.rs:
##########
@@ -50,43 +53,6 @@ macro_rules! downcast_string_arg {
     }};
 }
 
-macro_rules! downcast_primitive_array_arg {

Review Comment:
   I reviewed the changes in this module carefully and they look good to me -- thank you @retikulum 



##########
datafusion/physical-expr/src/aggregate/median.rs:
##########
@@ -102,12 +103,7 @@ macro_rules! median {
             return Ok(ScalarValue::Null);
         }
         let sorted = sort(&combined, None)?;
-        let array = sorted
-            .as_any()
-            .downcast_ref::<PrimitiveArray<$TY>>()
-            .ok_or(DataFusionError::Internal(
-                "median! macro failed to cast array to expected type".to_string(),
-            ))?;
+        let array = as_primitive_array::<$TY>(&sorted)?;

Review Comment:
   much nicer



##########
datafusion/core/tests/custom_sources.rs:
##########
@@ -162,18 +163,10 @@ impl ExecutionPlan for CustomExecutionPlan {
                     .map(|i| ColumnStatistics {
                         null_count: Some(batch.column(*i).null_count()),
                         min_value: Some(ScalarValue::Int32(aggregate::min(
-                            batch
-                                .column(*i)
-                                .as_any()
-                                .downcast_ref::<PrimitiveArray<Int32Type>>()
-                                .unwrap(),
+                            as_primitive_array::<Int32Type>(batch.column(*i)).unwrap(),

Review Comment:
   👍 



-- 
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 #4352: Improve error handling and add some more types for proper downcasting

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

   Benchmark runs are scheduled for baseline = 049690412cbdcc1dfba5ebd9e055985129cb8843 and contender = da54fa584c7c4e8069ca6aed51e7c1f0dffc807c. da54fa584c7c4e8069ca6aed51e7c1f0dffc807c 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/8c4649a6cc834069905c0f9b33e348a5...20a37d697d4942cc8e4c248879e45c7b/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/d01946810f3f4cdfaaed3a9bdf95bdcb...51d487d68c1b4a81988afc2dff09a709/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/3e79d49c85304652bf25784d734bd09e...d500c8eaccfa4c1b87be4c4d44fb3f12/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/ee13c2aca82044b486b5c2b61946bf14...3a31df66345b4aef97678b1b06efb5cc/)
   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 merged pull request #4352: Improve error handling and add some more types for proper downcasting

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


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