@@ -843,15 +843,12 @@ class VersionsSuite extends SparkFunSuite with Logging {
843
843
844
844
test(s " $version: SPARK-17920: Insert into/overwrite avro table " ) {
845
845
withTempDir { dir =>
846
- val path = dir.getAbsolutePath
847
- val schemaPath = s """ $path${File .separator}avroschemadir """
848
-
849
- new File (schemaPath).mkdir()
850
846
val avroSchema =
851
- """ {
847
+ """
848
+ |{
852
849
| "name": "test_record",
853
850
| "type": "record",
854
- | "fields": [ {
851
+ | "fields": [{
855
852
| "name": "f0",
856
853
| "type": [
857
854
| "null",
@@ -862,17 +859,17 @@ class VersionsSuite extends SparkFunSuite with Logging {
862
859
| "logicalType": "decimal"
863
860
| }
864
861
| ]
865
- | } ]
862
+ | }]
866
863
|}
867
864
""" .stripMargin
868
- val schemaUrl = s """ $schemaPath${File .separator}avroDecimal.avsc """
869
- val schemaFile = new File (schemaPath, " avroDecimal.avsc" )
865
+ val schemaFile = new File (dir, " avroDecimal.avsc" )
870
866
val writer = new PrintWriter (schemaFile)
871
867
writer.write(avroSchema)
872
868
writer.close()
869
+ val schemaPath = schemaFile.getCanonicalPath
873
870
874
871
val url = Thread .currentThread().getContextClassLoader.getResource(" avroDecimal" )
875
- val srcLocation = new File (url.getFile)
872
+ val srcLocation = new File (url.getFile).getCanonicalPath
876
873
val destTableName = " tab1"
877
874
val srcTableName = " tab2"
878
875
@@ -886,7 +883,7 @@ class VersionsSuite extends SparkFunSuite with Logging {
886
883
| INPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat'
887
884
| OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat'
888
885
|LOCATION ' $srcLocation'
889
- |TBLPROPERTIES ('avro.schema.url' = ' $schemaUrl ')
886
+ |TBLPROPERTIES ('avro.schema.url' = ' $schemaPath ')
890
887
""" .stripMargin
891
888
)
892
889
@@ -898,7 +895,7 @@ class VersionsSuite extends SparkFunSuite with Logging {
898
895
|STORED AS
899
896
| INPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat'
900
897
| OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat'
901
- |TBLPROPERTIES ('avro.schema.url' = ' $schemaUrl ')
898
+ |TBLPROPERTIES ('avro.schema.url' = ' $schemaPath ')
902
899
""" .stripMargin
903
900
)
904
901
versionSpark.sql(
0 commit comments