Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
[SPARK-50261][SQL] Fix error signature for invalid fraction of a second
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?
Changed type of parameter for error message for invalid fraction of second from Decimal to Double.

### Why are the changes needed?
To keep things consistent with other errors.

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Tests were updated to reflect the changes.

### Was this patch authored or co-authored using generative AI tooling?
No

Closes apache#48793 from markonik-db/SPARK-50261-FollowUp.

Authored-by: Marko Nikacevic <marko.nikacevic@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
  • Loading branch information
markonik-db authored and cloud-fan committed Nov 8, 2024
1 parent 01adf10 commit 60acd2f
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2808,7 +2808,7 @@ case class MakeTimestamp(
// This case of sec = 60 and nanos = 0 is supported for compatibility with PostgreSQL
LocalDateTime.of(year, month, day, hour, min, 0, 0).plusMinutes(1)
} else {
throw QueryExecutionErrors.invalidFractionOfSecondError(secAndMicros)
throw QueryExecutionErrors.invalidFractionOfSecondError(secAndMicros.toDouble)
}
} else {
LocalDateTime.of(year, month, day, hour, min, seconds, nanos)
Expand Down Expand Up @@ -2879,7 +2879,7 @@ case class MakeTimestamp(
ldt = java.time.LocalDateTime.of(
$year, $month, $day, $hour, $min, 0, 0).plusMinutes(1);
} else {
throw QueryExecutionErrors.invalidFractionOfSecondError($secAndNanos);
throw QueryExecutionErrors.invalidFractionOfSecondError($secAndNanos.toDouble());
}
} else {
ldt = java.time.LocalDateTime.of($year, $month, $day, $hour, $min, seconds, nanos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase with ExecutionE
summary = "")
}

def invalidFractionOfSecondError(secAndMicros: Decimal): DateTimeException = {
def invalidFractionOfSecondError(secAndMicros: Double): DateTimeException = {
new SparkDateTimeException(
errorClass = "INVALID_FRACTION_OF_SECOND",
messageParameters = Map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ org.apache.spark.SparkDateTimeException
"errorClass" : "INVALID_FRACTION_OF_SECOND",
"sqlState" : "22023",
"messageParameters" : {
"secAndMicros" : "60.007000"
"secAndMicros" : "60.007"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ org.apache.spark.SparkDateTimeException
"errorClass" : "INVALID_FRACTION_OF_SECOND",
"sqlState" : "22023",
"messageParameters" : {
"secAndMicros" : "60.007000"
"secAndMicros" : "60.007"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class QueryExecutionAnsiErrorsSuite extends QueryTest
condition = "INVALID_FRACTION_OF_SECOND",
sqlState = "22023",
parameters = Map(
"secAndMicros" -> "60.100000"
"secAndMicros" -> "60.1"
))
}

Expand Down

0 comments on commit 60acd2f

Please sign in to comment.