You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2020/02/27 06:53:57 UTC

[GitHub] [incubator-doris] gaodayue opened a new issue #3008: Wrong answer for tableau generated SQL

gaodayue opened a new issue #3008: Wrong answer for tableau generated SQL
URL: https://github.com/apache/incubator-doris/issues/3008
 
 
   **Describe the bug**
   Tableau will generated the following expression when using string fields in date filters
   
   ```SQL
   -- trying to parse varchar column `col` into date value
   CASE WHEN (NOT ISNULL(DATE(TIMESTAMP(STR_TO_DATE(SUBSTRING(`col`, 1, 1024), '%Y-%m-%d')))))
   THEN DATE(TIMESTAMP(STR_TO_DATE(SUBSTRING(`col`, 1, 1024), '%Y-%m-%d')))
   WHEN (NOT ISNULL(IFNULL(DATE(SUBSTRING(`col`, 1, 1024)),
                           STR_TO_DATE(SUBSTRING(`col`, 1, 1024),'%b %e %Y'))))
   THEN IFNULL(DATE(SUBSTRING(`col`, 1, 1024)),
               STR_TO_DATE(SUBSTRING(`col`, 1, 1024),'%b %e %Y'))
   ELSE NULL
   END
   ```
   
   The following results from Doris is wrong
   ```
   // correct
   mysql> select str_to_date(substring('2020-02-09', 1, 1024), '%b %e %Y');
   +-----------------------------------------------------------+
   | str_to_date(substring('2020-02-09', 1, 1024), '%b %e %Y') |
   +-----------------------------------------------------------+
   | NULL                                                      |
   +-----------------------------------------------------------+
   
   // correct
   mysql> select ifnull(date(substring('2020-02-09', 1, 1024)), null);
   +------------------------------------------------------+
   | ifnull(date(substring('2020-02-09', 1, 1024)), NULL) |
   +------------------------------------------------------+
   | 2020-02-09                                           |
   +------------------------------------------------------+
   
   // WRONG: expect to be 2020-02-09
   mysql> select ifnull(date(substring('2020-02-09', 1, 1024)), str_to_date(substring('2020-02-09', 1, 1024), '%b %e %Y'));
   +-----------------------------------------------------------------------------------------------------------+
   | ifnull(date(substring('2020-02-09', 1, 1024)), str_to_date(substring('2020-02-09', 1, 1024), '%b %e %Y')) |
   +-----------------------------------------------------------------------------------------------------------+
   |                                                                                                  20200209 |
   +-----------------------------------------------------------------------------------------------------------+
   
   // WRONG: expect to be 1 (true)
   mysql> SELECT CASE WHEN (NOT ISNULL(DATE(TIMESTAMP(STR_TO_DATE(SUBSTRING('2020-02-98', 1, 1024), '%Y-%m-%d')))))
       ->         THEN DATE(TIMESTAMP(STR_TO_DATE(SUBSTRING('2020-02-09', 1, 1024), '%Y-%m-%d')))
       ->         WHEN (NOT ISNULL(IFNULL(DATE(SUBSTRING('2020-02-09', 1, 1024)),
       ->                                 STR_TO_DATE(SUBSTRING('2020-02-09', 1, 1024),'%b %e %Y'))))
       ->         THEN IFNULL(DATE(SUBSTRING('2020-02-09', 1, 1024)),
       ->                     STR_TO_DATE(SUBSTRING('2020-02-09', 1, 1024),'%b %e %Y'))
       ->         ELSE NULL
       ->         END = TIMESTAMP('2020-02-09 00:00:00') as c1;
   +------+
   | c1   |
   +------+
   |    0 |
   +------+
   ```
   
   Doris version: 0.11
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [incubator-doris] imay closed issue #3008: Wrong answer for tableau generated SQL

Posted by GitBox <gi...@apache.org>.
imay closed issue #3008: Wrong answer for tableau generated SQL
URL: https://github.com/apache/incubator-doris/issues/3008
 
 
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [incubator-doris] gaodayue commented on issue #3008: Wrong answer for tableau generated SQL

Posted by GitBox <gi...@apache.org>.
gaodayue commented on issue #3008: Wrong answer for tableau generated SQL
URL: https://github.com/apache/incubator-doris/issues/3008#issuecomment-592275347
 
 
   Maybe it's related to #2946 , needs investigation

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [incubator-doris] wangbo commented on issue #3008: Wrong answer for tableau generated SQL

Posted by GitBox <gi...@apache.org>.
wangbo commented on issue #3008: Wrong answer for tableau generated SQL
URL: https://github.com/apache/incubator-doris/issues/3008#issuecomment-595098011
 
 
   **Bug Detail**
   The args of UDF ```ifnull``` current not support ```(date,datetime)``` or ```(datetime, date)```
   When user uses ifnull with args ```(date,datetime)``` or ```(datetime, date)```,```Fe``` can't find a totally match Function,it will use ```ifnull(int,int)``` instead, then type cast happened, input args ```date``` or ```datetime``` will be cast to int,So the result is wrong.
   
   **Solution**
   Add new Args type ```(date,datetime)``` and ```(date,datetime)```  for ```ifull```.
   First, type cast will be avoid.
   Second, for ```Fe```,add new Args type won't affect UDF match logic.
   Third , ```Be```  treats date and datetime as the same type by default, so we needn't change ```Be``` logic

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

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