Skip to content

Commit

Permalink
fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
stefankandic committed Jan 23, 2025
1 parent 30b05b3 commit ec0ad23
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,10 @@ object ResolveDefaultStringTypes extends Rule[LogicalPlan] {
case expression if needsCast(expression) =>
expression.setTagValue(CAST_ADDED_TAG, ())
newType => {
val replacedType = replaceDefaultStringType(expression.dataType, newType)
if (newType == StringType || replacedType.sameType(newType)) {
if (newType == StringType) {
expression
} else {
Cast(expression, replacedType)
Cast(expression, replaceDefaultStringType(expression.dataType, newType))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import org.apache.spark.sql.catalyst.util.DateTimeUtils
import org.apache.spark.sql.catalyst.util.DateTimeUtils.{convertSpecialDate, convertSpecialTimestamp, convertSpecialTimestampNTZ, instantToMicros, localDateTimeToMicros}
import org.apache.spark.sql.catalyst.util.TypeUtils.toSQLExpr
import org.apache.spark.sql.connector.catalog.CatalogManager
import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.types._


Expand Down Expand Up @@ -153,14 +152,15 @@ case class ReplaceCurrentLike(catalogManager: CatalogManager) extends Rule[Logic
val currentCatalog = catalogManager.currentCatalog.name()
val currentUser = CurrentUserContext.getCurrentUser

plan.transformAllExpressionsWithPruning(_.containsPattern(CURRENT_LIKE)) {
val res = plan.transformAllExpressionsWithPruning(_.containsPattern(CURRENT_LIKE)) {
case CurrentDatabase() =>
Literal.create(currentNamespace, SQLConf.get.defaultStringType)
Literal.create(currentNamespace)
case CurrentCatalog() =>
Literal.create(currentCatalog, SQLConf.get.defaultStringType)
Literal.create(currentCatalog)
case CurrentUser() =>
Literal.create(currentUser, SQLConf.get.defaultStringType)
Literal.create(currentUser)
}
res
}
}

Expand Down

0 comments on commit ec0ad23

Please sign in to comment.