[ 
https://issues.apache.org/jira/browse/IGNITE-25045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17949736#comment-17949736
 ] 

Maksim Zhuravkov edited comment on IGNITE-25045 at 5/6/25 2:05 PM:
-------------------------------------------------------------------


RexToLixTranslator translateCastToTime, translateCastToTimestamp, 
translateCastToTimestampWithLocalTimeZone completely ignores precision of a 
target type.

{noformat}
sql-cli> CREATE TABLE t (id int, time1_col TIME(1), val VARCHAR, PRIMARY KEY 
(id));
Updated 0 rows.

sql-cli> INSERT INTO t VALUES (1, null, '00:00:00.123');
Updated 1 rows.

sql-cli> UPDATE t SET time1_col = CAST(val AS TIME(1) FORMAT 'hh24:mi:ss.ff3');
Updated 1 rows.

sql-cli> SELECT * FROM t;
╔════╤══════════════╤══════════════╗
║ ID │ TIME1_COL    │ VAL          ║
╠════╪══════════════╪══════════════╣
║ 1  │ 00:00:00.123 │ 00:00:00.123 ║
╚════╧══════════════╧══════════════╝
{noformat}



was (Author: JIRAUSER298618):


RexToLixTranslator translateCastToTime, translateCastToTimestamp, 
translateCastToTimestampWithLocalTimeZone completely ignores precision of 
target type.

{noformat}
sql-cli> CREATE TABLE t (id int, time1_col TIME(1), val VARCHAR, PRIMARY KEY 
(id));
Updated 0 rows.

sql-cli> INSERT INTO t VALUES (1, null, '00:00:00.123');
Updated 1 rows.

sql-cli> UPDATE t SET time1_col = CAST(val AS TIME(1) FORMAT 'hh24:mi:ss.ff3');
Updated 1 rows.

sql-cli> SELECT * FROM t;
╔════╤══════════════╤══════════════╗
║ ID │ TIME1_COL    │ VAL          ║
╠════╪══════════════╪══════════════╣
║ 1  │ 00:00:00.123 │ 00:00:00.123 ║
╚════╧══════════════╧══════════════╝
{noformat}


> Sql. Time, Timestamp, Timestamp with local time zone. Insert with cast 
> operation ignores target precision
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: IGNITE-25045
>                 URL: https://issues.apache.org/jira/browse/IGNITE-25045
>             Project: Ignite
>          Issue Type: Bug
>          Components: sql
>            Reporter: Maksim Zhuravkov
>            Priority: Major
>              Labels: ignite-3
>
> Insert with CAST to timestamp with local time zone ignores target type 
> precision:
> {code:java}
>  @Test
>     public void test() {
>         igniteSql().execute(null, "CREATE TABLE ts (id INT PRIMARY KEY, 
> ts_ltz TIMESTAMP(1) WITH LOCAL TIME ZONE)");
>         List<String> ops = List.of(
>                 "TIMESTAMP WITH LOCAL TIME ZONE '2001-01-01 18:00:00.333'",
>                 "'2001-01-01 18:00:00.333'::TIMESTAMP WITH LOCAL TIME ZONE"
>         );
>         for (int i = 0; i < ops.size(); i ++) {
>             String op = ops.get(i);
>             assertQuery("INSERT INTO ts VALUES(" + i + ", " + op + " )")
>                     .withTimeZoneId(ZoneId.of("Europe/Paris"))
>                     .returnSomething()
>                     .check();
>         }
>         Statement stmt = igniteSql().statementBuilder()
>                 .query("SELECT id, ts_ltz, ts_ltz::VARCHAR FROM ts ORDER BY 
> id")
>                 .timeZoneId(ZoneId.of("Europe/Paris"))
>                 .build();
>         try (ResultSet<SqlRow> rs = igniteSql().execute(null, stmt)) {
>             while (rs.hasNext()) {
>                 var row = rs.next();
>                 System.err.println(row);
>             }
>         }
>     }
> {code}
> Output:
> {noformat}
> SqlRowImpl [ID=0, TS_LTZ=2001-01-01T17:00:00.300Z, TS_LTZ :: 
> VARCHAR=2001-01-01 18:00:00.3 Europe/Paris]
> SqlRowImpl [ID=1, TS_LTZ=2001-01-01T17:00:00.333Z, TS_LTZ :: 
> VARCHAR=2001-01-01 18:00:00.333 Europe/Paris]
> {noformat}
> P.S. There is no such issue with TIMESTAMP type.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to