Uh oh!
There was an error while loading. Please reload this page.
[SPARK-21786][SQL] The 'spark.sql.parquet.compression.codec' and 'spark.sql.orc.compression.codec' configuration doesn't take effect on hive table writing - #19218
Conversation
…ation doesn't take effect on tables with partition field(s)
maropu
commented
Sep 13, 2017
Could you add tests? Probably, you could insert some data then check if the data compressed by listing up files in temp dir? |
…ation doesn't take effect on tables with partition field(s) Add test.
fjh100456
commented
Sep 14, 2017
cc @maropu I have added the test. However, all of my local use cases do not work properly, so I'm not sure if the new use case will pass, but I will always be concerned. |
maropu
commented
Sep 15, 2017
@gatorsmile Is it worth fixing this? If so, could you trigger tests? |
gatorsmile
commented
Sep 15, 2017
ok to test |
SparkQA
commented
Sep 15, 2017
Test build #81813 has finished for PR 19218 at commit
|
gatorsmile
commented
Sep 15, 2017
@maropu@fjh100456 If the issue is true, we should fix it for sure. However, the PR description must be wrong. If this issue exists, it should be applicable to both partitioned and non-partitioned ORC/Parquet tables. cc @dongjoon-hyun I think you might be interested in ORC side. |
fjh100456
commented
Sep 15, 2017
|
…ation doesn't take effect on tables with partition field(s) Fix scala style.
SparkQA
commented
Sep 15, 2017
Test build #81815 has finished for PR 19218 at commit
|
…ation doesn't take effect on tables with partition field(s) Fix scala style.
SparkQA
commented
Sep 15, 2017
Test build #81816 has finished for PR 19218 at commit
|
…ation doesn't take effect on tables with partition field(s) Fix test problem
SparkQA
commented
Sep 15, 2017
Test build #81820 has finished for PR 19218 at commit
|
dongjoon-hyun
commented
Sep 15, 2017
Thank you for pinging me, @gatorsmile. |
| val fileSinkConf = new FileSinkDesc(tmpLocation.toString, tableDesc, false) | ||
| tableDesc.getOutputFileFormatClassName match { | ||
| case "org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat" => |
There was a problem hiding this comment.
- Parquet: It seems that you need to consider another output format, parquet.hive.DeprecatedParquetOutputFormat, too.
- ORC: We have spark.sql.orc.compression.codec by SPARK-21839.
fjh100456
commented
Sep 16, 2017
@dongjoon-hyun Thank you very much, I'll fix it now. |
…ation doesn't take effect on tables with partition field(s) Fix the similar issue of orc compression
…ation doesn't take effect on tables with partition field(s) Fix test problem
SparkQA
commented
Sep 16, 2017
Test build #81839 has finished for PR 19218 at commit
|
SparkQA
commented
Sep 16, 2017
Test build #81840 has finished for PR 19218 at commit
|
…ation doesn't take effect on tables with partition field(s) Fix test problem
A problem has been encountered, There are two ways to specify the compression format:
If the table already has been specified a compression format when it was created, and then specified another compression format by setting 'orc.compress', the latter will take effect. So whether the spark side should not have the default value, we can distinguish by 'undefined'; or discard this change, and explain in the document that 'spark.sql.parquet.compression.codec' for partitioned tables does not take effect, and 'spark.sql.orc.compression.codec ' is not valid for hive tables. Or your other better solution. |
SparkQA
commented
Sep 16, 2017
Test build #81841 has finished for PR 19218 at commit
|
I see. If you set Please update your PR description and title. |
| val tmpLocation = getExternalTmpPath(sparkSession, hadoopConf, tableLocation) | ||
| val fileSinkConf = new FileSinkDesc(tmpLocation.toString, tableDesc, false) | ||
| tableDesc.getOutputFileFormatClassName match { |
There was a problem hiding this comment.
Move the whole logics into saveAsHiveFile, which is being shared by InsertIntoHiveDirCommand and InsertIntoHiveTable. Both need these logics.
gatorsmile
commented
Sep 17, 2017
@fjh100456 We have priority for three different inputs. Here, you just consider one of three. Please also add the extra checks. Hopefully, @dongjoon-hyun can help you answer your questions. He just finished the work in #19055 |
dongjoon-hyun
commented
Sep 17, 2017
Sorry, guys. I've been away from keyboard since last Friday night. I'll be back on next Tuesday (PST). |
fjh100456
commented
Dec 18, 2017
I will change the code with the suggestion of @gatorsmile ,it's a little busy this days.I will do it tomorrow. |
…rk.sql.orc.compression.codec' configuration doesn't take effect on hive table writing Move the whole determination logics to HiveOptions
fjh100456
commented
Dec 19, 2017
@gatorsmile@maropu Does it look better now? About statistic issue, is there any suggestion? @SparkQA Please start test, thanks. |
gatorsmile
commented
Dec 20, 2017
ok to test |
SparkQA
commented
Dec 20, 2017
Test build #85154 has finished for PR 19218 at commit
|
…rk.sql.orc.compression.codec' configuration doesn't take effect on hive table writing Fix scala style
SparkQA
commented
Dec 20, 2017
Test build #85173 has finished for PR 19218 at commit
|
fjh100456
commented
Dec 21, 2017
@gatorsmile Could you help to review it? Thanks very much! |
| Option((ParquetOutputFormat.COMPRESSION, compressionCodec)) | ||
| case formatName if formatName.endsWith("orcoutputformat") => | ||
| val compressionCodec = new OrcOptions(tableInfo.getProperties.asScala.toMap, | ||
| sqlConf).compressionCodec |
There was a problem hiding this comment.
Also update OrcOptions's compressionCodec to compressionCodecClassName
There was a problem hiding this comment.
The compressionCodec is used in several places, do you mean I should fix them all?
There was a problem hiding this comment.
Yeah. Just to make it consistent
| class InsertSuite extends QueryTest with TestHiveSingleton with BeforeAndAfter | ||
| with SQLTestUtils { | ||
| with ParquetTest { |
There was a problem hiding this comment.
This is the insert suite. We are unable to do this.
Could you create a separate suite in the current package org.apache.spark.sql.hive? The suite name can be CompressionCodecSuite
There was a problem hiding this comment.
Please also check whether the compression takes an effect? Compare the size whether is smaller than the original size without compressions?
There was a problem hiding this comment.
Seems compressed table does not always be smaller than uncompressed tables.SNAPPY Compression size may be bigger than non-compression size when the amount of data is not big. So I'd like to check the size not equal when compression are different.
| tableInfo.getOutputFileFormatClassName.toLowerCase match { | ||
| case formatName if formatName.endsWith("parquetoutputformat") => | ||
| val compressionCodec = new ParquetOptions(tableInfo.getProperties.asScala.toMap, | ||
| sqlConf).compressionCodecClassName |
There was a problem hiding this comment.
We normally do not split the code like this. We like the following way:
valtableProps= tableInfo.getProperties.asScala.toMap
tableInfo.getOutputFileFormatClassName.toLowerCase match {
case formatName if formatName.endsWith("parquetoutputformat") =>valcompressionCodec=newParquetOptions(tableProps, sqlConf).compressionCodecClassName
Option((ParquetOutputFormat.COMPRESSION, compressionCodec))
...There was a problem hiding this comment.
Yes it looks better, I will change it.
| import scala.collection.JavaConverters._ | ||
| import org.apache.hadoop.hive.ql.plan.{FileSinkDesc, TableDesc} |
| val parquetCompressionConf = parameters.get(ParquetOutputFormat.COMPRESSION) | ||
| val codecName = parameters | ||
| .get("compression") | ||
| .orElse(parquetCompressionConf) |
There was a problem hiding this comment.
Is this new? Do we support parquet.compression before this PR?
There was a problem hiding this comment.
Yes it's new. I guess PartitionOptions did not used when writing hive table before, because it's invisible for hive. I changeed it to public.
There was a problem hiding this comment.
Could we keep the old behavior? We could add it later? We do not want to mix multiple issues in the same PR?
There was a problem hiding this comment.
If so, parquet's table-level compression may be overwrited in this PR, and it may not be what we want.
Shall I fix it first in another PR?
There was a problem hiding this comment.
Yeah, we can submit a separate PR for that issue. The behavior change needs to be documented in SparkSQL doc.
| HiveOptions.getHiveWriteCompression(fileSinkConf.getTableInfo, sparkSession.sessionState.conf) | ||
| .foreach{ case (compression, codec) => | ||
| hadoopConf.set(compression, codec) | ||
| } |
There was a problem hiding this comment.
.foreach { case (compression, codec) => hadoopConf.set(compression, codec) }
gatorsmile
commented
Dec 22, 2017
Could you also add another test scenario? For the existing Hive tables (created by Hive), does our Spark respect it? Do we use the existing compression configuration? |
fjh100456
commented
Dec 23, 2017
@gatorsmile |
What are multiple compressions? |
SparkQA
commented
Dec 23, 2017
Test build #85334 has finished for PR 19218 at commit
|
SparkQA
commented
Dec 23, 2017
Test build #85335 has finished for PR 19218 at commit
|
SparkQA
commented
Dec 23, 2017
Test build #85340 has finished for PR 19218 at commit
|
gatorsmile
commented
Dec 25, 2017
@fjh100456 Yeah. Please also add the test cases with the table containing mixed compression codec. Thanks! I have some comments about your fix. See my commit: I will review your fix later |
| class CompressionCodecSuite extends TestHiveSingleton with ParquetTest { | ||
| import spark.implicits._ | ||
| private val maxRecordNum = 100000 |
There was a problem hiding this comment.
Could you reduce it to a smaller number? The test cases are very slow to run.
fjh100456
commented
Dec 26, 2017
I'd finished to write the test case with the table containing mixed compression codec. But maybe I'd made a mistake, the original branch was deleted mistakenly, I will closed this PR and create another PR. Sorry. |
fjh100456
commented
Dec 27, 2017
Please go to #20087 |
…rk.sql.orc.compression.codec' configuration doesn't take effect on hive table writing [SPARK-21786][SQL] The 'spark.sql.parquet.compression.codec' and 'spark.sql.orc.compression.codec' configuration doesn't take effect on hive table writing What changes were proposed in this pull request? Pass ‘spark.sql.parquet.compression.codec’ value to ‘parquet.compression’. Pass ‘spark.sql.orc.compression.codec’ value to ‘orc.compress’. How was this patch tested? Add test. Note: This is the same issue mentioned in #19218 . That branch was deleted mistakenly, so make a new pr instead. gatorsmile maropu dongjoon-hyun discipleforteen Author: fjh100456 <fu.jinhua6@zte.com.cn> Author: Takeshi Yamamuro <yamamuro@apache.org> Author: Wenchen Fan <wenchen@databricks.com> Author: gatorsmile <gatorsmile@gmail.com> Author: Yinan Li <liyinan926@gmail.com> Author: Marcelo Vanzin <vanzin@cloudera.com> Author: Juliusz Sompolski <julek@databricks.com> Author: Felix Cheung <felixcheung_m@hotmail.com> Author: jerryshao <sshao@hortonworks.com> Author: Li Jin <ice.xelloss@gmail.com> Author: Gera Shegalov <gera@apache.org> Author: chetkhatri <ckhatrimanjal@gmail.com> Author: Joseph K. Bradley <joseph@databricks.com> Author: Bago Amirbekian <bago@databricks.com> Author: Xianjin YE <advancedxy@gmail.com> Author: Bruce Robbins <bersprockets@gmail.com> Author: zuotingbing <zuo.tingbing9@zte.com.cn> Author: Kent Yao <yaooqinn@hotmail.com> Author: hyukjinkwon <gurwls223@gmail.com> Author: Adrian Ionescu <adrian@databricks.com> Closes#20087 from fjh100456/HiveTableWriting. (cherry picked from commit 00d1691) Signed-off-by: gatorsmile <gatorsmile@gmail.com>
…rk.sql.orc.compression.codec' configuration doesn't take effect on hive table writing [SPARK-21786][SQL] The 'spark.sql.parquet.compression.codec' and 'spark.sql.orc.compression.codec' configuration doesn't take effect on hive table writing What changes were proposed in this pull request? Pass ‘spark.sql.parquet.compression.codec’ value to ‘parquet.compression’. Pass ‘spark.sql.orc.compression.codec’ value to ‘orc.compress’. How was this patch tested? Add test. Note: This is the same issue mentioned in apache#19218 . That branch was deleted mistakenly, so make a new pr instead. gatorsmile maropu dongjoon-hyun discipleforteen Author: fjh100456 <fu.jinhua6@zte.com.cn> Author: Takeshi Yamamuro <yamamuro@apache.org> Author: Wenchen Fan <wenchen@databricks.com> Author: gatorsmile <gatorsmile@gmail.com> Author: Yinan Li <liyinan926@gmail.com> Author: Marcelo Vanzin <vanzin@cloudera.com> Author: Juliusz Sompolski <julek@databricks.com> Author: Felix Cheung <felixcheung_m@hotmail.com> Author: jerryshao <sshao@hortonworks.com> Author: Li Jin <ice.xelloss@gmail.com> Author: Gera Shegalov <gera@apache.org> Author: chetkhatri <ckhatrimanjal@gmail.com> Author: Joseph K. Bradley <joseph@databricks.com> Author: Bago Amirbekian <bago@databricks.com> Author: Xianjin YE <advancedxy@gmail.com> Author: Bruce Robbins <bersprockets@gmail.com> Author: zuotingbing <zuo.tingbing9@zte.com.cn> Author: Kent Yao <yaooqinn@hotmail.com> Author: hyukjinkwon <gurwls223@gmail.com> Author: Adrian Ionescu <adrian@databricks.com> Closesapache#20087 from fjh100456/HiveTableWriting.

[SPARK-21786][SQL] The 'spark.sql.parquet.compression.codec' and 'spark.sql.orc.compression.codec' configuration doesn't take effect on hive table writing
What changes were proposed in this pull request?
Pass ‘spark.sql.parquet.compression.codec’ value to ‘parquet.compression’.
Pass ‘spark.sql.orc.compression.codec’ value to ‘orc.compress’.
How was this patch tested?
Add test.