Max Gekk created SPARK-57552:
--------------------------------
Summary: Support cast between TIME and TIMESTAMP_NTZ(p) for p in
[7, 9]
Key: SPARK-57552
URL: https://issues.apache.org/jira/browse/SPARK-57552
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 the nanosecond
timestamp type
{{TIMESTAMP_NTZ(p)}} ({{TimestampNTZNanosType}}, p in 7..9).
h2. Why
ANSI SQL requires TIME <-> TIMESTAMP to be a valid cast (6.13 <cast
specification>).
SPARK-52617 covers the microsecond {{TimestampNTZType}}; this ticket adds the
nanosecond-precision {{TimestampNTZNanosType}} target/source. Depends on the
TIME
precision-9 extension.
h2. Semantics (ANSI)
* {{CAST(time AS TIMESTAMP_NTZ(p))}}: combine the time-of-day with
{{CURRENT_DATE}} to form
the local date-time; fractional seconds carried at the target precision p.
* {{CAST(ts AS TIME(q))}}: drop the date, keep the time-of-day, truncate/round
fractional
seconds to q.
h2. Scope
* Add the {{canCast}}/{{canAnsiCast}} entries in {{Cast.scala}} and the runtime
+ codegen
cast paths.
* Reuse the existing same-family nanos cross-precision floor helpers in
{{SparkDateTimeUtils}} ({{truncateNanosWithinMicroToPrecision}} / the
{{TimestampNanosVal}} floor). {{TIME}} stores nanos-of-day ({{Long}});
{{TimestampNTZNanosType}} stores epoch-micros ({{Long}}) + nanos-within-micro
({{Short}}).
* Handle precision narrowing/widening between TIME(q) and TIMESTAMP_NTZ(p).
h2. Acceptance criteria
* Both cast directions work for all precision combinations of TIME(0..9) and
TIMESTAMP_NTZ(7..9), with correct truncation.
* ANSI and non-ANSI modes covered; tests added to {{CastSuiteBase}} and the 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]