[
https://issues.apache.org/jira/browse/SPARK-57821?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Max Gekk updated SPARK-57821:
-----------------------------
Shepherd: Max Gekk
> Support nanosecond-precision timestamps in date_trunc
> -----------------------------------------------------
>
> Key: SPARK-57821
> URL: https://issues.apache.org/jira/browse/SPARK-57821
> Project: Spark
> Issue Type: Sub-task
> Components: SQL
> Affects Versions: 4.3.0
> Reporter: Max Gekk
> Priority: Major
>
> This sub-task is part of the umbrella SPARK-56822 (timestamps with nanosecond
> precision).
> h2. Problem
> {{TruncTimestamp}} (datetimeExpressions.scala ~L2874-2900) declares
> {{inputTypes = Seq(StringType, TimestampType)}} and {{dataType =
> TimestampType}}, and evaluates via {{DateTimeUtils.truncTimestamp(Long,
> ...)}}. A {{TIMESTAMP_NTZ(p)}} / {{TIMESTAMP_LTZ(p)}} argument is implicitly
> cast to microsecond {{TimestampType}}, dropping {{nanosWithinMicro}} and
> forcing an LTZ result even for NTZ input. ({{trunc(date, ...)}} is date-only
> and out of scope.)
> h2. Goal
> {{date_trunc(fmt, ts_nanos)}} accepts nanosecond timestamps, returns the same
> nanosecond type/precision and family, and truncates correctly (units at or
> above SECOND zero the whole fraction including {{nanosWithinMicro}};
> MICROSECOND zeroes {{nanosWithinMicro}}).
> h2. Scope
> Extend {{TruncTimestamp.inputTypes}} / {{dataType}} to accept
> {{AnyTimestampNanoType}}; add a nanosecond eval/codegen branch operating on
> {{TimestampNanosVal}}; add {{DateTimeUtils.truncTimestampNanos}} if needed;
> keep the format-unit list unchanged (optionally accept a no-op NANOSECOND
> unit).
> h2. Acceptance criteria
> * {{date_trunc('SECOND'|'MINUTE'|'HOUR'|'DAY'|...)}} over NTZ/LTZ nanos
> returns the same type with the fraction zeroed; {{date_trunc('MICROSECOND',
> ...)}} zeroes only {{nanosWithinMicro}}; NTZ stays NTZ, LTZ stays LTZ.
> h2. Testing
> {{DateExpressionsSuite}}; nanos golden files.
> h2. Dependencies
> None - independent.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]