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
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,8 @@ protected void reserveInternal(int newCapacity) {
this.data = Platform.reallocateMemory(data, oldCapacity * 4L, newCapacity * 4L);
} else if (type instanceof LongType || type instanceof DoubleType ||
DecimalType.is64BitDecimalType(type) || type instanceof TimestampType ||
type instanceof TimestampNTZType || type instanceof DayTimeIntervalType) {
type instanceof TimestampNTZType || type instanceof DayTimeIntervalType ||
type instanceof TimeType) {
this.data = Platform.reallocateMemory(data, oldCapacity * 8L, newCapacity * 8L);
} else if (childColumns != null) {
// Nothing to store.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.spark.sql.execution.datasources.parquet

import java.time.{Duration, Period}
import java.time.{Duration, LocalTime, Period}

import org.apache.hadoop.fs.{FileSystem, Path}

Expand All @@ -34,6 +34,8 @@ abstract class ParquetFileFormatSuite
with SharedSparkSession
with CommonFileDataSourceSuite {

import testImplicits._

override protected def dataSourceFormat = "parquet"

test("read parquet footers in parallel") {
Expand Down Expand Up @@ -129,6 +131,20 @@ abstract class ParquetFileFormatSuite
}
}
}

test("Write and read back TIME values") {
Copy link
Copy Markdown
Member Author

@MaxGekk MaxGekk Mar 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move it here from ParquetIOSuite to test for both V1 and V2 Parquet datasource, and avoid the test duplication.

Seq(false, true).foreach { offHeapEnabled =>
withSQLConf(SQLConf.COLUMN_VECTOR_OFFHEAP_ENABLED.key -> offHeapEnabled.toString) {
withTempPath { dir =>
val data = Seq(LocalTime.parse("01:12:30.999999")).toDF("col")
data.write.parquet(dir.getCanonicalPath)
val readback = spark.read.parquet(dir.getCanonicalPath)
assertResult(readback.schema) { new StructType().add("col", TimeType()) }
checkAnswer(readback, data)
}
}
}
}
}

class ParquetFileFormatV1Suite extends ParquetFileFormatSuite {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1628,16 +1628,6 @@ class ParquetIOSuite extends QueryTest with ParquetTest with SharedSparkSession
}
}
}

test("Write TimeType") {
withTempPath { dir =>
val data = Seq(LocalTime.parse("01:12:30.999999")).toDF("col")
data.write.parquet(dir.getCanonicalPath)
val readback = spark.read.parquet(dir.getCanonicalPath)
assertResult(readback.schema) { new StructType().add("col", TimeType()) }
checkAnswer(readback, data)
}
}
}

class JobCommitFailureParquetOutputCommitter(outputPath: Path, context: TaskAttemptContext)
Expand Down