This is an automated email from the ASF dual-hosted git repository.

wenchen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new 60acd2fe442c [SPARK-50261][SQL] Fix error signature for invalid 
fraction of a second
60acd2fe442c is described below

commit 60acd2fe442c38e5c154e54f632733e28e2b8ec4
Author: Marko Nikacevic <[email protected]>
AuthorDate: Thu Nov 7 16:01:34 2024 -0800

    [SPARK-50261][SQL] Fix error signature for invalid fraction of a second
    
    ### 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 #48793 from markonik-db/SPARK-50261-FollowUp.
    
    Authored-by: Marko Nikacevic <[email protected]>
    Signed-off-by: Wenchen Fan <[email protected]>
---
 .../apache/spark/sql/catalyst/expressions/datetimeExpressions.scala   | 4 ++--
 .../main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala | 2 +-
 sql/core/src/test/resources/sql-tests/results/ansi/timestamp.sql.out  | 2 +-
 .../resources/sql-tests/results/timestampNTZ/timestamp-ansi.sql.out   | 2 +-
 .../org/apache/spark/sql/errors/QueryExecutionAnsiErrorsSuite.scala   | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
index dd20418496ca..9467f1146c43 100644
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
@@ -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)
@@ -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);
diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
index a32016eee61f..6cf930f18dc2 100644
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
@@ -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(
diff --git 
a/sql/core/src/test/resources/sql-tests/results/ansi/timestamp.sql.out 
b/sql/core/src/test/resources/sql-tests/results/ansi/timestamp.sql.out
index c64bd2ff57e1..d75380b16cc8 100644
--- a/sql/core/src/test/resources/sql-tests/results/ansi/timestamp.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/ansi/timestamp.sql.out
@@ -126,7 +126,7 @@ org.apache.spark.SparkDateTimeException
   "errorClass" : "INVALID_FRACTION_OF_SECOND",
   "sqlState" : "22023",
   "messageParameters" : {
-    "secAndMicros" : "60.007000"
+    "secAndMicros" : "60.007"
   }
 }
 
diff --git 
a/sql/core/src/test/resources/sql-tests/results/timestampNTZ/timestamp-ansi.sql.out
 
b/sql/core/src/test/resources/sql-tests/results/timestampNTZ/timestamp-ansi.sql.out
index 482a1efb6b09..79996d838c1e 100644
--- 
a/sql/core/src/test/resources/sql-tests/results/timestampNTZ/timestamp-ansi.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/results/timestampNTZ/timestamp-ansi.sql.out
@@ -126,7 +126,7 @@ org.apache.spark.SparkDateTimeException
   "errorClass" : "INVALID_FRACTION_OF_SECOND",
   "sqlState" : "22023",
   "messageParameters" : {
-    "secAndMicros" : "60.007000"
+    "secAndMicros" : "60.007"
   }
 }
 
diff --git 
a/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionAnsiErrorsSuite.scala
 
b/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionAnsiErrorsSuite.scala
index 3e896ae69b68..f07d2d6620f7 100644
--- 
a/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionAnsiErrorsSuite.scala
+++ 
b/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionAnsiErrorsSuite.scala
@@ -102,7 +102,7 @@ class QueryExecutionAnsiErrorsSuite extends QueryTest
       condition = "INVALID_FRACTION_OF_SECOND",
       sqlState = "22023",
       parameters = Map(
-        "secAndMicros" -> "60.100000"
+        "secAndMicros" -> "60.1"
       ))
   }
 


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

Reply via email to