Max Gekk created SPARK-57553:
--------------------------------

             Summary: Support cast between TIME and TIMESTAMP_LTZ
                 Key: SPARK-57553
                 URL: https://issues.apache.org/jira/browse/SPARK-57553
             Project: Spark
          Issue Type: Sub-task
          Components: SQL
    Affects Versions: 4.3.0
            Reporter: Max Gekk


h2. What

Support {{CAST}} in both directions between {{TIME}} and {{TIMESTAMP}} / 
{{TIMESTAMP_LTZ}}
(the microsecond {{TimestampType}}).

h2. Why

ANSI SQL requires TIME <-> TIMESTAMP to be a valid cast. SPARK-52617 covers the
WITHOUT TIME ZONE variant; this ticket covers the WITH LOCAL TIME ZONE variant. 
Unlike NTZ,
the LTZ direction is time-zone aware and uses the session time zone.

h2. Semantics (ANSI / session time zone)

* {{CAST(time AS TIMESTAMP_LTZ)}}: combine the time-of-day with 
{{CURRENT_DATE}} in the
  session time zone, then store as an absolute instant (epoch micros, UTC).
* {{CAST(ts_ltz AS TIME(q))}}: convert the instant to the session time zone, 
take the
  time-of-day, truncate fractional seconds to q.

h2. Scope

* {{canCast}}/{{canAnsiCast}} + runtime + codegen in {{Cast.scala}}, threading 
the session
  {{zoneId}} (as other TIMESTAMP_LTZ casts do).
* {{TIMESTAMP_LTZ}} has microsecond precision; casting from {{TIME(7..9)}} 
truncates the
  sub-microsecond digits (mark nullable only if applicable).

h2. Acceptance criteria

* Both directions correct across DST/zone boundaries; covered with explicit 
session
  time-zone tests.
* ANSI and non-ANSI modes; tests in {{CastSuiteBase}} and SQL golden files.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to