aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Kadner <ckadner@us.ibm.com>2015-08-06 14:15:42 -0700
committerMichael Armbrust <michael@databricks.com>2015-08-06 14:15:42 -0700
commitabfedb9cd70af60c8290bd2f5a5cec1047845ba0 (patch)
tree4a4d62ab67106bfd1d4e332a89808ba41ce2bf85
parent54c0789a05a783ce90e0e9848079be442a82966b (diff)
downloadspark-abfedb9cd70af60c8290bd2f5a5cec1047845ba0.tar.gz
spark-abfedb9cd70af60c8290bd2f5a5cec1047845ba0.tar.bz2
spark-abfedb9cd70af60c8290bd2f5a5cec1047845ba0.zip
[SPARK-9211] [SQL] [TEST] normalize line separators before generating MD5 hash
The golden answer file names for the existing Hive comparison tests were generated using a MD5 hash of the query text which uses Unix-style line separator characters `\n` (LF). This PR ensures that all occurrences of the Windows-style line separator `\r\n` (CR) are replaced with `\n` (LF) before generating the MD5 hash to produce an identical MD5 hash for golden answer file names generated on Windows. Author: Christian Kadner <ckadner@us.ibm.com> Closes #7563 from ckadner/SPARK-9211_working and squashes the following commits: d541db0 [Christian Kadner] [SPARK-9211][SQL] normalize line separators before MD5 hash
-rw-r--r--sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveComparisonTest.scala2
-rw-r--r--sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala8
2 files changed, 5 insertions, 5 deletions
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveComparisonTest.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveComparisonTest.scala
index 638b9c8103..2bdb0e1187 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveComparisonTest.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveComparisonTest.scala
@@ -124,7 +124,7 @@ abstract class HiveComparisonTest
protected val cacheDigest = java.security.MessageDigest.getInstance("MD5")
protected def getMd5(str: String): String = {
val digest = java.security.MessageDigest.getInstance("MD5")
- digest.update(str.getBytes("utf-8"))
+ digest.update(str.replaceAll(System.lineSeparator(), "\n").getBytes("utf-8"))
new java.math.BigInteger(1, digest.digest).toString(16)
}
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
index edb2755367..83f9f3eaa3 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
@@ -427,7 +427,7 @@ class HiveQuerySuite extends HiveComparisonTest with BeforeAndAfter {
|'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
|USING 'cat' AS (tKey, tValue) ROW FORMAT SERDE
|'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' FROM src;
- """.stripMargin.replaceAll("\n", " "))
+ """.stripMargin.replaceAll(System.lineSeparator(), " "))
test("transform with SerDe2") {
@@ -446,7 +446,7 @@ class HiveQuerySuite extends HiveComparisonTest with BeforeAndAfter {
|('avro.schema.literal'='{"namespace": "testing.hive.avro.serde","name":
|"src","type": "record","fields": [{"name":"key","type":"int"}]}')
|FROM small_src
- """.stripMargin.replaceAll("\n", " ")).collect().head
+ """.stripMargin.replaceAll(System.lineSeparator(), " ")).collect().head
assert(expected(0) === res(0))
}
@@ -458,7 +458,7 @@ class HiveQuerySuite extends HiveComparisonTest with BeforeAndAfter {
|('serialization.last.column.takes.rest'='true') USING 'cat' AS (tKey, tValue)
|ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
|WITH SERDEPROPERTIES ('serialization.last.column.takes.rest'='true') FROM src;
- """.stripMargin.replaceAll("\n", " "))
+ """.stripMargin.replaceAll(System.lineSeparator(), " "))
createQueryTest("transform with SerDe4",
"""
@@ -467,7 +467,7 @@ class HiveQuerySuite extends HiveComparisonTest with BeforeAndAfter {
|('serialization.last.column.takes.rest'='true') USING 'cat' ROW FORMAT SERDE
|'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' WITH SERDEPROPERTIES
|('serialization.last.column.takes.rest'='true') FROM src;
- """.stripMargin.replaceAll("\n", " "))
+ """.stripMargin.replaceAll(System.lineSeparator(), " "))
createQueryTest("LIKE",
"SELECT * FROM src WHERE value LIKE '%1%'")