Project: Flink (App Definition and Development / Streaming & Messaging)
File: parquet.md

title: Parquet weight: 9 type: docs aliases: /dev/table/connectors/formats/parquet.html <!-- 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. --> {{< label "Format: Serialization Schema" >}} {{< label "Format: Deserialization Schema" >}} The format allows to read and write Parquet data. Dependencies {{< sqldownloadtable "parquet" >}} How to create a table with Parquet format Here is an example to create a table using Filesystem connector and Parquet format. ```sql CREATE TABLE user_behavior ( user_id BIGINT, item_id BIGINT, category_id BIGINT, behavior STRING, ts TIMESTAMP(3), dt STRING ) PARTITIONED BY (dt) WITH ( 'connector' = 'filesystem', 'path' = '/tmp/user_behavior', 'format' = 'parquet' ) ``` Format Options <table class="table table-bordered"> <thead> <tr> <th class="text-left" style="width: 25%">Option</th> <th class="text-center" style="width: 8%">Required</th> <th class="text-center" style="width: 7%">Default</th> <th class="text-center" style="width: 10%">Type</th> <th class="text-center" style="width: 50%">Description</th> </tr> </thead> <tbody> <tr> <td><h5>format</h5></td> <td>required</td> <td style="word-wrap: break-word;">(none)</td> <td>String</td> <td>Specify what format to use, here should be 'parquet'.</td> </tr> <tr> <td><h5>parquet.utc-timezone</h5></td> <td>optional</td> <td style="word-wrap: break-word;">false</td> <td>Boolean</td> <td>Use UTC timezone or local timezone to the conversion between epoch time and LocalDateTime. Hive 0.x/1.x/2.x use local timezone. But Hive 3.x use UTC timezone.</td> </tr> <tr> <td><h5>timestamp.time.unit</h5></td> <td>optional</td> <td style="word-wrap: break-word;">micros</td> <td>String</td> <td>Store parquet int64/LogicalTypes timestamps in this time unit, value is nanos/micros/millis.</td> </tr> <tr> <td><h5>write.int64.timestamp</h5></td> <td>optional</td> <td style="word-wrap: break-word;">false</td> <td>Boolean</td> <td>Write parquet timestamp as int64/LogicalTypes instead of int96/OriginalTypes. Note: Timestamp will be time zone agnostic (NEVER converted to a different time zone).</td> </tr> </tbody> </table> Parquet format also supports configuration from . For example, you can configure `parquet.compression=GZIP` to enable gzip compression. Data Type Mapping Currently, Parquet format type mapping is compatible with Apache Hive, but by default not with Apache Spark: Timestamp: mapping timestamp type to int96 whatever the precision is. Spark compatibility requires int64 via config option `write.int64.timestamp` (see above). Decimal: mapping decimal type to fixed length byte array according to the precision. The following table lists the type mapping from Flink type to Parquet type. <table class="table table-bordered"> <thead> <tr> <th class="text-left">Flink Data Type</th> <th class="text-center">Parquet type</th> <th class="text-center">Parquet logical type</th> </tr> </thead> <tbody> <tr> <td>CHAR / VARCHAR / STRING</td> <td>BINARY</td> <td>UTF8</td> </tr> <tr> <td>BOOLEAN</td> <td>BOOLEAN</td> <td></td> </tr> <tr> <td>BINARY / VARBINARY</td> <td>BINARY</td> <td></td> </tr> <tr> <td>DECIMAL</td> <td>FIXEDLENBYTE_ARRAY</td> <td>DECIMAL</td> </tr> <tr> <td>TINYINT</td> <td>INT32</td> <td>INT_8</td> </tr> <tr> <td>SMALLINT</td> <td>INT32</td> <td>INT_16</td> </tr> <tr> <td>INT</td> <td>INT32</td> <td></td> </tr> <tr> <td>BIGINT</td> <td>INT64</td> <td></td> </tr> <tr> <td>FLOAT</td> <td>FLOAT</td> <td></td> </tr> <tr> <td>DOUBLE</td> <td>DOUBLE</td> <td></td> </tr> <tr> <td>DATE</td> <td>INT32</td> <td>DATE</td> </tr> <tr> <td>TIME</td> <td>INT32</td> <td>TIME_MILLIS</td> </tr> <tr> <td>TIMESTAMP</td> <td>INT96 (or INT64)</td> <td></td> </tr> <tr> <td>ARRAY</td> <td>-</td> <td>LIST</td> </tr> <tr> <td>MAP</td> <td>-</td> <td>MAP</td> </tr> <tr> <td>ROW</td> <td>-</td> <td>STRUCT</td> </tr> </tbody> </table>