vinodkc commented on code in PR #50525: URL: https://github.com/apache/spark/pull/50525#discussion_r2031235530
########## sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/TimeExpressionsSuite.scala: ########## @@ -168,4 +168,62 @@ class TimeExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper { checkConsistencyBetweenInterpretedAndCodegen( (child: Expression) => MinutesOfTime(child).replacement, TimeType()) } + + test("SecondExpressionBuilder") { + // Empty expressions list + checkError( + exception = intercept[AnalysisException] { + SecondExpressionBuilder.build("second", Seq.empty) + }, + condition = "WRONG_NUM_ARGS.WITHOUT_SUGGESTION", + parameters = Map( + "functionName" -> "`second`", + "expectedNum" -> "> 0", + "actualNum" -> "0", + "docroot" -> SPARK_DOC_ROOT) + ) + + // test TIME-typed child should build SecondsOfTime + val timeExpr = Literal(localTime(12, 58, 59), TimeType()) + val builtExprForTime = SecondExpressionBuilder.build("second", Seq(timeExpr)) + assert(builtExprForTime.isInstanceOf[SecondsOfTime]) + assert(builtExprForTime.asInstanceOf[SecondsOfTime].child eq timeExpr) + + // test non TIME-typed child should build second + val tsExpr = Literal("2007-09-03 10:45:23") + val builtExprForTs = SecondExpressionBuilder.build("second", Seq(tsExpr)) + assert(builtExprForTs.isInstanceOf[Second]) + assert(builtExprForTs.asInstanceOf[Second].child eq tsExpr) + } + + test("Second with TIME type") { + // A few test times in microseconds since midnight: + // time in microseconds -> expected second + val testTimes = Seq( Review Comment: @senthh , I updated the above comment; please check -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org