-
Notifications
You must be signed in to change notification settings - Fork 28.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-23158] [SQL] Move HadoopFsRelationTest test suites to from sql/hive to sql/core #20331
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,19 +15,20 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.spark.sql.hive.orc | ||
|
||
import java.io.File | ||
package org.apache.spark.sql.execution.datasources.orc | ||
|
||
import org.apache.hadoop.fs.Path | ||
|
||
import org.apache.spark.sql.Row | ||
import org.apache.spark.sql.catalyst.catalog.CatalogUtils | ||
import org.apache.spark.sql.execution.datasources.HadoopFsRelationTest | ||
import org.apache.spark.sql.internal.SQLConf | ||
import org.apache.spark.sql.sources.HadoopFsRelationTest | ||
import org.apache.spark.sql.test.SharedSQLContext | ||
import org.apache.spark.sql.types._ | ||
|
||
class OrcHadoopFsRelationSuite extends HadoopFsRelationTest { | ||
class OrcHadoopFsRelationSuite extends SharedSQLContext | ||
|
||
abstract class OrcHadoopFsRelationBase extends HadoopFsRelationTest { | ||
import testImplicits._ | ||
|
||
override protected val enableAutoThreadAudit = false | ||
|
@@ -82,44 +83,4 @@ class OrcHadoopFsRelationSuite extends HadoopFsRelationTest { | |
} | ||
} | ||
} | ||
|
||
test("SPARK-13543: Support for specifying compression codec for ORC via option()") { | ||
withTempPath { dir => | ||
val path = s"${dir.getCanonicalPath}/table1" | ||
val df = (1 to 5).map(i => (i, (i % 2).toString)).toDF("a", "b") | ||
df.write | ||
.option("compression", "ZlIb") | ||
.orc(path) | ||
|
||
// Check if this is compressed as ZLIB. | ||
val maybeOrcFile = new File(path).listFiles().find { f => | ||
!f.getName.startsWith("_") && f.getName.endsWith(".zlib.orc") | ||
} | ||
assert(maybeOrcFile.isDefined) | ||
val orcFilePath = maybeOrcFile.get.toPath.toString | ||
val expectedCompressionKind = | ||
OrcFileOperator.getFileReader(orcFilePath).get.getCompression | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same here. |
||
assert("ZLIB" === expectedCompressionKind.name()) | ||
|
||
val copyDf = spark | ||
.read | ||
.orc(path) | ||
checkAnswer(df, copyDf) | ||
} | ||
} | ||
|
||
test("Default compression codec is snappy for ORC compression") { | ||
withTempPath { file => | ||
spark.range(0, 10).write | ||
.orc(file.getCanonicalPath) | ||
val expectedCompressionKind = | ||
OrcFileOperator.getFileReader(file.getCanonicalPath).get.getCompression | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gatorsmile . This test case should be tested on |
||
assert("SNAPPY" === expectedCompressionKind.name()) | ||
} | ||
} | ||
} | ||
|
||
class HiveOrcHadoopFsRelationSuite extends OrcHadoopFsRelationSuite { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is Hive only. Thus, create a separate file for it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you! |
||
override val dataSourceName: String = | ||
classOf[org.apache.spark.sql.hive.orc.OrcFileFormat].getCanonicalName | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.spark.sql.hive.orc | ||
|
||
import java.io.File | ||
|
||
import org.apache.spark.sql.execution.datasources.orc.OrcHadoopFsRelationBase | ||
import org.apache.spark.sql.hive.test.TestHiveSingleton | ||
|
||
class HiveOrcHadoopFsRelationSuite extends OrcHadoopFsRelationBase with TestHiveSingleton { | ||
import testImplicits._ | ||
|
||
override val dataSourceName: String = | ||
classOf[org.apache.spark.sql.hive.orc.OrcFileFormat].getCanonicalName | ||
|
||
test("SPARK-13543: Support for specifying compression codec for ORC via option()") { | ||
withTempPath { dir => | ||
val path = s"${dir.getCanonicalPath}/table1" | ||
val df = (1 to 5).map(i => (i, (i % 2).toString)).toDF("a", "b") | ||
df.write | ||
.option("compression", "ZlIb") | ||
.orc(path) | ||
|
||
// Check if this is compressed as ZLIB. | ||
val maybeOrcFile = new File(path).listFiles().find { f => | ||
!f.getName.startsWith("_") && f.getName.endsWith(".zlib.orc") | ||
} | ||
assert(maybeOrcFile.isDefined) | ||
val orcFilePath = maybeOrcFile.get.toPath.toString | ||
val expectedCompressionKind = | ||
OrcFileOperator.getFileReader(orcFilePath).get.getCompression | ||
assert("ZLIB" === expectedCompressionKind.name()) | ||
|
||
val copyDf = spark | ||
.read | ||
.orc(path) | ||
checkAnswer(df, copyDf) | ||
} | ||
} | ||
|
||
test("Default compression codec is snappy for ORC compression") { | ||
withTempPath { file => | ||
spark.range(0, 10).write | ||
.orc(file.getCanonicalPath) | ||
val expectedCompressionKind = | ||
OrcFileOperator.getFileReader(file.getCanonicalPath).get.getCompression | ||
assert("SNAPPY" === expectedCompressionKind.name()) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test will fail if
SQLConf.MAX_RECORDS_PER_FILE.key
is less than 2There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the default value won't be less than 2, we don't need to be so careful...