Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ class VeloxTestSettings extends BackendTestSettings {
.exclude("cast from timestamp II")
.exclude("SPARK-36286: invalid string cast to timestamp")
.exclude("SPARK-39749: cast Decimal to string")
// TODO: fix in Spark-4.0
.exclude("Casting to char/varchar")
enableSuite[GlutenTryCastSuite]
.exclude(
"Process Infinity, -Infinity, NaN in case insensitive manner" // +inf not supported in folly.
Expand All @@ -119,8 +117,6 @@ class VeloxTestSettings extends BackendTestSettings {
.exclude("data type casting")
// Revised by setting timezone through config and commented unsupported cases.
.exclude("cast string to timestamp")
// TODO: fix in Spark-4.0
.exclude("Casting to char/varchar")
enableSuite[GlutenCollectionExpressionsSuite]
// Rewrite in Gluten to replace Seq with Array
.exclude("Shuffle")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ import java.sql.{Date, Timestamp}
import java.util.{Calendar, TimeZone}

class GlutenCastSuite extends CastWithAnsiOffSuite with GlutenTestsTrait {
override def beforeAll(): Unit = {
super.beforeAll()
// Need to explicitly set spark.sql.preserveCharVarcharTypeInfo=true for gluten's test
// framework. In Gluten, it overrides the checkEvaluation that invokes Spark's RowEncoder,
// which requires this configuration to be set.
// In Vanilla spark, the checkEvaluation method doesn't invoke RowEncoder.
conf.setConf(SQLConf.PRESERVE_CHAR_VARCHAR_TYPE_INFO, true)
}

override def cast(v: Any, targetType: DataType, timeZoneId: Option[String] = None): Cast = {
v match {
Expand Down Expand Up @@ -287,5 +295,4 @@ class GlutenCastSuite extends CastWithAnsiOffSuite with GlutenTestsTrait {
val d = Decimal(c.getTimeInMillis.toDouble / 1000)
checkEvaluation(cast(d, TimestampType), new Timestamp(c.getTimeInMillis))
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,21 @@ import org.apache.spark.sql.GlutenTestsTrait
import org.apache.spark.sql.catalyst.util.DateTimeTestUtils.{withDefaultTimeZone, ALL_TIMEZONES, UTC, UTC_OPT}
import org.apache.spark.sql.catalyst.util.DateTimeUtils.{fromJavaTimestamp, millisToMicros, TimeZoneUTC}
import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.types.{BinaryType, ByteType, DateType, Decimal, DecimalType, DoubleType, FloatType, IntegerType, LongType, ShortType, StringType, TimestampType}
import org.apache.spark.sql.types._
import org.apache.spark.util.DebuggableThreadUtils

import java.sql.{Date, Timestamp}
import java.util.{Calendar, TimeZone}

class GlutenTryCastSuite extends TryCastSuite with GlutenTestsTrait {
override def beforeAll(): Unit = {
super.beforeAll()
// Need to explicitly set spark.sql.preserveCharVarcharTypeInfo=true for gluten's test
// framework. In Gluten, it overrides the checkEvaluation that invokes Spark's RowEncoder,
// which requires this configuration to be set.
// In Vanilla spark, the checkEvaluation method doesn't invoke RowEncoder.
conf.setConf(SQLConf.PRESERVE_CHAR_VARCHAR_TYPE_INFO, true)
}

testGluten("data type casting") {
val sd = "1970-01-01"
Expand Down