You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by we...@apache.org on 2017/11/23 17:20:23 UTC

spark git commit: [SPARK-17920][FOLLOWUP] simplify the schema file creation in test

Repository: spark
Updated Branches:
  refs/heads/master b4edafa99 -> 42f83d7c4


[SPARK-17920][FOLLOWUP] simplify the schema file creation in test

## What changes were proposed in this pull request?

a followup of https://github.com/apache/spark/pull/19779 , to simplify the file creation.

## How was this patch tested?

test only change

Author: Wenchen Fan <we...@databricks.com>

Closes #19799 from cloud-fan/minor.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/42f83d7c
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/42f83d7c
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/42f83d7c

Branch: refs/heads/master
Commit: 42f83d7c40bb4e9c7c50f2cbda515b331fb2097f
Parents: b4edafa
Author: Wenchen Fan <we...@databricks.com>
Authored: Thu Nov 23 18:20:16 2017 +0100
Committer: Wenchen Fan <we...@databricks.com>
Committed: Thu Nov 23 18:20:16 2017 +0100

----------------------------------------------------------------------
 .../spark/sql/hive/client/VersionsSuite.scala   | 21 +++++++++-----------
 1 file changed, 9 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/42f83d7c/sql/hive/src/test/scala/org/apache/spark/sql/hive/client/VersionsSuite.scala
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/client/VersionsSuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/client/VersionsSuite.scala
index fbf6877..9d15dab 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/client/VersionsSuite.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/client/VersionsSuite.scala
@@ -843,15 +843,12 @@ class VersionsSuite extends SparkFunSuite with Logging {
 
     test(s"$version: SPARK-17920: Insert into/overwrite avro table") {
       withTempDir { dir =>
-        val path = dir.getAbsolutePath
-        val schemaPath = s"""$path${File.separator}avroschemadir"""
-
-        new File(schemaPath).mkdir()
         val avroSchema =
-          """{
+          """
+            |{
             |  "name": "test_record",
             |  "type": "record",
-            |  "fields": [ {
+            |  "fields": [{
             |    "name": "f0",
             |    "type": [
             |      "null",
@@ -862,17 +859,17 @@ class VersionsSuite extends SparkFunSuite with Logging {
             |        "logicalType": "decimal"
             |      }
             |    ]
-            |  } ]
+            |  }]
             |}
           """.stripMargin
-        val schemaUrl = s"""$schemaPath${File.separator}avroDecimal.avsc"""
-        val schemaFile = new File(schemaPath, "avroDecimal.avsc")
+        val schemaFile = new File(dir, "avroDecimal.avsc")
         val writer = new PrintWriter(schemaFile)
         writer.write(avroSchema)
         writer.close()
+        val schemaPath = schemaFile.getCanonicalPath
 
         val url = Thread.currentThread().getContextClassLoader.getResource("avroDecimal")
-        val srcLocation = new File(url.getFile)
+        val srcLocation = new File(url.getFile).getCanonicalPath
         val destTableName = "tab1"
         val srcTableName = "tab2"
 
@@ -886,7 +883,7 @@ class VersionsSuite extends SparkFunSuite with Logging {
                |  INPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat'
                |  OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat'
                |LOCATION '$srcLocation'
-               |TBLPROPERTIES ('avro.schema.url' = '$schemaUrl')
+               |TBLPROPERTIES ('avro.schema.url' = '$schemaPath')
            """.stripMargin
           )
 
@@ -898,7 +895,7 @@ class VersionsSuite extends SparkFunSuite with Logging {
                |STORED AS
                |  INPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat'
                |  OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat'
-               |TBLPROPERTIES ('avro.schema.url' = '$schemaUrl')
+               |TBLPROPERTIES ('avro.schema.url' = '$schemaPath')
            """.stripMargin
           )
           versionSpark.sql(


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org