You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Pavel Pereslegin (Jira)" <ji...@apache.org> on 2025/03/27 14:22:00 UTC
[jira] [Comment Edited] (IGNITE-24909) Sql. Improve test coverage for date/time templates support
[ https://issues.apache.org/jira/browse/IGNITE-24909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17938956#comment-17938956 ]
Pavel Pereslegin edited comment on IGNITE-24909 at 3/27/25 2:21 PM:
--------------------------------------------------------------------
Calcite uses SimpleDateFormat to parse dates internally, so issues with possible invalid/wrong patterns and overflows are caused by Java's SimpleDateFormat usage without additional validations.
For example the following is acceptable for SimpleDateFormat:
{code:java}
DateFormat df = new SimpleDateFormat("yy-MM-dd", Locale.ENGLISH);
System.out.println(df.parse("9999999-9999999-9999999")); // Sun Dec 27 00:00:00 MSK 9999998
{code}
And the same is acceptable by Calcite
{code:java}
sql("SELECT CAST('9999999-9999999-9999999' AS DATE FORMAT 'yy-MM-dd')"); // [[-898510-03-05]]
{code}
was (Author: xtern):
Calcite uses SimpleDateFormat to parse dates internally, so issues with possible invalid/wrong patterns and overflows are related to Java's SimpleDateFormat.
For example the following is acceptable for SimpleDateFormat:
{code:java}
DateFormat df = new SimpleDateFormat("yy-MM-dd", Locale.ENGLISH);
System.out.println(df.parse("9999999-9999999-9999999")); // Sun Dec 27 00:00:00 MSK 9999998
{code}
And the same is acceptable by Calcite
{code:java}
sql("SELECT CAST('9999999-9999999-9999999' AS DATE FORMAT 'yy-MM-dd')"); // [[-898510-03-05]]
{code}
> Sql. Improve test coverage for date/time templates support
> ----------------------------------------------------------
>
> Key: IGNITE-24909
> URL: https://issues.apache.org/jira/browse/IGNITE-24909
> Project: Ignite
> Issue Type: Improvement
> Components: sql
> Affects Versions: 3.0
> Reporter: Pavel Pereslegin
> Priority: Major
> Labels: ignite-3
>
> Date/time formatting tests currently located in {{test_cast_format.test}}, but the tests look incomplete.
> Need to improve checks for boundary values and templates (see 9.44 Datetime templates):
> * Incorrect templates, for example YYYYY, FF0, FF10, MMM, DDDD
> * Pattern mismatching (for example {{SELECT CAST('2021-01-9999' AS DATE FORMAT 'YYYY-MM-DD')}}).
> * Cast values with overflow, for example cast('9999-00-00' as date format 'YYYY-MM-DD') or cast('9999-99-99' as date format 'YYYY-MM-DD') produces strange results
> * Add test for cast with precision greater than zero (for example SELECT cast('01:05:07.161' as time(*2*) format 'HH24:MI:SS.FF1'))
> * Add tests that uses dynamic parameters
> * Add tests that uses table columns
--
This message was sent by Atlassian Jira
(v8.20.10#820010)