Skip to content

Commit bd2c075

Browse files
committed
improve date/time microbenchmarks
1 parent 937619f commit bd2c075

File tree

1 file changed

+11
-31
lines changed

1 file changed

+11
-31
lines changed

spark/src/test/scala/org/apache/spark/sql/benchmark/CometDatetimeExpressionBenchmark.scala

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -30,47 +30,33 @@ import org.apache.spark.sql.internal.SQLConf
3030
*/
3131
object CometDatetimeExpressionBenchmark extends CometBenchmarkBase {
3232

33-
def dateTruncExprBenchmark(values: Int, useDictionary: Boolean): Unit = {
33+
def dateTruncExprBenchmark(values: Int): Unit = {
3434
withTempPath { dir =>
3535
withTempTable("parquetV1Table") {
3636
prepareTable(
3737
dir,
3838
spark.sql(
3939
s"select cast(timestamp_micros(cast(value/100000 as integer)) as date) as dt FROM $tbl"))
40-
Seq("YEAR", "YYYY", "YY", "MON", "MONTH", "MM").foreach { level =>
41-
val isDictionary = if (useDictionary) "(Dictionary)" else ""
42-
val name = s"Date Truncate $isDictionary - $level"
40+
Seq("YEAR", "MONTH").foreach { level =>
41+
val name = s"Date Truncate - $level"
4342
val query = s"select trunc(dt, '$level') from parquetV1Table"
4443
runExpressionBenchmark(name, values, query)
4544
}
4645
}
4746
}
4847
}
4948

50-
def timestampTruncExprBenchmark(values: Int, useDictionary: Boolean): Unit = {
49+
def timestampTruncExprBenchmark(values: Int): Unit = {
5150
withTempPath { dir =>
5251
withTempTable("parquetV1Table") {
5352
prepareTable(
5453
dir,
5554
spark.sql(s"select timestamp_micros(cast(value/100000 as integer)) as ts FROM $tbl"))
56-
Seq(
57-
"YEAR",
58-
"YYYY",
59-
"YY",
60-
"MON",
61-
"MONTH",
62-
"MM",
63-
"DAY",
64-
"DD",
65-
"HOUR",
66-
"MINUTE",
67-
"SECOND",
68-
"WEEK",
69-
"QUARTER").foreach { level =>
70-
val isDictionary = if (useDictionary) "(Dictionary)" else ""
71-
val name = s"Timestamp Truncate $isDictionary - $level"
72-
val query = s"select date_trunc('$level', ts) from parquetV1Table"
73-
runExpressionBenchmark(name, values, query)
55+
Seq("YEAR", "MONTH", "DAY", "HOUR", "MINUTE", "SECOND", "WEEK", "QUARTER").foreach {
56+
level =>
57+
val name = s"Timestamp Truncate - $level"
58+
val query = s"select date_trunc('$level', ts) from parquetV1Table"
59+
runExpressionBenchmark(name, values, query)
7460
}
7561
}
7662
}
@@ -85,16 +71,10 @@ object CometDatetimeExpressionBenchmark extends CometBenchmarkBase {
8571
"spark.sql.parquet.datetimeRebaseModeInWrite" -> "CORRECTED") {
8672

8773
runBenchmarkWithTable("DateTrunc", values) { v =>
88-
dateTruncExprBenchmark(v, useDictionary = false)
89-
}
90-
runBenchmarkWithTable("DateTrunc (Dictionary)", values, useDictionary = true) { v =>
91-
dateTruncExprBenchmark(v, useDictionary = true)
74+
dateTruncExprBenchmark(v)
9275
}
9376
runBenchmarkWithTable("TimestampTrunc", values) { v =>
94-
timestampTruncExprBenchmark(v, useDictionary = false)
95-
}
96-
runBenchmarkWithTable("TimestampTrunc (Dictionary)", values, useDictionary = true) { v =>
97-
timestampTruncExprBenchmark(v, useDictionary = true)
77+
timestampTruncExprBenchmark(v)
9878
}
9979
}
10080
}

0 commit comments

Comments
 (0)