You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jiangzhx (via GitHub)" <gi...@apache.org> on 2023/07/26 06:50:54 UTC

[GitHub] [arrow-datafusion] jiangzhx opened a new issue, #7097: is there a way to get a result similar to `datediff` function

jiangzhx opened a new issue, #7097:
URL: https://github.com/apache/arrow-datafusion/issues/7097

   ### Is your feature request related to a problem or challenge?
   
   I’d like to ask if there is a way to get a result similar to `datediff` function , also it seems that this function is not available in DataFusion.
   
   i try another way like this,but how can i get 6  days from  interval  result
   ```
   select to_timestamp(now())-to_timestamp('2023-07-20T05:44:00.419557');
   
   +------------------------------------------------------------------------+                                                                                             
   | to_timestamp(now()) - to_timestamp(Utf8("2023-07-20T05:44:00.419557")) |                                                                                             
   +------------------------------------------------------------------------+                                                                                             
   | 0 years 0 mons 6 days 0 hours 51 mins 7.343851000 secs                 |                                                                                             
   +------------------------------------------------------------------------+           
   ```                                                                                  
   
   ### Describe the solution you'd like
   
   something like `date_diff` 
    
   
   ### Describe alternatives you've considered
   
   add udf like `date_diff`
   or 
   make 
   `select extract(day from interval '1 days' ); `
   work
   ```
   
   Error during planning: No function matches the given name and argument types 'date_part(Utf8, Interval(MonthDayNano))'. You might need to add explicit type casts.
           Candidate functions:
           date_part(Utf8, Date32)
           date_part(Utf8, Date64)
           date_part(Utf8, Timestamp(Second, None))
           date_part(Utf8, Timestamp(Microsecond, None))
           date_part(Utf8, Timestamp(Millisecond, None))
           date_part(Utf8, Timestamp(Nanosecond, None))
           date_part(Utf8, Timestamp(Nanosecond, Some("+00:00")))
   
   ```
   
   ### Additional context
   
   _No response_


-- 
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.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on issue #7097: is there a way to get a result similar to `datediff` function

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on issue #7097:
URL: https://github.com/apache/arrow-datafusion/issues/7097#issuecomment-1651909704

   For example, either use or follow https://docs.rs/arrow/latest/arrow/compute/fn.day.html


-- 
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 issue #7097: is there a way to get a result similar to `datediff` function

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on issue #7097:
URL: https://github.com/apache/arrow-datafusion/issues/7097#issuecomment-1658155546

   Thanks @NiwakaDev  -- let us know if you run into any trouble. 


-- 
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] smallzhongfeng commented on issue #7097: is there a way to get a result similar to `datediff` function

Posted by "smallzhongfeng (via GitHub)" <gi...@apache.org>.
smallzhongfeng commented on issue #7097:
URL: https://github.com/apache/arrow-datafusion/issues/7097#issuecomment-1653466104

   Do we have plans to support date_diff, date_add and other time functions, such as comparing spark's udf function about `date`? [https://spark.apache.org/docs/3.4.1/api/sql/search.html?q=date](https://spark.apache.org/docs/3.4.1/api/sql/search.html?q=date)


-- 
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: [I] is there a way to get a result similar to `datediff` function [arrow-datafusion]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on issue #7097:
URL: https://github.com/apache/arrow-datafusion/issues/7097#issuecomment-1872904579

   Note there is an existing issue for implementing `extract(X from interval)` in Datafusion here: #6327
   
   I've also put details in a comment there with comparison of other engines behaviour


-- 
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 issue #7097: is there a way to get a result similar to `datediff` function

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on issue #7097:
URL: https://github.com/apache/arrow-datafusion/issues/7097#issuecomment-1651907523

   I agree that adding support for for intervals to `EXTRACT` would be very helpful. 


-- 
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 issue #7097: is there a way to get a result similar to `datediff` function

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on issue #7097:
URL: https://github.com/apache/arrow-datafusion/issues/7097#issuecomment-1653578572

   > Do we have plans to support date_diff, date_add and other time functions, @alamb such as comparing spark's udf
   
   There do not appear to be any such plans:  https://github.com/apache/arrow-datafusion/issues?q=is%3Aissue+is%3Aopen+date_diff+
   
   Adding them seems like a good idea to me. However, st some point we probably need to figure out how to split functions into packages so users can mix/match "packages" of functions they want without having to get all of the others. I filed https://github.com/apache/arrow-datafusion/issues/7110 to track this idea
   
   🤔 
   


-- 
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 issue #7097: is there a way to get a result similar to `datediff` function

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on issue #7097:
URL: https://github.com/apache/arrow-datafusion/issues/7097#issuecomment-1651908813

   I think this would be a good first issue as the wiring is all done and this would be a relatively simple extension to date_part I think 


-- 
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] NiwakaDev commented on issue #7097: is there a way to get a result similar to `datediff` function

Posted by "NiwakaDev (via GitHub)" <gi...@apache.org>.
NiwakaDev commented on issue #7097:
URL: https://github.com/apache/arrow-datafusion/issues/7097#issuecomment-1657207753

   @alamb 
   
   I'd like to implement the following feature:
   ```sql
   select extract(~ from interval ~ ); 
   ```


-- 
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: [I] is there a way to get a result similar to `datediff` function [arrow-datafusion]

Posted by "NiwakaDev (via GitHub)" <gi...@apache.org>.
NiwakaDev commented on issue #7097:
URL: https://github.com/apache/arrow-datafusion/issues/7097#issuecomment-1773758086

   As far as I understand, it seems like this issue depends on https://github.com/apache/arrow-rs/issues/4969.


-- 
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: [I] is there a way to get a result similar to `datediff` function [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on issue #7097:
URL: https://github.com/apache/arrow-datafusion/issues/7097#issuecomment-1774855584

   @NiwakaDev  I am not sure about this. 
   
   Note DataFusion already supports `extract` for several field types:
   https://arrow.apache.org/datafusion/user-guide/sql/scalar_functions.html#extract
   
   What would `extract (.. from interval ..)` do? Perhaps you could provide an example or a link to another database system that implements such a function?


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