Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-23277

Calcite. Wrong cast of VARCHAR to TIMESTAMP WITH LOCAL TIMEZONE

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • None
    • Release Notes Required

    Description

      When support of `TIMESTAMP WITH LOCAL TIME ZONE` is enabled, cast from a `VARCHAR` must be fixed. The timezone is skipped.

      Reproducer:

      @Test
          public void testCastToTimestampWithLocalTimeZoneFromStringColumn() {
              TimeZone tz = TimeZone.getDefault();
      
              try {
                  sql("CREATE TABLE src (id INT PRIMARY KEY, str_date VARCHAR(100))");
                  sql("INSERT INTO src VALUES (1, '2024-07-21 12:00:00')");
      
                  sql("CREATE TABLE test (val TIMESTAMP WITH LOCAL TIME ZONE)");
      
                  TimeZone.setDefault(TimeZone.getTimeZone(ZoneOffset.ofHours(4)));
      
                  assertQuery("INSERT INTO test SELECT str_date FROM src WHERE id = 1").check();
      
                  TimeZone.setDefault(tz);
      
                  assertQuery("SELECT val FROM test")
                      .returns(LocalDateTime.of(2024,7, 21, 8, 0, 0))
                      .check();
              } finally {
                  TimeZone.setDefault(tz);
              }
          }
      

      Adoption of #IGNITE-22780

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              vladsz83 Vladimir Steshin
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: