Orc Format

Format: Serialization Schema Format: Deserialization Schema

Apache Orc Format 允许读写 ORC 数据。

依赖

In order to use the ORC format the following dependencies are required for both projects using a build automation tool (such as Maven or SBT) and SQL Client with SQL JAR bundles.

Maven dependencySQL Client
  1. <dependency>
  2. <groupId>org.apache.flink</groupId>
  3. <artifactId>flink-orc</artifactId>
  4. <version>1.16.0</version>
  5. </dependency>
Copied to clipboard!
Download

如何用 Orc 格式创建一个表格

下面是一个用 Filesystem connector 和 Orc format 创建表格的例子

  1. CREATE TABLE user_behavior (
  2. user_id BIGINT,
  3. item_id BIGINT,
  4. category_id BIGINT,
  5. behavior STRING,
  6. ts TIMESTAMP(3),
  7. dt STRING
  8. ) PARTITIONED BY (dt) WITH (
  9. 'connector' = 'filesystem',
  10. 'path' = '/tmp/user_behavior',
  11. 'format' = 'orc'
  12. )

Format 参数

参数是否必选默认值类型描述
format
必选(none)String指定要使用的格式,这里应该是 ‘orc’。

Orc 格式也支持来源于 Table properties 的表属性。 举个例子,你可以设置 orc.compress=SNAPPY 来允许spappy压缩。

数据类型映射

Orc 格式类型的映射和 Apache Hive 是兼容的。下面的表格列出了 Flink 类型的数据和 Orc 类型的数据的映射关系。

Flink 数据类型Orc 物理类型Orc 逻辑类型
CHARbytesCHAR
VARCHARbytesVARCHAR
STRINGbytesSTRING
BOOLEANlongBOOLEAN
BYTESbytesBINARY
DECIMALdecimalDECIMAL
TINYINTlongBYTE
SMALLINTlongSHORT
INTlongINT
BIGINTlongLONG
FLOATdoubleFLOAT
DOUBLEdoubleDOUBLE
DATElongDATE
TIMESTAMPtimestampTIMESTAMP
ARRAY-LIST
MAP-MAP
ROW-STRUCT