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/06/24 16:32:04 UTC

[GitHub] [arrow-datafusion] mkmik opened a new pull request, #2786: wip: Implement extract epoch

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

   # 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 #2785
   
    # 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.  
   -->
   
   # 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.
   -->
   
   # Are there any user-facing changes?
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   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 closed pull request #2786: wip: Implement extract epoch

Posted by GitBox <gi...@apache.org>.
alamb closed pull request #2786: wip: Implement extract epoch
URL: https://github.com/apache/arrow-datafusion/pull/2786


-- 
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 #2786: wip: Implement extract epoch

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

   This PR is more than 6 month old, so closing it down for now to clean up the PR list. Please reopen if this is a mistake and you plan to work on it more 


-- 
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] codecov-commenter commented on pull request #2786: wip: Implement extract epoch

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #2786:
URL: https://github.com/apache/arrow-datafusion/pull/2786#issuecomment-1165769582

   # [Codecov](https://codecov.io/gh/apache/arrow-datafusion/pull/2786?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#2786](https://codecov.io/gh/apache/arrow-datafusion/pull/2786?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (bec8956) into [master](https://codecov.io/gh/apache/arrow-datafusion/commit/11ae73755314b4f0565dbca8cd99e6f7678a0083?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (11ae737) will **decrease** coverage by `0.03%`.
   > The diff coverage is `0.00%`.
   
   ```diff
   @@            Coverage Diff             @@
   ##           master    #2786      +/-   ##
   ==========================================
   - Coverage   85.15%   85.11%   -0.04%     
   ==========================================
     Files         273      273              
     Lines       48076    48096      +20     
   ==========================================
     Hits        40938    40938              
   - Misses       7138     7158      +20     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/arrow-datafusion/pull/2786?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...tafusion/physical-expr/src/datetime\_expressions.rs](https://codecov.io/gh/apache/arrow-datafusion/pull/2786/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGF0YWZ1c2lvbi9waHlzaWNhbC1leHByL3NyYy9kYXRldGltZV9leHByZXNzaW9ucy5ycw==) | `69.39% <0.00%> (-8.52%)` | :arrow_down: |
   | [datafusion/core/src/physical\_plan/metrics/value.rs](https://codecov.io/gh/apache/arrow-datafusion/pull/2786/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGF0YWZ1c2lvbi9jb3JlL3NyYy9waHlzaWNhbF9wbGFuL21ldHJpY3MvdmFsdWUucnM=) | `86.93% <0.00%> (-0.51%)` | :arrow_down: |
   | [datafusion/expr/src/logical\_plan/plan.rs](https://codecov.io/gh/apache/arrow-datafusion/pull/2786/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGF0YWZ1c2lvbi9leHByL3NyYy9sb2dpY2FsX3BsYW4vcGxhbi5ycw==) | `73.91% <0.00%> (+0.19%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/arrow-datafusion/pull/2786?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/arrow-datafusion/pull/2786?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [11ae737...bec8956](https://codecov.io/gh/apache/arrow-datafusion/pull/2786?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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] Dandandan commented on a diff in pull request #2786: wip: Implement extract epoch

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


##########
datafusion/physical-expr/src/datetime_expressions.rs:
##########
@@ -372,6 +377,40 @@ pub fn date_part(args: &[ColumnarValue]) -> Result<ColumnarValue> {
     })
 }
 
+fn extract_epoch<T>(array: &PrimitiveArray<T>) -> Result<Int32Array>
+where
+    T: ArrowTemporalType + ArrowNumericType,
+    i64: std::convert::From<T::Native>,
+{
+    let mut b = Int32Builder::new(array.len());

Review Comment:
   Note: In terms of performance (and readability), it is better to avoid the builder/`value` etc. and work directly on the values (check the arrow-rs kernels for examples).
   Ok to leave this for a future PR if you like 👍 



-- 
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 #2786: wip: Implement extract epoch

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


##########
datafusion/physical-expr/src/datetime_expressions.rs:
##########
@@ -356,8 +360,9 @@ pub fn date_part(args: &[ColumnarValue]) -> Result<ColumnarValue> {
         "hour" => extract_date_part!(array, temporal::hour),
         "minute" => extract_date_part!(array, temporal::minute),
         "second" => extract_date_part!(array, temporal::second),
+        "epoch" => extract_date_part!(array, extract_epoch),
         _ => Err(DataFusionError::Execution(format!(
-            "Date part '{}' not supported",
+            "Date partx '{}' not supported",

Review Comment:
   ```suggestion
               "Date part '{}' not supported",
   ```



##########
datafusion/physical-expr/src/datetime_expressions.rs:
##########
@@ -372,6 +377,40 @@ pub fn date_part(args: &[ColumnarValue]) -> Result<ColumnarValue> {
     })
 }
 
+fn extract_epoch<T>(array: &PrimitiveArray<T>) -> Result<Int32Array>
+where
+    T: ArrowTemporalType + ArrowNumericType,
+    i64: std::convert::From<T::Native>,
+{
+    let mut b = Int32Builder::new(array.len());
+    match array.data_type() {
+        &DataType::Timestamp(ref unit, _) => {
+            for i in 0..array.len() {
+                if array.is_null(i) {
+                    b.append_null()?;
+                } else {
+                    let scale = match unit {

Review Comment:
   I would recommend using the `chrono` functions for this, such as done here:
   
   https://sourcegraph.com/github.com/apache/arrow-rs/-/blob/arrow/src/compute/kernels/temporal.rs?L214-240&subtree=true
   
   



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