goldmedal opened a new issue, #14884:
URL: https://github.com/apache/datafusion/issues/14884

   ### Describe the bug
   
   Currenlty, if we input a null value to `to_char`, we will get an empty 
string instead of a null value.
   ```
   > select to_char(NULL, '%Y-%m-%d %H:%M:%S') is null;
   +-------------------------------------------------+
   | to_char(NULL,Utf8("%Y-%m-%d %H:%M:%S")) IS NULL |
   +-------------------------------------------------+
   | false                                           |
   +-------------------------------------------------+
   1 row(s) fetched. 
   Elapsed 0.001 seconds.
   
   > select to_char(NULL, '%Y-%m-%d %H:%M:%S');
   +-----------------------------------------+
   | to_char(NULL,Utf8("%Y-%m-%d %H:%M:%S")) |
   +-----------------------------------------+
   |                                         |
   +-----------------------------------------+
   1 row(s) fetched. 
   Elapsed 0.001 seconds.
   ```
   
   However, the postgres behavior is returing a null value if got a null input.
   ```
   psql=# select to_char(null::timestamp, '%Y-%m-%d %H:%M:%S') is null;
    ?column? 
   ----------
    t
   (1 row)
   
   psql=# select to_char(null::timestamp, '%Y-%m-%d %H:%M:%S');
    to_char 
   ---------
    
   (1 row)
   ```
   
   I think we should follow the behavior of postgres.
   
   ### To Reproduce
   
   Execute the SQL mentioned above.
   
   ### Expected behavior
   
   `to_char` should return a null if got a null input.
   
   ### 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-unsubscr...@datafusion.apache.org.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to