Skip to content

[Bug] function str_to_date()'s behavior on BE and FE is inconsistent #4494

@morningman

Description

@morningman

Describe the bug
On FE, str_to_date() is implemented by joda.DateTimeFormatter,
and on BE, it is implemented by Doris it self.

These 2 implementations are inconsistent in some cases:

  1. FE can not to the constant folding for str_to_date("2020-08-08", "%Y-%m-%d %H:%i:%s")
    It falls to BE and return 2020-08-08, but in mysql, it returns 2020-08-08 00:00:00.

  2. select str_to_date("20-09-01", "%Y-%m-%d");
    FE return 0020-09-01, but BE return 2020-09-01, which is same as MySQL.

  3. Some BI will generate predicate like
    DATE_ADD(DATE_ADD(str_to_date(DATE_FORMAT(NOW(),'%Y-%m-%d'),'%Y-%m-%d %H:%i:%s'),INTERVAL 1 DAY),INTERVAL -1 SECOND)

    It should be able to do the constant folding, but failed on str_to_date.

Resolution

We should keep the behavior on BE and FE consistency.

Metadata

Metadata

Assignees

Labels

kind/fixCategorizes issue or PR as related to a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions