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/05/10 04:31:07 UTC

[spark] branch master updated: [SPARK-43425][SQL] Add `TimestampNTZType` to `ColumnarBatchRow`

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 82aed865976 [SPARK-43425][SQL] Add `TimestampNTZType` to `ColumnarBatchRow`
82aed865976 is described below

commit 82aed8659766970ca0dea9487f4961260191d20a
Author: Fokko Driesprong <fo...@tabular.io>
AuthorDate: Tue May 9 21:30:50 2023 -0700

    [SPARK-43425][SQL] Add `TimestampNTZType` to `ColumnarBatchRow`
    
    ### What changes were proposed in this pull request?
    
    Noticed this one was missing when implementing `TimestampNTZType` in Iceberg.
    
    ### Why are the changes needed?
    
    Able to read `TimestampNTZType` using the `ColumnarBatchRow`.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No
    
    ### How was this patch tested?
    
    I checked for `TestColumnarBatchRow.java` but couldn't find it. So I figured that this would be okay.
    
    Closes #41103 from Fokko/fd-add-timestampntz.
    
    Authored-by: Fokko Driesprong <fo...@tabular.io>
    Signed-off-by: Dongjoon Hyun <do...@apache.org>
---
 .../org/apache/spark/sql/vectorized/ColumnarBatchRow.java |  2 ++
 .../sql/execution/vectorized/ColumnarBatchSuite.scala     | 15 +++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/sql/catalyst/src/main/java/org/apache/spark/sql/vectorized/ColumnarBatchRow.java b/sql/catalyst/src/main/java/org/apache/spark/sql/vectorized/ColumnarBatchRow.java
index d30155eb2b4..da794e4bb91 100644
--- a/sql/catalyst/src/main/java/org/apache/spark/sql/vectorized/ColumnarBatchRow.java
+++ b/sql/catalyst/src/main/java/org/apache/spark/sql/vectorized/ColumnarBatchRow.java
@@ -176,6 +176,8 @@ public final class ColumnarBatchRow extends InternalRow {
       return getInt(ordinal);
     } else if (dataType instanceof TimestampType) {
       return getLong(ordinal);
+    } else if (dataType instanceof TimestampNTZType) {
+      return getLong(ordinal);
     } else if (dataType instanceof ArrayType) {
       return getArray(ordinal);
     } else if (dataType instanceof StructType) {
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/vectorized/ColumnarBatchSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/vectorized/ColumnarBatchSuite.scala
index 9b2c2c34c7e..b34af3c8c63 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/execution/vectorized/ColumnarBatchSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/vectorized/ColumnarBatchSuite.scala
@@ -1957,6 +1957,21 @@ class ColumnarBatchSuite extends SparkFunSuite {
       column.close()
   }
 
+  testVector("Timestamp without timezone", 10, TimestampNTZType) {
+    column =>
+      val dt = TimestampNTZType
+      (0 until 10).foreach { i =>
+        column.putLong(i, i)
+      }
+      val bachRow = new ColumnarBatchRow(Array(column))
+      (0 until 10).foreach { i =>
+        bachRow.rowId = i
+        assert(bachRow.get(0, dt) === i)
+        val batchRowCopy = bachRow.copy()
+        assert(batchRowCopy.get(0, dt) === i)
+      }
+  }
+
   testVector("WritableColumnVector.reserve(): requested capacity is negative", 1024, ByteType) {
     column =>
       val ex = intercept[RuntimeException] { column.reserve(-1) }


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