Skip to content

Commit 7c01009

Browse files
committed
address review comments
1 parent 93eccdf commit 7c01009

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

spark/src/main/spark-4.1/org/apache/comet/shims/CometExprShim.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ trait CometExprShim extends CommonStringExprs {
155155
inputs,
156156
binding)
157157
case (Literal(parser: ToTimeParser, _), "parse", args)
158-
if i.dataType.isInstanceOf[TimeType] && parser.fmt.isEmpty =>
158+
if i.dataType.isInstanceOf[TimeType] && parser.fmt.isEmpty && args.size == 1 =>
159159
val childExprs = args.map(exprToProtoInternal(_, inputs, binding))
160160
val optExpr =
161161
scalarFunctionExprToProtoWithReturnType("to_time", i.dataType, true, childExprs: _*)
@@ -167,7 +167,7 @@ trait CometExprShim extends CommonStringExprs {
167167
case TryEval(i: Invoke) =>
168168
(i.targetObject, i.functionName, i.arguments) match {
169169
case (Literal(parser: ToTimeParser, _), "parse", args)
170-
if i.dataType.isInstanceOf[TimeType] && parser.fmt.isEmpty =>
170+
if i.dataType.isInstanceOf[TimeType] && parser.fmt.isEmpty && args.size == 1 =>
171171
val childExprs = args.map(exprToProtoInternal(_, inputs, binding))
172172
val optExpr = scalarFunctionExprToProtoWithReturnType(
173173
"to_time",

spark/src/test/resources/sql-tests/expressions/datetime/to_time.sql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,16 @@ SELECT try_to_time(' 1:00:00 PM')
245245
-- to_time with format pattern falls back to Spark (not supported natively)
246246
query expect_fallback(invoke is not supported)
247247
SELECT to_time('12:30:45', 'HH:mm:ss')
248+
249+
statement
250+
CREATE TABLE test_to_time_col_fmt(s STRING, f STRING) USING parquet
251+
252+
statement
253+
INSERT INTO test_to_time_col_fmt VALUES
254+
('14.30.00', 'HH.mm.ss'),
255+
('1230', 'HHmm')
256+
257+
-- A non-foldable format column should fall back to Spark because Comet does
258+
-- not implement the format-pattern variant of to_time.
259+
query expect_fallback(invoke is not supported)
260+
SELECT to_time(s, f) FROM test_to_time_col_fmt

0 commit comments

Comments
 (0)