This is an automated email from the ASF dual-hosted git repository.
maxgekk 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 031310bcc339 [SPARK-52660][SQL] Add time type to
`CodeGenerator#javaClass`
031310bcc339 is described below
commit 031310bcc3397fe39cff6c6210cde5bd854dee7e
Author: Bruce Robbins <[email protected]>
AuthorDate: Thu Jul 3 14:23:00 2025 +0200
[SPARK-52660][SQL] Add time type to `CodeGenerator#javaClass`
### What changes were proposed in this pull request?
Update `CodeGenerator#javaClass` to map `TimeType` to `Long`.
### Why are the changes needed?
The change is needed to fully support wholestage codegen for code using the
time type. Without this change, the following query gets an error compiling the
generated code (and falls back to non-wholestage codegen):
```
create or replace temp view v1(col1) as values
(time'22:33:01'),
(time'01:33:01'),
(null);
select max(col1), min(col1) from v1;
```
### Does this PR introduce _any_ user-facing change?
No. The time type is not released yet.
### How was this patch tested?
New test.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #51354 from bersprockets/time_agg_issue.
Authored-by: Bruce Robbins <[email protected]>
Signed-off-by: Max Gekk <[email protected]>
---
.../sql/catalyst/expressions/codegen/CodeGenerator.scala | 2 +-
.../org/apache/spark/sql/DataFrameAggregateSuite.scala | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
index 2564d4eab9bd..6b2c696fb993 100644
---
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
+++
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
@@ -1989,7 +1989,7 @@ object CodeGenerator extends Logging {
case ByteType => java.lang.Byte.TYPE
case ShortType => java.lang.Short.TYPE
case IntegerType | DateType | _: YearMonthIntervalType =>
java.lang.Integer.TYPE
- case LongType | TimestampType | TimestampNTZType | _: DayTimeIntervalType
=>
+ case LongType | TimestampType | TimestampNTZType | _: DayTimeIntervalType
| _: TimeType =>
java.lang.Long.TYPE
case FloatType => java.lang.Float.TYPE
case DoubleType => java.lang.Double.TYPE
diff --git
a/sql/core/src/test/scala/org/apache/spark/sql/DataFrameAggregateSuite.scala
b/sql/core/src/test/scala/org/apache/spark/sql/DataFrameAggregateSuite.scala
index 1ae64085bbb7..b7f129c35c5d 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/DataFrameAggregateSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/DataFrameAggregateSuite.scala
@@ -2915,6 +2915,22 @@ class DataFrameAggregateSuite extends QueryTest
assert (df.schema == expectedSchema)
checkAnswer(df, Seq(Row(LocalTime.parse(ts1), 2),
Row(LocalTime.parse(ts2), 1)))
}
+
+ test("SPARK-52660: Support aggregation of Time column when codegen is
split") {
+ val res = sql(
+ "SELECT max(expr), MIN(expr) " +
+ "FROM VALUES TIME'22:01:00', " +
+ "TIME'22:00:00', " +
+ "TIME'15:00:00', " +
+ "TIME'22:01:00', " +
+ "TIME'13:22:01', " +
+ "TIME'03:00:00', " +
+ "TIME'22:00:00', " +
+ "TIME'17:45:00' AS tab(expr);")
+ checkAnswer(
+ res,
+ Row(LocalTime.of(22, 1, 0), LocalTime.of(3, 0, 0)))
+ }
}
case class B(c: Option[Double])
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]