You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by do...@apache.org on 2023/06/10 05:20:48 UTC

[spark] branch master updated: [SPARK-43594][SQL] Add LocalDateTime to anyToMicros

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

dongjoon 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 5ea8ce4b537 [SPARK-43594][SQL] Add LocalDateTime to anyToMicros
5ea8ce4b537 is described below

commit 5ea8ce4b5374e58e7858dd97adbb0dd612ccb1b7
Author: Fokko Driesprong <fo...@tabular.io>
AuthorDate: Fri Jun 9 22:20:16 2023 -0700

    [SPARK-43594][SQL] Add LocalDateTime to anyToMicros
    
    ### What changes were proposed in this pull request?
    
    Small change to `anyToMicros` to also accept `LocalDateTime` that's being returned when working with `TIMESTAMP_NTZ`. This simplifies some code at the Iceberg side.
    
    ### Why are the changes needed?
    
    With the introduction of the TIMESTAMP_NTZ it is convient to also accept LocalDateTime
    
    ### Does this PR introduce _any_ user-facing change?
    
    No
    
    ### How was this patch tested?
    
    Very trivial change, no test needed.
    
    Closes #41238 from Fokko/fd-add-local-date-time.
    
    Authored-by: Fokko Driesprong <fo...@tabular.io>
    Signed-off-by: Dongjoon Hyun <do...@apache.org>
---
 .../main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala  | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
index 2ae11f6568a..a3f74168b84 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
@@ -211,12 +211,13 @@ object DateTimeUtils {
   /**
    * Converts an Java object to microseconds.
    *
-   * @param obj Either an object of `java.sql.Timestamp` or `java.time.Instant`.
+   * @param obj Either an object of `java.sql.Timestamp` or `java.time.{Instant,LocalDateTime}`.
    * @return The number of micros since the epoch.
    */
   def anyToMicros(obj: Any): Long = obj match {
     case t: Timestamp => fromJavaTimestamp(t)
     case i: Instant => instantToMicros(i)
+    case ldt: LocalDateTime => localDateTimeToMicros(ldt)
   }
 
   /**


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org