Skip to content

Commit f7693f0

Browse files
committed
fix
1 parent 568055d commit f7693f0

7 files changed

Lines changed: 76 additions & 54 deletions

File tree

sql/hive/src/test/scala/org/apache/spark/sql/sources/HadoopFsRelationTest.scala renamed to sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/HadoopFsRelationTest.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
package org.apache.spark.sql.sources
18+
package org.apache.spark.sql.execution.datasources
1919

2020
import java.io.File
2121

@@ -26,15 +26,14 @@ import org.apache.hadoop.fs.Path
2626
import org.apache.spark.deploy.SparkHadoopUtil
2727
import org.apache.spark.sql._
2828
import org.apache.spark.sql.execution.DataSourceScanExec
29-
import org.apache.spark.sql.execution.datasources._
30-
import org.apache.spark.sql.hive.test.TestHiveSingleton
3129
import org.apache.spark.sql.internal.SQLConf
32-
import org.apache.spark.sql.test.SQLTestUtils
30+
import org.apache.spark.sql.sources.SimpleTextSource
31+
import org.apache.spark.sql.test.{SharedSQLContext, SQLTestUtils}
3332
import org.apache.spark.sql.types._
3433

3534

36-
abstract class HadoopFsRelationTest extends QueryTest with SQLTestUtils with TestHiveSingleton {
37-
import spark.implicits._
35+
abstract class HadoopFsRelationTest extends QueryTest with SQLTestUtils with SharedSQLContext {
36+
import testImplicits._
3837

3938
val dataSourceName: String
4039

sql/hive/src/test/scala/org/apache/spark/sql/sources/JsonHadoopFsRelationSuite.scala renamed to sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/json/JsonHadoopFsRelationSuite.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
* limitations under the License.
1616
*/
1717

18-
package org.apache.spark.sql.sources
18+
package org.apache.spark.sql.execution.datasources.json
1919

2020
import java.math.BigDecimal
2121

2222
import org.apache.hadoop.fs.Path
2323

2424
import org.apache.spark.sql.Row
2525
import org.apache.spark.sql.catalyst.catalog.CatalogUtils
26+
import org.apache.spark.sql.execution.datasources.HadoopFsRelationTest
2627
import org.apache.spark.sql.types._
2728

2829
class JsonHadoopFsRelationSuite extends HadoopFsRelationTest {

sql/hive/src/test/scala/org/apache/spark/sql/hive/orc/OrcHadoopFsRelationSuite.scala renamed to sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/orc/OrcHadoopFsRelationSuite.scala

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,14 @@
1515
* limitations under the License.
1616
*/
1717

18-
package org.apache.spark.sql.hive.orc
19-
20-
import java.io.File
18+
package org.apache.spark.sql.execution.datasources.orc
2119

2220
import org.apache.hadoop.fs.Path
2321

2422
import org.apache.spark.sql.Row
2523
import org.apache.spark.sql.catalyst.catalog.CatalogUtils
24+
import org.apache.spark.sql.execution.datasources.HadoopFsRelationTest
2625
import org.apache.spark.sql.internal.SQLConf
27-
import org.apache.spark.sql.sources.HadoopFsRelationTest
2826
import org.apache.spark.sql.types._
2927

3028
class OrcHadoopFsRelationSuite extends HadoopFsRelationTest {
@@ -82,44 +80,4 @@ class OrcHadoopFsRelationSuite extends HadoopFsRelationTest {
8280
}
8381
}
8482
}
85-
86-
test("SPARK-13543: Support for specifying compression codec for ORC via option()") {
87-
withTempPath { dir =>
88-
val path = s"${dir.getCanonicalPath}/table1"
89-
val df = (1 to 5).map(i => (i, (i % 2).toString)).toDF("a", "b")
90-
df.write
91-
.option("compression", "ZlIb")
92-
.orc(path)
93-
94-
// Check if this is compressed as ZLIB.
95-
val maybeOrcFile = new File(path).listFiles().find { f =>
96-
!f.getName.startsWith("_") && f.getName.endsWith(".zlib.orc")
97-
}
98-
assert(maybeOrcFile.isDefined)
99-
val orcFilePath = maybeOrcFile.get.toPath.toString
100-
val expectedCompressionKind =
101-
OrcFileOperator.getFileReader(orcFilePath).get.getCompression
102-
assert("ZLIB" === expectedCompressionKind.name())
103-
104-
val copyDf = spark
105-
.read
106-
.orc(path)
107-
checkAnswer(df, copyDf)
108-
}
109-
}
110-
111-
test("Default compression codec is snappy for ORC compression") {
112-
withTempPath { file =>
113-
spark.range(0, 10).write
114-
.orc(file.getCanonicalPath)
115-
val expectedCompressionKind =
116-
OrcFileOperator.getFileReader(file.getCanonicalPath).get.getCompression
117-
assert("SNAPPY" === expectedCompressionKind.name())
118-
}
119-
}
120-
}
121-
122-
class HiveOrcHadoopFsRelationSuite extends OrcHadoopFsRelationSuite {
123-
override val dataSourceName: String =
124-
classOf[org.apache.spark.sql.hive.orc.OrcFileFormat].getCanonicalName
12583
}

sql/hive/src/test/scala/org/apache/spark/sql/sources/ParquetHadoopFsRelationSuite.scala renamed to sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetHadoopFsRelationSuite.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
package org.apache.spark.sql.sources
18+
package org.apache.spark.sql.execution.datasources.parquet
1919

2020
import java.io.File
2121

@@ -25,7 +25,7 @@ import org.apache.parquet.hadoop.ParquetOutputFormat
2525

2626
import org.apache.spark.sql._
2727
import org.apache.spark.sql.catalyst.catalog.CatalogUtils
28-
import org.apache.spark.sql.execution.datasources.SQLHadoopMapReduceCommitProtocol
28+
import org.apache.spark.sql.execution.datasources.{HadoopFsRelationTest, SQLHadoopMapReduceCommitProtocol}
2929
import org.apache.spark.sql.internal.SQLConf
3030
import org.apache.spark.sql.types._
3131

@@ -162,7 +162,6 @@ class ParquetHadoopFsRelationSuite extends HadoopFsRelationTest {
162162
}
163163

164164
test("SPARK-11500: Not deterministic order of columns when using merging schemas.") {
165-
import testImplicits._
166165
withSQLConf(SQLConf.PARQUET_SCHEMA_MERGING_ENABLED.key -> "true") {
167166
withTempPath { dir =>
168167
val pathOne = s"${dir.getCanonicalPath}/part=1"

sql/hive/src/test/scala/org/apache/spark/sql/sources/SimpleTextHadoopFsRelationSuite.scala renamed to sql/core/src/test/scala/org/apache/spark/sql/sources/SimpleTextHadoopFsRelationSuite.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import org.apache.hadoop.fs.Path
2121

2222
import org.apache.spark.sql.catalyst.catalog.CatalogUtils
2323
import org.apache.spark.sql.catalyst.expressions.PredicateHelper
24+
import org.apache.spark.sql.execution.datasources.HadoopFsRelationTest
2425
import org.apache.spark.sql.types._
2526

2627
class SimpleTextHadoopFsRelationSuite extends HadoopFsRelationTest with PredicateHelper {

sql/hive/src/test/scala/org/apache/spark/sql/sources/SimpleTextRelation.scala renamed to sql/core/src/test/scala/org/apache/spark/sql/sources/SimpleTextRelation.scala

File renamed without changes.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.spark.sql.hive.orc
19+
20+
import java.io.File
21+
22+
import org.apache.spark.sql.execution.datasources.orc.OrcHadoopFsRelationSuite
23+
24+
class HiveOrcHadoopFsRelationSuite extends OrcHadoopFsRelationSuite {
25+
import testImplicits._
26+
27+
override val dataSourceName: String =
28+
classOf[org.apache.spark.sql.hive.orc.OrcFileFormat].getCanonicalName
29+
30+
test("SPARK-13543: Support for specifying compression codec for ORC via option()") {
31+
withTempPath { dir =>
32+
val path = s"${dir.getCanonicalPath}/table1"
33+
val df = (1 to 5).map(i => (i, (i % 2).toString)).toDF("a", "b")
34+
df.write
35+
.option("compression", "ZlIb")
36+
.orc(path)
37+
38+
// Check if this is compressed as ZLIB.
39+
val maybeOrcFile = new File(path).listFiles().find { f =>
40+
!f.getName.startsWith("_") && f.getName.endsWith(".zlib.orc")
41+
}
42+
assert(maybeOrcFile.isDefined)
43+
val orcFilePath = maybeOrcFile.get.toPath.toString
44+
val expectedCompressionKind =
45+
OrcFileOperator.getFileReader(orcFilePath).get.getCompression
46+
assert("ZLIB" === expectedCompressionKind.name())
47+
48+
val copyDf = spark
49+
.read
50+
.orc(path)
51+
checkAnswer(df, copyDf)
52+
}
53+
}
54+
55+
test("Default compression codec is snappy for ORC compression") {
56+
withTempPath { file =>
57+
spark.range(0, 10).write
58+
.orc(file.getCanonicalPath)
59+
val expectedCompressionKind =
60+
OrcFileOperator.getFileReader(file.getCanonicalPath).get.getCompression
61+
assert("SNAPPY" === expectedCompressionKind.name())
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)