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

[GitHub] [arrow-datafusion] comphead commented on a diff in pull request #5643: Support `date_bin` with 2 arguments

comphead commented on code in PR #5643:
URL: https://github.com/apache/arrow-datafusion/pull/5643#discussion_r1142362953


##########
datafusion/physical-expr/src/datetime_expressions.rs:
##########
@@ -319,13 +319,20 @@ fn date_bin_single(stride: i64, source: i64, origin: i64) -> i64 {
 
 /// DATE_BIN sql function
 pub fn date_bin(args: &[ColumnarValue]) -> Result<ColumnarValue> {
-    if args.len() != 3 {
+    if args.len() != 2 && args.len() != 3 {

Review Comment:
   Thanks, unfortunately We poorly support overloaded functions, and have to use confusing conditions.
   
   However maybe it can be improved like 
   
   ```
   pub fn date_bin(args: &[ColumnarValue]) -> Result<ColumnarValue> {
       check params count
       if 3 the date_bin_3args
       if 2 the date_bin_2args
       else panic
   
   }
   
   pub fn date_bin_3args(args: &[ColumnarValue]) -> Result<ColumnarValue> {
       main logic
   }
   
   pub fn date_bin_2args(args: &[ColumnarValue]) -> Result<ColumnarValue> {
       order params
       date_bin_3args(params);
   }
   ```



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