diff options
author | uncleGen <hustyugm@gmail.com> | 2017-03-05 03:35:42 -0800 |
---|---|---|
committer | Herman van Hovell <hvanhovell@databricks.com> | 2017-03-05 03:35:42 -0800 |
commit | f48461ab2bdb91cd00efa5a5ec4b0b2bc361e7a2 (patch) | |
tree | 0c12530aa99b888e5ea78dc5c5c6f410c0c80b64 /sql/core/src/test | |
parent | 42c4cd9e2a44eaa6a16e3b490eb82b6292d9b2ea (diff) | |
download | spark-f48461ab2bdb91cd00efa5a5ec4b0b2bc361e7a2.tar.gz spark-f48461ab2bdb91cd00efa5a5ec4b0b2bc361e7a2.tar.bz2 spark-f48461ab2bdb91cd00efa5a5ec4b0b2bc361e7a2.zip |
[SPARK-19805][TEST] Log the row type when query result dose not match
## What changes were proposed in this pull request?
improve the log message when query result does not match.
before pr:
```
== Results ==
!== Correct Answer - 3 == == Spark Answer - 3 ==
[1] [1]
[2] [2]
[3] [3]
```
after pr:
~~== Results ==
!== Correct Answer - 3 == == Spark Answer - 3 ==
!RowType[string] RowType[integer]
[1] [1]
[2] [2]
[3] [3]~~
```
== Results ==
!== Correct Answer - 3 == == Spark Answer - 3 ==
!struct<value:string> struct<value:int>
[1] [1]
[2] [2]
[3] [3]
```
## How was this patch tested?
Jenkins
Author: uncleGen <hustyugm@gmail.com>
Closes #17145 from uncleGen/improve-test-result.
Diffstat (limited to 'sql/core/src/test')
-rw-r--r-- | sql/core/src/test/scala/org/apache/spark/sql/QueryTest.scala | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/QueryTest.scala b/sql/core/src/test/scala/org/apache/spark/sql/QueryTest.scala index 34fa626e00..f9808834df 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/QueryTest.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/QueryTest.scala @@ -312,13 +312,23 @@ object QueryTest { sparkAnswer: Seq[Row], isSorted: Boolean = false): Option[String] = { if (prepareAnswer(expectedAnswer, isSorted) != prepareAnswer(sparkAnswer, isSorted)) { + val getRowType: Option[Row] => String = row => + row.map(row => + if (row.schema == null) { + "struct<>" + } else { + s"${row.schema.catalogString}" + }).getOrElse("struct<>") + val errorMessage = s""" |== Results == |${sideBySide( s"== Correct Answer - ${expectedAnswer.size} ==" +: + getRowType(expectedAnswer.headOption) +: prepareAnswer(expectedAnswer, isSorted).map(_.toString()), s"== Spark Answer - ${sparkAnswer.size} ==" +: + getRowType(sparkAnswer.headOption) +: prepareAnswer(sparkAnswer, isSorted).map(_.toString())).mkString("\n")} """.stripMargin return Some(errorMessage) |