forked from facebookincubator/velox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow trailing spaces in cast(varchar as date) (facebookincubator#10077)
Summary: Pull Request resolved: facebookincubator#10077 Presto CAST(varchar AS date) allows leading and trailing spaces. Velox used to allow leading spaces, but not trailing spaces. date(x) function is an alias for CAST. Update the implementation of date(x) to match CAST. from_iso8601_date(x) function is different from CAST. It doesn't allow leading or trailing whitespaces, but allows partial dates, e.g. '2024', '2024-01'. Velox used to allow leading spaces. Here are some examples of CAST and from_iso8601_date: ``` presto> select -> x, try(from_iso8601_date(x)) as from_iso, try(cast(x as date)) as "cast" -> from (values -> '', -> '2024-01-12', -> '2024-01', -> '2024', -> '2024-1-2', -> '2024-1', -> '2024', -> ' 2024-1-3', -> ' 2024-1-3 ', -> '2024-1-3 ' -> ) as t(x) -> ; x | from_iso | cast --------------+------------+------------ | NULL | NULL 2024-01-12 | 2024-01-12 | 2024-01-12 2024-01 | 2024-01-01 | NULL 2024 | 2024-01-01 | NULL 2024-1-2 | 2024-01-02 | 2024-01-02 2024-1 | 2024-01-01 | NULL 2024 | 2024-01-01 | NULL 2024-1-3 | NULL | 2024-01-03 2024-1-3 | NULL | 2024-01-03 2024-1-3 | NULL | 2024-01-03 (10 rows) ``` Fixes facebookincubator#10076 Fixes facebookincubator#10061 Reviewed By: xiaoxmeng, pedroerp Differential Revision: D58217666 fbshipit-source-id: 7e8f3e7076eb0ae8c38314ddeab2e87d20f2ed4b
- Loading branch information
1 parent
7637d56
commit efe648f
Showing
5 changed files
with
31 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters