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

   **Describe the bug**
   When i try to add a udf (`to_date`), I am able to do the following:
   - SELECT to_date(\"updatedAt\") as u from 'table';
   - SELECT DISTINCT to_date(\"updatedAt\") as u from 'table';
   - SELECT to_date(\"updatedAt\") as u from 'table' where 
to_date(\"updatedAt\") != '2023-03-04';
   
   But I am _NOT_ able to do the following
   - `SELECT to_date(\"updatedAt\") as u from 'table' group by u;`
   - `SELECT to_date(\"updatedAt\") as u from 'table' group by 
to_date(\"updatedAt\");`
     - Error log: `Join Error\ncaused by\nExternal error: task 554 panicked`: 
<https://pastebin.com/AcxWjh9Y>
   
   **To Reproduce**
   example updatedAt looks like: "2023-03-05T05:01:15.274000+00:00"
   - `SELECT to_date(\"updatedAt\") as u from 'table' group by u;`
   
   `to_date` udf using `chrono` crate
   
   ```
   pub fn to_date(args: &[ArrayRef]) -> DFResult<ArrayRef> {
       if args.is_empty() || args.len() > 1 {
           return Err(DataFusionError::Internal(format!(
               "to_date was called with {} arguments. It requires only 1.",
               args.len()
           )));
       }
       let arg = &args[0].as_any().downcast_ref::<StringArray>().unwrap();
       let mut builder = Date32Builder::new();
       let date_string: &str = arg.value(0);
       let date_time = match DateTime::parse_from_rfc3339(date_string) {
           Ok(dt) => dt,
           Err(e) => {
               return Result::Err(DataFusionError::Internal(e.to_string()));
           }
       };
       builder.append_value((date_time.timestamp() / 86400) as i32);
       Ok(Arc::new(builder.finish()))
   }
   ```
   
   **Expected behavior**
   Expecting it to group the dates like this:
     SELECT u FROM (SELECT to_date(\"updatedAt\") as u from 'table') group by u;
   
   **Additional context**
   Another problem/issue i am having is:
   - `SELECT to_date(\"updatedAt\") as u from 'table' where u != '2023-03-04';`
     - `Schema error: No field named 'u'. Valid fields are 'table'.'field', ...`


-- 
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-unsubscr...@arrow.apache.org.apache.org

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

Reply via email to