Skip to content
Prev Previous commit
Fix
  • Loading branch information
maropu committed Dec 29, 2017
commit b9febbdd928c4fa2cba29eaaef85ffcc173c1b44
Original file line number Diff line number Diff line change
Expand Up @@ -659,12 +659,14 @@ object CombineConcats extends Rule[LogicalPlan] {
Concat(flattened)
}

private def hasNestedConcats(concat: Concat): Boolean = concat.children.exists {
case c: Concat => true
case c @ Cast(Concat(children), StringType, _) => true
case _ => false
}

def apply(plan: LogicalPlan): LogicalPlan = plan.transformExpressionsDown {
case concat: Concat if concat.children.exists {
case c: Concat => true
case c @ Cast(Concat(children), StringType, _) => true
case _ => false
} =>
case concat: Concat if hasNestedConcats(concat) =>
flattenConcats(concat)
}
}