File tree Expand file tree Collapse file tree
spark/src/test/scala/org/apache/comet Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -437,15 +437,13 @@ class CometCastSuite extends CometTestBase with AdaptiveSparkPlanHelper {
437437 }
438438
439439 test(" cast LongType to TimestampType" ) {
440- // Use assertDataFrameEquals because extreme Long values (Long.MIN_VALUE, Long.MAX_VALUE)
441- // overflow when converted to java.sql.Timestamp during collect(), but the cast itself works.
440+ // Cast back to long avoids java.sql.Timestamp overflow during collect() for extreme values
442441 compatibleTimezones.foreach { tz =>
443442 withSQLConf(SQLConf .SESSION_LOCAL_TIMEZONE .key -> tz) {
444- withTempPath { dir =>
445- val data = roundtripParquet(generateLongs(), dir).coalesce(1 )
446- data.createOrReplaceTempView(" t1" )
447- val df = spark.sql(" select a, cast(a as timestamp) from t1" )
448- assertDataFrameEquals(df)
443+ withTable(" t1" ) {
444+ generateLongs().write.saveAsTable(" t1" )
445+ val df = spark.sql(" select a, cast(cast(a as timestamp) as long) from t1" )
446+ checkSparkAnswerAndOperator(df)
449447 }
450448 }
451449 }
You can’t perform that action at this time.
0 commit comments