You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "Omega359 (via GitHub)" <gi...@apache.org> on 2024/03/13 16:49:58 UTC

[PR] Move make_date, to_char to datafusion-functions [arrow-datafusion]

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

   ## 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.
   -->
   
   Closes #9538
   
   ## 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.  
   -->
   
   Function migration to new crate
   
   ## 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.
   -->
   
   Code, tests
   
   ## Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   Yes
   
   ## Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   No.
   <!--
   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


Re: [PR] Move make_date, to_char to datafusion-functions [arrow-datafusion]

Posted by "Omega359 (via GitHub)" <gi...@apache.org>.
Omega359 commented on code in PR #9601:
URL: https://github.com/apache/arrow-datafusion/pull/9601#discussion_r1524734771


##########
datafusion/functions/benches/to_char.rs:
##########
@@ -42,8 +38,8 @@ fn random_date_in_range(
     start_date + TimeDelta::try_days(random_days).unwrap()
 }
 
-fn data(rng: &mut ThreadRng) -> Date32Array {
-    let mut data: Vec<i32> = vec![];
+fn data(rng: &mut ThreadRng) -> Vec<Expr> {

Review Comment:
   The numbers looked amazing though :)



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


Re: [PR] Move make_date, to_char to datafusion-functions [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #9601:
URL: https://github.com/apache/arrow-datafusion/pull/9601#discussion_r1524588400


##########
datafusion/functions/benches/to_char.rs:
##########
@@ -17,20 +17,16 @@
 
 extern crate criterion;
 
-use std::sync::Arc;
-
-use arrow_array::{ArrayRef, Date32Array, StringArray};
 use chrono::prelude::*;
 use chrono::TimeDelta;
 use criterion::{black_box, criterion_group, criterion_main, Criterion};
 use rand::rngs::ThreadRng;
 use rand::seq::SliceRandom;
 use rand::Rng;
 
-use datafusion_common::ScalarValue;
 use datafusion_common::ScalarValue::TimestampNanosecond;
-use datafusion_expr::ColumnarValue;
-use datafusion_physical_expr::datetime_expressions::to_char;
+use datafusion_expr::{lit, Expr};
+use datafusion_functions::expr_fn::to_char;

Review Comment:
   I think this is the wrong function to be benchmarking -- it should be the implementation (not the expr_fn)



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


Re: [PR] Move make_date, to_char to datafusion-functions [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #9601:
URL: https://github.com/apache/arrow-datafusion/pull/9601#discussion_r1523677491


##########
datafusion/functions/benches/to_char.rs:
##########
@@ -42,8 +38,8 @@ fn random_date_in_range(
     start_date + TimeDelta::try_days(random_days).unwrap()
 }
 
-fn data(rng: &mut ThreadRng) -> Date32Array {
-    let mut data: Vec<i32> = vec![];
+fn data(rng: &mut ThreadRng) -> Vec<Expr> {

Review Comment:
   doesn't this change the meaning of the benchmark from testing to_char on a single array to testing to_char on a single row with 1000's of arguments?
   
   Like `to_date(v1, v2, v3, .....)`
   
   instead of `to_date(arr)` ?
   
   Is that intentional?



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


Re: [PR] Move make_date, to_char to datafusion-functions [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #9601:
URL: https://github.com/apache/arrow-datafusion/pull/9601#discussion_r1524587434


##########
datafusion/functions/benches/to_char.rs:
##########
@@ -42,8 +38,8 @@ fn random_date_in_range(
     start_date + TimeDelta::try_days(random_days).unwrap()
 }
 
-fn data(rng: &mut ThreadRng) -> Date32Array {
-    let mut data: Vec<i32> = vec![];
+fn data(rng: &mut ThreadRng) -> Vec<Expr> {

Review Comment:
   Right, but then the benchmark is simply testing how fast the `to_char` expr_fn function is creating a `Expr::Function` call (but not actually evaluting the expression)
   
   ```rust
   data.iter().enumerate().for_each(|(idx, i)| {
      black_box(to_char(i.clone(), patterns.get(idx).unwrap().clone())); 
   })
   ```



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


Re: [PR] Move make_date, to_char to datafusion-functions [arrow-datafusion]

Posted by "Omega359 (via GitHub)" <gi...@apache.org>.
Omega359 commented on code in PR #9601:
URL: https://github.com/apache/arrow-datafusion/pull/9601#discussion_r1524893610


##########
datafusion/functions/benches/to_char.rs:
##########
@@ -42,8 +38,8 @@ fn random_date_in_range(
     start_date + TimeDelta::try_days(random_days).unwrap()
 }
 
-fn data(rng: &mut ThreadRng) -> Date32Array {
-    let mut data: Vec<i32> = vec![];
+fn data(rng: &mut ThreadRng) -> Vec<Expr> {

Review Comment:
   Fixed.



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


Re: [PR] Move make_date, to_char to datafusion-functions [arrow-datafusion]

Posted by "Omega359 (via GitHub)" <gi...@apache.org>.
Omega359 commented on code in PR #9601:
URL: https://github.com/apache/arrow-datafusion/pull/9601#discussion_r1523886133


##########
datafusion/functions/benches/to_char.rs:
##########
@@ -42,8 +38,8 @@ fn random_date_in_range(
     start_date + TimeDelta::try_days(random_days).unwrap()
 }
 
-fn data(rng: &mut ThreadRng) -> Date32Array {
-    let mut data: Vec<i32> = vec![];
+fn data(rng: &mut ThreadRng) -> Vec<Expr> {

Review Comment:
   The benchmark functions iterate on the data and patterns so that shouldn't be the case. 
   ```
           let data = data(&mut rng);
           let patterns = patterns(&mut rng);
   
           b.iter(|| {
               data.iter().enumerate().for_each(|(idx, i)| {
                   black_box(to_char(i.clone(), patterns.get(idx).unwrap().clone()));
               })
           })
   ```        



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


Re: [PR] Move make_date, to_char to datafusion-functions [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #9601:
URL: https://github.com/apache/arrow-datafusion/pull/9601


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