uros-db commented on code in PR #51575: URL: https://github.com/apache/spark/pull/51575#discussion_r2223811295
########## sql/core/src/test/scala/org/apache/spark/sql/TimeFunctionsSuiteBase.scala: ########## @@ -161,6 +161,150 @@ abstract class TimeFunctionsSuiteBase extends QueryTest with SharedSparkSession checkAnswer(result1, expected) checkAnswer(result2, expected) } + + test("SPARK-52883: to_time function without format") { + // Input data for the function. + val schema = StructType(Seq( + StructField("str", StringType, nullable = false) + )) + val data = Seq( + Row("00:00:00"), + Row("01:02:03.4"), + Row("23:59:59.999999") + ) + val df = spark.createDataFrame(spark.sparkContext.parallelize(data), schema) + + // Test the function using both `selectExpr` and `select`. + val result1 = df.selectExpr( + "to_time(str)" + ) + val result2 = df.select( + to_time(col("str")) + ) + // Check that both methods produce the same result. + checkAnswer(result1, result2) + + // Expected output of the function. + val expected = Seq( + "00:00:00", + "01:02:03.4", + "23:59:59.999999" + ).toDF("timeString").select(col("timeString").cast("time")) + // Check that the results match the expected output. + checkAnswer(result1, expected) + checkAnswer(result2, expected) + } + + test("SPARK-52883: to_time function with format") { Review Comment: I kind of described this in: https://github.com/apache/spark/pull/51575#discussion_r2217748094. TLDR: I don't think that we need to go super deep with scala function tests here. We already have extensive testing, so here I would focus on the bare minimum. Otherwise, we explode the testing space quite a bit, if we want to do this for every expression/function. -- 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