You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by li...@apache.org on 2018/01/04 13:15:25 UTC
spark git commit: [SPARK-22771][SQL] Add a missing return statement
in Concat.checkInputDataTypes
Repository: spark
Updated Branches:
refs/heads/master 5aadbc929 -> 6f68316e9
[SPARK-22771][SQL] Add a missing return statement in Concat.checkInputDataTypes
## What changes were proposed in this pull request?
This pr is a follow-up to fix a bug left in #19977.
## How was this patch tested?
Added tests in `StringExpressionsSuite`.
Author: Takeshi Yamamuro <ya...@apache.org>
Closes #20149 from maropu/SPARK-22771-FOLLOWUP.
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/6f68316e
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/6f68316e
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/6f68316e
Branch: refs/heads/master
Commit: 6f68316e98fad72b171df422566e1fc9a7bbfcde
Parents: 5aadbc9
Author: Takeshi Yamamuro <ya...@apache.org>
Authored: Thu Jan 4 21:15:10 2018 +0800
Committer: gatorsmile <ga...@gmail.com>
Committed: Thu Jan 4 21:15:10 2018 +0800
----------------------------------------------------------------------
.../sql/catalyst/expressions/stringExpressions.scala | 2 +-
.../catalyst/expressions/StringExpressionsSuite.scala | 12 ++++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/6f68316e/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala
----------------------------------------------------------------------
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala
index b0da55a..41dc762 100755
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala
@@ -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("[", ", ", "]"))
}
http://git-wip-us.apache.org/repos/asf/spark/blob/6f68316e/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/StringExpressionsSuite.scala
----------------------------------------------------------------------
diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/StringExpressionsSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/StringExpressionsSuite.scala
index 54cde77..97ddbeb 100644
--- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/StringExpressionsSuite.scala
+++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/StringExpressionsSuite.scala
@@ -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 {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org