-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-36670][SQL][TEST] Add FileSourceCodecSuite #33912
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
Changes from 9 commits
b364990
cbb6f0a
ab5fc9c
5923b6f
194faf2
ed5f33d
0029f33
b6f20cf
e76393b
16e7db9
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 |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /* | ||
| * 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.execution.datasources | ||
|
|
||
| import org.apache.spark.sql.QueryTest | ||
| import org.apache.spark.sql.internal.SQLConf | ||
| import org.apache.spark.sql.test.{SharedSparkSession, SQLTestUtils} | ||
|
|
||
| trait FileSourceCodecSuite extends QueryTest with SQLTestUtils { | ||
|
Member
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. Nit: let's make it here so that ParquetCodecSuite doesn't need to extend SharedSparkSession |
||
|
|
||
| protected def format: String | ||
| protected val codecConfigName: String | ||
| protected def availableCodecs: Seq[String] | ||
|
|
||
| def testWithAllCodecs(name: String)(f: => Unit): Unit = { | ||
| for (codec <- availableCodecs) { | ||
| test(s"$name - file source $format - codec: $codec") { | ||
| withSQLConf(codecConfigName -> codec) { | ||
| f | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| testWithAllCodecs("write and read") { | ||
| withTempPath { dir => | ||
| testData | ||
| .repartition(5) | ||
| .write | ||
| .format(format) | ||
| .save(dir.getCanonicalPath) | ||
|
|
||
| val df = spark.read.format(format).load(dir.getCanonicalPath) | ||
| checkAnswer(df, testData) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| class ParquetCodecSuite extends FileSourceCodecSuite with SharedSparkSession { | ||
|
|
||
| override def format: String = "parquet" | ||
| override val codecConfigName: String = SQLConf.PARQUET_COMPRESSION.key | ||
| // Exclude "lzo" because it is GPL-licenced so not included in Hadoop. | ||
| // TODO(SPARK-36669): "lz4" codec fails due to HADOOP-17891. | ||
| override protected def availableCodecs: Seq[String] = | ||
| if (System.getProperty("os.arch") == "aarch64") { | ||
| // Exclude "brotli" due to PARQUET-1975. | ||
| Seq("none", "uncompressed", "snappy", "gzip", "zstd") | ||
| } else { | ||
| Seq("none", "uncompressed", "snappy", "gzip", "brotli", "zstd") | ||
| } | ||
| } | ||
|
|
||
| class OrcCodecSuite extends FileSourceCodecSuite with SharedSparkSession { | ||
|
|
||
| override def format: String = "orc" | ||
| override val codecConfigName: String = SQLConf.ORC_COMPRESSION.key | ||
| override protected def availableCodecs = Seq("none", "uncompressed", "snappy", | ||
| "zlib", "zstd", "lz4", "lzo") | ||
|
Contributor
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. we don't have GPL licence issue here for lzo?
Member
Author
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. I don't add extra dependency for Orc lzo codec. I think it uses aircompressor for lzo too.
Member
Author
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. Please see ORC-77 (https://issues.apache.org/jira/browse/ORC-77).
Member
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. Yes, Apache ORC uses
Member
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. FYI, I have an unfinished PR to Hadoop to support LZO using aircompressor. apache/hadoop#2159 |
||
| } | ||
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.
nit, remove empty line?