Skip to content

Conversation

@morningman
Copy link
Contributor

Proposed changes

The return type of str_to_date depends on whether the time part is included in the format.
If included, it is DATETIME, otherwise it is DATE.
If the format parameter is not constant, the return type will be DATETIME.
The above judgment has been completed in the FE query planning stage,
so here we directly set the value type to the return type set in the query plan.

For example:
A table with one column k1 varchar, and has 2 lines:
"%Y-%m-%d"
"%Y-%m-%d %H:%i:%s"
Query:
SELECT str_to_date("2020-09-01", k1) from tbl;
Result will be:
2020-09-01 00:00:00
2020-09-01 00:00:00

Query:
SELECT str_to_date("2020-09-01", "%Y-%m-%d");
Return type is DATE

Query:
SELECT str_to_date("2020-09-01", "%Y-%m-%d %H:%i:%s");
Return type is DATETIME

Types of changes

  • Bugfix (non-breaking change which fixes an issue)

@morningman morningman added the area/mysql-compatibility Issues or PRs related to the mysql compatibility label Dec 2, 2020
@morningman morningman self-assigned this Dec 2, 2020
Copy link
Member

@yangzhg yangzhg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor

@EmmyMiao87 EmmyMiao87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@EmmyMiao87 EmmyMiao87 added the approved Indicates a PR has been approved by one committer. label Dec 2, 2020
@morningman morningman merged commit 5215727 into apache:master Dec 3, 2020
@yangzhg yangzhg mentioned this pull request Feb 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. area/mysql-compatibility Issues or PRs related to the mysql compatibility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants