Skip to content
Closed
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 @@ -58,7 +58,7 @@ case class Concat(children: Seq[Expression]) extends Expression {
} else {
val childTypes = children.map(_.dataType)
if (childTypes.exists(tpe => !Seq(StringType, BinaryType).contains(tpe))) {
TypeCheckResult.TypeCheckFailure(
return TypeCheckResult.TypeCheckFailure(
s"input to function $prettyName should have StringType or BinaryType, but it's " +
childTypes.map(_.simpleString).mkString("[", ", ", "]"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ class StringExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
checkEvaluation(Concat(strs.map(Literal.create(_, StringType))), strs.mkString, EmptyRow)
}

test("SPARK-22771 Check Concat.checkInputDataTypes results") {
assert(Concat(Seq.empty[Expression]).checkInputDataTypes().isSuccess)
assert(Concat(Literal.create("a") :: Literal.create("b") :: Nil)
.checkInputDataTypes().isSuccess)
assert(Concat(Literal.create("a".getBytes) :: Literal.create("b".getBytes) :: Nil)
.checkInputDataTypes().isSuccess)
assert(Concat(Literal.create(1) :: Literal.create(2) :: Nil)
.checkInputDataTypes().isFailure)
assert(Concat(Literal.create("a") :: Literal.create("b".getBytes) :: Nil)
.checkInputDataTypes().isFailure)
}

test("concat_ws") {
def testConcatWs(expected: String, sep: String, inputs: Any*): Unit = {
val inputExprs = inputs.map {
Expand Down