Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions common/utils/src/main/resources/error/error-conditions.json
Original file line number Diff line number Diff line change
Expand Up @@ -8365,6 +8365,11 @@
"Temporary views cannot be created with the WITH SCHEMA clause. Recreate the temporary view when the underlying schema changes, or use a persisted view."
]
},
"TIMESTAMP_NANOS_WITH_LEGACY_TIME_PARSER" : {
"message" : [
"Parsing or formatting nanosecond-precision timestamps (TIMESTAMP_LTZ/TIMESTAMP_NTZ with precision in [7, 9]) under the LEGACY time parser policy. Set <config> to CORRECTED."
]
},
"TIME_TRAVEL" : {
"message" : [
"Time travel on the relation: <relationId>."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,20 @@ trait SparkDateTimeUtils {
* The input is the already-extracted `nanosWithinMicro` component (`0..999`), so truncation is
* independent of the epoch sign of the original timestamp value.
*
* Precisions outside `[7, 9]` are passed through unchanged because the surrounding timestamp
* nanos types validate the bound.
* `precision` is expected to originate from a validated `TimestampNTZNanosType` /
* `TimestampLTZNanosType` (which can only be constructed with `p` in [7, 9]), so it is not a
* user-reachable input here. An out-of-range value therefore indicates an internal caller bug
* and raises an internal error rather than silently retaining all sub-microsecond digits.
*/
private def truncateNanosWithinMicroToPrecision(nanosWithinMicro: Int, precision: Int): Int = {
precision match {
case 7 => (nanosWithinMicro / 100) * 100
case 8 => (nanosWithinMicro / 10) * 10
case _ => nanosWithinMicro
case 9 => nanosWithinMicro
case _ =>
throw SparkException.internalError(
s"Fractional second precision $precision is out of range " +
s"[${TimestampNTZNanosType.MIN_PRECISION}, ${TimestampNTZNanosType.MAX_PRECISION}].")
}
}

Expand Down
Loading