qidaye opened a new pull request #4612:
URL: https://github.com/apache/incubator-doris/pull/4612


   ## Proposed changes
   
   1. add date range check in `DateLiteral` for `FEFunctions`
   2. `select str_to_date(202009,'%Y%m')` and `select str_to_date(str,'%Y%m') 
from tb where tb.str = '202009'` will return same output `2020-09-00`.
   3. add support of zero-date to function `str_to_date()`,`date_format()` 
   
   **current behavior**
   ```
   mysql> select siteid,str_to_date(siteid,'%Y%m%d') from table2  order by 
siteid;
   +------------+---------------------------------+
   | siteid     | str_to_date(`siteid`, '%Y%m%d') |
   +------------+---------------------------------+
   |          1 | 2001-00-00                      |
   |          2 | 2002-00-00                      |
   |          2 | 2002-00-00                      |
   |          3 | 2003-00-00                      |
   |          4 | 2004-00-00                      |
   |          5 | 2005-00-00                      |
   |         20 | 2020-00-00                      |
   |        202 | 0202-00-00                      |
   |       2020 | 2020-00-00                      |
   |      20209 | 2020-09-00                      |
   |     202008 | 2020-08-00                      |
   |     202009 | 2020-09-00                      |
   |    2020009 | 2020-00-09                      |
   |   20200009 | 2020-00-09                      |
   |   20201309 | NULL                            |
   | 2020090909 | 2020-09-09                      |
   +------------+---------------------------------+
   
   mysql> select 
str_to_date('2','%Y%m%d'),str_to_date('20','%Y%m%d'),str_to_date('202','%Y%m%d'),str_to_date('2020','%Y%m%d'),str_to_date('20209','%Y%m%d'),str_to_date('202009','%Y%m%d'),str_to_date('2020099','%Y%m%d'),str_to_date('20200909','%Y%m%d'),str_to_date('2020090909','%Y%m%d'),str_to_date('2020009','%Y%m%d'),str_to_date('20200009','%Y%m%d'),str_to_date('20201309','%Y%m%d');
   
+----------------------------+-----------------------------+------------------------------+-------------------------------+--------------------------------+---------------------------------+----------------------------------+-----------------------------------+-------------------------------------+----------------------------------+-----------------------------------+-----------------------------------+
   | str_to_date('2', '%Y%m%d') | str_to_date('20', '%Y%m%d') | 
str_to_date('202', '%Y%m%d') | str_to_date('2020', '%Y%m%d') | 
str_to_date('20209', '%Y%m%d') | str_to_date('202009', '%Y%m%d') | 
str_to_date('2020099', '%Y%m%d') | str_to_date('20200909', '%Y%m%d') | 
str_to_date('2020090909', '%Y%m%d') | str_to_date('2020009', '%Y%m%d') | 
str_to_date('20200009', '%Y%m%d') | str_to_date('20201309', '%Y%m%d') |
   
+----------------------------+-----------------------------+------------------------------+-------------------------------+--------------------------------+---------------------------------+----------------------------------+-----------------------------------+-------------------------------------+----------------------------------+-----------------------------------+-----------------------------------+
   | 2002-00-00                 | 2020-00-00                  | 0202-00-00      
             | 2020-00-00                    | 2020-09-00                     | 
2020-09-00                      | 2020-09-09                       | 2020-09-09 
                       | 2020-09-09                          | 2020-00-09       
                | 2020-00-09                        | NULL                      
        |
   
+----------------------------+-----------------------------+------------------------------+-------------------------------+--------------------------------+---------------------------------+----------------------------------+-----------------------------------+-------------------------------------+----------------------------------+-----------------------------------+-----------------------------------+
   ```
   fix 
[https://github.com/apache/incubator-doris/issues/4494](https://github.com/apache/incubator-doris/issues/4494)
   
   ## Types of changes
   
   - [x] Bugfix (non-breaking change which fixes an issue)
   
   
   ## Checklist
   
   - [x] I have create an issue on (Fix #ISSUE), and have described the 
bug/feature there in detail
   - [x] Compiling and unit tests pass locally with my changes
   - [x] I have added tests that prove my fix is effective or that my feature 
works
   - [x] If this change need a document change, I have updated the document
   - [x] Any dependent changes have been merged
   


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

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



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

Reply via email to