Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
maropu committed Dec 28, 2017
1 parent 179c6fd commit 1c94418
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -668,21 +668,17 @@ object TypeCoercion {
*/
case class ConcatCoercion(conf: SQLConf) extends TypeCoercionRule {

private def typeCastToString(c: Concat): Concat = {
val newChildren = c.children.map { e =>
ImplicitTypeCasts.implicitCast(e, StringType).getOrElse(e)
}
c.copy(children = newChildren)
}

override protected def coerceTypes(plan: LogicalPlan): LogicalPlan = plan transform { case p =>
p transformExpressionsUp {
// Skip nodes if unresolved or empty children
case c @ Concat(children) if !c.childrenResolved || children.isEmpty => c

case c @ Concat(children) if conf.concatBinaryAsString ||
!children.map(_.dataType).forall(_ == BinaryType) =>
typeCastToString(c)
val newChildren = c.children.map { e =>
ImplicitTypeCasts.implicitCast(e, StringType).getOrElse(e)
}
c.copy(children = newChildren)
}
}
}
Expand Down

0 comments on commit 1c94418

Please sign in to comment.