spark3使用hive zstd压缩格式总结
•
大数据
ZSTD(全称为Zstandard)是一种开源的无损数据压缩算法,其压缩性能和压缩比均优于当前Hadoop支持的其他压缩格式,本特性使得Hive支持ZSTD压缩格式的表。Hive支持基于ZSTD压缩的存储格式有常见的ORC,RCFile,TextFile,JsonFile,Parquet,Squence,CSV。
ZSTD压缩格式的建表方式如下:
ORC存储格式建表时可指定TBLPROPERTIES(“orc.compress”=“zstd”):
create table tab_1(...) stored as orc TBLPROPERTIES("orc.compress"="zstd");
Parquet存储格式建表可指定TBLPROPERTIES(“parquet.compression”=“zstd”):
create table tab_2(...) stored as parquet TBLPROPERTIES("parquet.compression"="zstd");
其他格式或通用格式建表可执行设置参数指定compress,codec为“org.apache.hadoop.io.compress.ZStandardCode”:
set hive.exec.compress.output=true; set mapreduce.map.output.compress=true; set mapreduce.map.output.compress.codec=org.apache.hadoop.io.compress.ZStandardCodec; set mapreduce.output.fileoutputformat.compress=true; set mapreduce.output.fileoutputformat.compress.codec=org.apache.hadoop.io.compress.ZStandardCodec; set hive.exec.compress.intermediate=true; create table tab_3(...) stored as textfile;
说明:
ZSTD压缩格式的表和其他普通压缩表的SQL操作没有区别,可支持正常的增删查及聚合类SQL操作。
写出的文件使用zstd压缩,spark3才开始支持
–conf spark.sql.parquet.compression.codec=zstd
本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://net2asp.com/9b6f7d7b2d.html
