You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ja...@apache.org on 2020/06/10 02:52:12 UTC
[flink] branch master updated (f81b2c1 -> 821e786)
This is an automated email from the ASF dual-hosted git repository.
jark pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git.
from f81b2c1 [hotfix][python] Remove unnecessary methods in JobExecutionResult
new 0980a28 [hotfix][avro] Fix TINYINT/SMALLINT types not work in Avro format
new 9171292 [hotfix][docs][table] Minor improvements on Filesystem and HBase connector page
new 821e786 [FLINK-18133][docs][avro] Add documentation for the new Avro format
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
docs/dev/table/connectors/filesystem.md | 6 +-
docs/dev/table/connectors/filesystem.zh.md | 6 +-
docs/dev/table/connectors/formats/avro.md | 203 ++++++++++++++++++++
docs/dev/table/connectors/formats/avro.zh.md | 206 +++++++++++++++++++++
docs/dev/table/connectors/formats/index.md | 72 +++++++
docs/dev/table/connectors/formats/index.zh.md | 72 +++++++
docs/dev/table/connectors/hbase.md | 9 +-
docs/dev/table/connectors/hbase.zh.md | 9 +-
.../avro/AvroRowDataDeserializationSchema.java | 6 +-
.../avro/AvroRowDataSerializationSchema.java | 6 +
.../avro/typeutils/AvroSchemaConverter.java | 2 +
.../avro/AvroRowDataDeSerializationSchemaTest.java | 38 ++--
12 files changed, 595 insertions(+), 40 deletions(-)
create mode 100644 docs/dev/table/connectors/formats/avro.md
create mode 100644 docs/dev/table/connectors/formats/avro.zh.md
create mode 100644 docs/dev/table/connectors/formats/index.md
create mode 100644 docs/dev/table/connectors/formats/index.zh.md
[flink] 02/03: [hotfix][docs][table] Minor improvements on
Filesystem and HBase connector page
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jark pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
commit 91712929d33a1ed09079991437dd770d26af0eb3
Author: Jark Wu <ja...@apache.org>
AuthorDate: Mon Jun 8 17:37:39 2020 +0800
[hotfix][docs][table] Minor improvements on Filesystem and HBase connector page
---
docs/dev/table/connectors/filesystem.md | 6 +++---
docs/dev/table/connectors/filesystem.zh.md | 6 +++---
docs/dev/table/connectors/hbase.md | 9 +--------
docs/dev/table/connectors/hbase.zh.md | 9 +--------
4 files changed, 8 insertions(+), 22 deletions(-)
diff --git a/docs/dev/table/connectors/filesystem.md b/docs/dev/table/connectors/filesystem.md
index bcef270..5b1b286 100644
--- a/docs/dev/table/connectors/filesystem.md
+++ b/docs/dev/table/connectors/filesystem.md
@@ -1,8 +1,8 @@
---
-title: "FileSystem Connector"
-nav-title: FileSystem Connector
+title: "FileSystem SQL Connector"
+nav-title: FileSystem
nav-parent_id: sql-connectors
-nav-pos: 1
+nav-pos: 3
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
diff --git a/docs/dev/table/connectors/filesystem.zh.md b/docs/dev/table/connectors/filesystem.zh.md
index bcef270..5b1b286 100644
--- a/docs/dev/table/connectors/filesystem.zh.md
+++ b/docs/dev/table/connectors/filesystem.zh.md
@@ -1,8 +1,8 @@
---
-title: "FileSystem Connector"
-nav-title: FileSystem Connector
+title: "FileSystem SQL Connector"
+nav-title: FileSystem
nav-parent_id: sql-connectors
-nav-pos: 1
+nav-pos: 3
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
diff --git a/docs/dev/table/connectors/hbase.md b/docs/dev/table/connectors/hbase.md
index 810703f..503e11e 100644
--- a/docs/dev/table/connectors/hbase.md
+++ b/docs/dev/table/connectors/hbase.md
@@ -42,17 +42,10 @@ Dependencies
In order to setup the HBase connector, the following table provide dependency information for both projects using a build automation tool (such as Maven or SBT) and SQL Client with SQL JAR bundles.
-{% if site.is_stable %}
-
| HBase Version | Maven dependency | SQL Client JAR |
| :------------------ | :-------------------------------------------------------- | :----------------------|
-| 1.4.x | `flink-connector-hbase{{site.scala_version_suffix}}` | [Download](https://repo.maven.apache.org/maven2/org/apache/flink/flink-connector-hbase{{site.scala_version_suffix}}/{{site.version}}/flink-connector-hbase{{site.scala_version_suffix}}-{{site.version}}.jar) |
-
-{% else %}
-
-The dependency table is only available for stable releases.
+| 1.4.x | `flink-connector-hbase{{site.scala_version_suffix}}` | {% if site.is_stable %} [Download](https://repo.maven.apache.org/maven2/org/apache/flink/flink-connector-hbase{{site.scala_version_suffix}}/{{site.version}}/flink-connector-hbase{{site.scala_version_suffix}}-{{site.version}}.jar) {% else %} Only available for stable releases {% endif %}|
-{% endif %}
How to create an HBase table
----------------
diff --git a/docs/dev/table/connectors/hbase.zh.md b/docs/dev/table/connectors/hbase.zh.md
index 810703f..503e11e 100644
--- a/docs/dev/table/connectors/hbase.zh.md
+++ b/docs/dev/table/connectors/hbase.zh.md
@@ -42,17 +42,10 @@ Dependencies
In order to setup the HBase connector, the following table provide dependency information for both projects using a build automation tool (such as Maven or SBT) and SQL Client with SQL JAR bundles.
-{% if site.is_stable %}
-
| HBase Version | Maven dependency | SQL Client JAR |
| :------------------ | :-------------------------------------------------------- | :----------------------|
-| 1.4.x | `flink-connector-hbase{{site.scala_version_suffix}}` | [Download](https://repo.maven.apache.org/maven2/org/apache/flink/flink-connector-hbase{{site.scala_version_suffix}}/{{site.version}}/flink-connector-hbase{{site.scala_version_suffix}}-{{site.version}}.jar) |
-
-{% else %}
-
-The dependency table is only available for stable releases.
+| 1.4.x | `flink-connector-hbase{{site.scala_version_suffix}}` | {% if site.is_stable %} [Download](https://repo.maven.apache.org/maven2/org/apache/flink/flink-connector-hbase{{site.scala_version_suffix}}/{{site.version}}/flink-connector-hbase{{site.scala_version_suffix}}-{{site.version}}.jar) {% else %} Only available for stable releases {% endif %}|
-{% endif %}
How to create an HBase table
----------------
[flink] 03/03: [FLINK-18133][docs][avro] Add documentation for the
new Avro format
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jark pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
commit 821e786ce1e94e0074affcd50ecd4b87a6bd744b
Author: Jark Wu <ja...@apache.org>
AuthorDate: Mon Jun 8 17:38:14 2020 +0800
[FLINK-18133][docs][avro] Add documentation for the new Avro format
This closes #12523
---
docs/dev/table/connectors/formats/avro.md | 203 +++++++++++++++++++++++++
docs/dev/table/connectors/formats/avro.zh.md | 206 ++++++++++++++++++++++++++
docs/dev/table/connectors/formats/index.md | 72 +++++++++
docs/dev/table/connectors/formats/index.zh.md | 72 +++++++++
4 files changed, 553 insertions(+)
diff --git a/docs/dev/table/connectors/formats/avro.md b/docs/dev/table/connectors/formats/avro.md
new file mode 100644
index 0000000..8870235
--- /dev/null
+++ b/docs/dev/table/connectors/formats/avro.md
@@ -0,0 +1,203 @@
+---
+title: "Avro Format"
+nav-title: Avro
+nav-parent_id: sql-formats
+nav-pos: 3
+---
+<!--
+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.
+-->
+
+<span class="label label-info">Format: Serialization Schema</span>
+<span class="label label-info">Format: Deserialization Schema</span>
+
+* This will be replaced by the TOC
+{:toc}
+
+The [Apache Avro](https://avro.apache.org/) format allows to read and write Avro data based on an Avro schema. Currently, the Avro schema is derived from table schema.
+
+Dependencies
+------------
+
+In order to setup the Avro format, the following table provides dependency information for both projects using a build automation tool (such as Maven or SBT) and SQL Client with SQL JAR bundles.
+
+| Maven dependency | SQL Client JAR |
+| :----------------- | :----------------------|
+| `flink-avro` | [Pre-bundled Hadoop](https://flink.apache.org/downloads.html#additional-components) |
+
+How to create a table with Avro format
+----------------
+
+Here is an example to create a table using Kafka connector and Avro format.
+
+<div class="codetabs" markdown="1">
+<div data-lang="SQL" markdown="1">
+{% highlight sql %}
+CREATE TABLE user_behavior (
+ user_id BIGINT,
+ item_id BIGINT,
+ category_id BIGINT,
+ behavior STRING,
+ ts TIMESTAMP(3),
+) WITH (
+ 'connector' = 'kafka',
+ 'topic' = 'user_behavior',
+ 'properties.bootstrap.servers' = 'localhost:9092',
+ 'properties.group.id' = 'testGroup',
+ 'format' = 'avro'
+)
+{% endhighlight %}
+</div>
+</div>
+
+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 'avro'.</td>
+ </tr>
+ </tbody>
+</table>
+
+Data Type Mapping
+----------------
+
+Currently, the Avro schema is always derived from table schema. Explicitly defining an Avro schema is not supported yet.
+So the following table lists the type mapping from Flink type to Avro type.
+
+<table class="table table-bordered">
+ <thead>
+ <tr>
+ <th class="text-left">Flink Data Type</th>
+ <th class="text-center">Avro type</th>
+ <th class="text-center">Avro logical type</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>CHAR / VARCHAR / STRING</td>
+ <td>string</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>BOOLEAN</td>
+ <td>boolean</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>BINARY / VARBINARY</td>
+ <td>bytes</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>DECIMAL</td>
+ <td>fixed</td>
+ <td>decimal</td>
+ </tr>
+ <tr>
+ <td>TINYINT</td>
+ <td>int</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>SMALLINT</td>
+ <td>int</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>INT</td>
+ <td>int</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>BIGINT</td>
+ <td>long</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>int</td>
+ <td>date</td>
+ </tr>
+ <tr>
+ <td>TIME</td>
+ <td>int</td>
+ <td>time-millis</td>
+ </tr>
+ <tr>
+ <td>TIMESTAMP</td>
+ <td>long</td>
+ <td>timestamp-millis</td>
+ </tr>
+ <tr>
+ <td>ARRAY</td>
+ <td>array</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>MAP<br>
+ (key must be string/char/varchar type)</td>
+ <td>map</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>MULTISET<br>
+ (element must be string/char/varchar type)</td>
+ <td>map</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>ROW</td>
+ <td>record</td>
+ <td></td>
+ </tr>
+ </tbody>
+</table>
+
+In addition to the types listed above, Flink supports reading/writing nullable types. Flink maps nullable types to Avro `union(something, null)`, where `something` is the Avro type converted from Flink type.
+
+You can refer to Avro Specification for more information about Avro types: [https://avro.apache.org/docs/current/spec.html](https://avro.apache.org/docs/current/spec.html).
+
+
+
+
diff --git a/docs/dev/table/connectors/formats/avro.zh.md b/docs/dev/table/connectors/formats/avro.zh.md
new file mode 100644
index 0000000..ed74042
--- /dev/null
+++ b/docs/dev/table/connectors/formats/avro.zh.md
@@ -0,0 +1,206 @@
+---
+title: "Avro Format"
+nav-title: Avro
+nav-parent_id: sql-formats
+nav-pos: 3
+---
+<!--
+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.
+-->
+
+<span class="label label-info">Format: Serialization Schema</span>
+<span class="label label-info">Format: Deserialization Schema</span>
+
+* This will be replaced by the TOC
+{:toc}
+
+The [Apache Avro](https://avro.apache.org/) format allows to read and write Avro data based on an Avro schema. Currently, the Avro schema is derived from table schema.
+
+Dependencies
+------------
+
+In order to setup the Avro format, the following table provides dependency information for both projects using a build automation tool (such as Maven or SBT) and SQL Client with SQL JAR bundles.
+
+| Maven dependency | SQL Client JAR |
+| :----------------- | :----------------------|
+| `flink-avro` | [Pre-bundled Hadoop](https://flink.apache.org/downloads.html#additional-components) |
+
+How to create a table with Avro format
+----------------
+
+Here is an example to create a table using Kafka connector and Avro format.
+
+<div class="codetabs" markdown="1">
+<div data-lang="SQL" markdown="1">
+{% highlight sql %}
+CREATE TABLE user_behavior (
+ user_id BIGINT,
+ item_id BIGINT,
+ category_id BIGINT,
+ behavior STRING,
+ ts TIMESTAMP(3),
+) WITH (
+ 'connector' = 'kafka',
+ 'topic' = 'user_behavior',
+ 'properties.bootstrap.servers' = 'localhost:9092',
+ 'properties.group.id' = 'testGroup',
+ 'format' = 'avro'
+)
+{% endhighlight %}
+</div>
+</div>
+
+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 'avro'.</td>
+ </tr>
+ </tbody>
+</table>
+
+Data Type Mapping
+----------------
+
+Currently, the Avro schema is always derived from table schema, explicitly define an Avro schema is not supported yet. So here only lists the conversion from Flink type to Avro type.
+
+### Conversion from Flink type to Avro type
+
+The following table lists the conversion from the supported Flink type to Avro type.
+
+<table class="table table-bordered">
+ <thead>
+ <tr>
+ <th class="text-left">Flink Data Type</th>
+ <th class="text-center">Avro type</th>
+ <th class="text-center">Avro logical type</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>CHAR / VARCHAR / STRING</td>
+ <td>string</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>BOOLEAN</td>
+ <td>boolean</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>BINARY / VARBINARY</td>
+ <td>bytes</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>DECIMAL</td>
+ <td>fixed</td>
+ <td>decimal</td>
+ </tr>
+ <tr>
+ <td>TINYINT</td>
+ <td>int</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>SMALLINT</td>
+ <td>int</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>INT</td>
+ <td>int</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>BIGINT</td>
+ <td>long</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>int</td>
+ <td>date</td>
+ </tr>
+ <tr>
+ <td>TIME</td>
+ <td>int</td>
+ <td>time-millis</td>
+ </tr>
+ <tr>
+ <td>TIMESTAMP</td>
+ <td>long</td>
+ <td>timestamp-millis</td>
+ </tr>
+ <tr>
+ <td>ARRAY</td>
+ <td>array</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>MAP<br>
+ (key must be string/char/varchar type)</td>
+ <td>map</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>MULTISET<br>
+ (element must be string/char/varchar type)</td>
+ <td>map</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>ROW</td>
+ <td>record</td>
+ <td></td>
+ </tr>
+ </tbody>
+</table>
+
+In addition to the types listed above, Flink supports reading/writing nullable types. Flink maps nullable types to Avro `union(something, null)`, where `something` is the Avro type converted from Flink type.
+
+You can refer to Avro Specification for more information about Avro types: [https://avro.apache.org/docs/current/spec.html](https://avro.apache.org/docs/current/spec.html).
+
+
+
+
diff --git a/docs/dev/table/connectors/formats/index.md b/docs/dev/table/connectors/formats/index.md
new file mode 100644
index 0000000..6f45d74
--- /dev/null
+++ b/docs/dev/table/connectors/formats/index.md
@@ -0,0 +1,72 @@
+---
+title: "Formats"
+nav-id: sql-formats
+nav-parent_id: sql-connectors
+nav-pos: 1
+nav-show_overview: true
+---
+<!--
+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.
+-->
+
+Flink provides a set of table formats that can be used with table connectors. A table format is a storage format defines how to map binary data onto table columns.
+
+Flink supports the following formats:
+
+<table class="table table-bordered">
+ <thead>
+ <tr>
+ <th class="text-left">Formats</th>
+ <th class="text-left">Supported Connectors</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>CSV</td>
+ <td>Apache Kafka,
+ <a href="{{ site.baseurl }}/dev/table/connectors/filesystem.html">Filesystem</a></td>
+ </tr>
+ <tr>
+ <td>JSON</td>
+ <td>Apache Kafka,
+ <a href="{{ site.baseurl }}/dev/table/connectors/filesystem.html">Filesystem</a>,
+ Elasticsearch</td>
+ </tr>
+ <tr>
+ <td><a href="{{ site.baseurl }}/dev/table/connectors/formats/avro.html">Apache Avro</a></td>
+ <td>Apache Kafka,
+ <a href="{{ site.baseurl }}/dev/table/connectors/filesystem.html">Filesystem</a></td>
+ </tr>
+ <tr>
+ <td>Debezium JSON</td>
+ <td>Apache Kafka</td>
+ </tr>
+ <tr>
+ <td>Canal JSON</td>
+ <td>Apache Kafka</td>
+ </tr>
+ <tr>
+ <td>Apache Parquet</td>
+ <td><a href="{{ site.baseurl }}/dev/table/connectors/filesystem.html">Filesystem</a></td>
+ </tr>
+ <tr>
+ <td>Apache ORC</td>
+ <td><a href="{{ site.baseurl }}/dev/table/connectors/filesystem.html">Filesystem</a></td>
+ </tr>
+ </tbody>
+</table>
\ No newline at end of file
diff --git a/docs/dev/table/connectors/formats/index.zh.md b/docs/dev/table/connectors/formats/index.zh.md
new file mode 100644
index 0000000..9272f21
--- /dev/null
+++ b/docs/dev/table/connectors/formats/index.zh.md
@@ -0,0 +1,72 @@
+---
+title: "Formats"
+nav-id: sql-formats
+nav-parent_id: sql-connectors
+nav-pos: 1
+nav-show_overview: true
+---
+<!--
+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.
+-->
+
+Flink provides a set of table formats that can be used with table connectors. A table format is a storage format defines how to map binary data onto table columns.
+
+Flink supports the following formats:
+
+<table class="table table-bordered">
+ <thead>
+ <tr>
+ <th class="text-left">Formats</th>
+ <th class="text-left">Supported Connectors</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>CSV</td>
+ <td><a href="{{ site.baseurl }}/dev/table/connectors/kafka.html">Apache Kafka</a>,
+ <a href="{{ site.baseurl }}/dev/table/connectors/filesystem.html">Filesystem</a></td>
+ </tr>
+ <tr>
+ <td>JSON</td>
+ <td><a href="{{ site.baseurl }}/dev/table/connectors/kafka.html">Apache Kafka</a>,
+ <a href="{{ site.baseurl }}/dev/table/connectors/filesystem.html">Filesystem</a>,
+ <a href="{{ site.baseurl }}/dev/table/connectors/elasticsearch.html">Elasticsearch</a></td>
+ </tr>
+ <tr>
+ <td><a href="{{ site.baseurl }}/dev/table/connectors/formats/avro.html">Apache Avro</a></td>
+ <td><a href="{{ site.baseurl }}/dev/table/connectors/kafka.html">Apache Kafka</a>,
+ <a href="{{ site.baseurl }}/dev/table/connectors/filesystem.html">Filesystem</a></td>
+ </tr>
+ <tr>
+ <td>Debezium JSON</td>
+ <td><a href="{{ site.baseurl }}/dev/table/connectors/kafka.html">Apache Kafka</a></td>
+ </tr>
+ <tr>
+ <td>Canal JSON</td>
+ <td><a href="{{ site.baseurl }}/dev/table/connectors/kafka.html">Apache Kafka</a></td>
+ </tr>
+ <tr>
+ <td>Apache Parquet</td>
+ <td><a href="{{ site.baseurl }}/dev/table/connectors/filesystem.html">Filesystem</a></td>
+ </tr>
+ <tr>
+ <td>Apache ORC</td>
+ <td><a href="{{ site.baseurl }}/dev/table/connectors/filesystem.html">Filesystem</a></td>
+ </tr>
+ </tbody>
+</table>
\ No newline at end of file
[flink] 01/03: [hotfix][avro] Fix TINYINT/SMALLINT types not work
in Avro format
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jark pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
commit 0980a28efee56ea900291336eb2d230d229baa61
Author: Jark Wu <ja...@apache.org>
AuthorDate: Mon Jun 8 17:36:04 2020 +0800
[hotfix][avro] Fix TINYINT/SMALLINT types not work in Avro format
---
.../avro/AvroRowDataDeserializationSchema.java | 6 ++--
.../avro/AvroRowDataSerializationSchema.java | 6 ++++
.../avro/typeutils/AvroSchemaConverter.java | 2 ++
.../avro/AvroRowDataDeSerializationSchemaTest.java | 38 +++++++++++++---------
4 files changed, 34 insertions(+), 18 deletions(-)
diff --git a/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/AvroRowDataDeserializationSchema.java b/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/AvroRowDataDeserializationSchema.java
index 995a83c..31ba11d 100644
--- a/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/AvroRowDataDeserializationSchema.java
+++ b/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/AvroRowDataDeserializationSchema.java
@@ -229,9 +229,11 @@ public class AvroRowDataDeserializationSchema implements DeserializationSchema<R
switch (type.getTypeRoot()) {
case NULL:
return avroObject -> null;
+ case TINYINT:
+ return avroObject -> ((Integer) avroObject).byteValue();
+ case SMALLINT:
+ return avroObject -> ((Integer) avroObject).shortValue();
case BOOLEAN: // boolean
- case TINYINT: // short
- case SMALLINT: // int
case INTEGER: // int
case INTERVAL_YEAR_MONTH: // long
case BIGINT: // long
diff --git a/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/AvroRowDataSerializationSchema.java b/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/AvroRowDataSerializationSchema.java
index 5b1fbbe..bc6eca7 100644
--- a/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/AvroRowDataSerializationSchema.java
+++ b/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/AvroRowDataSerializationSchema.java
@@ -187,6 +187,12 @@ public class AvroRowDataSerializationSchema implements SerializationSchema<RowDa
case NULL:
converter = (schema, object) -> null;
break;
+ case TINYINT:
+ converter = (schema, object) -> ((Byte) object).intValue();
+ break;
+ case SMALLINT:
+ converter = (schema, object) -> ((Short) object).intValue();
+ break;
case BOOLEAN: // boolean
case INTEGER: // int
case INTERVAL_YEAR_MONTH: // long
diff --git a/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/typeutils/AvroSchemaConverter.java b/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/typeutils/AvroSchemaConverter.java
index 37745e5..4524726 100644
--- a/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/typeutils/AvroSchemaConverter.java
+++ b/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/typeutils/AvroSchemaConverter.java
@@ -186,6 +186,8 @@ public class AvroSchemaConverter {
return SchemaBuilder.builder().nullType();
case BOOLEAN:
return getNullableBuilder(logicalType).booleanType();
+ case TINYINT:
+ case SMALLINT:
case INTEGER:
return getNullableBuilder(logicalType).intType();
case BIGINT:
diff --git a/flink-formats/flink-avro/src/test/java/org/apache/flink/formats/avro/AvroRowDataDeSerializationSchemaTest.java b/flink-formats/flink-avro/src/test/java/org/apache/flink/formats/avro/AvroRowDataDeSerializationSchemaTest.java
index 38c6c2f..9110e2f 100644
--- a/flink-formats/flink-avro/src/test/java/org/apache/flink/formats/avro/AvroRowDataDeSerializationSchemaTest.java
+++ b/flink-formats/flink-avro/src/test/java/org/apache/flink/formats/avro/AvroRowDataDeSerializationSchemaTest.java
@@ -62,9 +62,11 @@ import static org.apache.flink.table.api.DataTypes.FLOAT;
import static org.apache.flink.table.api.DataTypes.INT;
import static org.apache.flink.table.api.DataTypes.MAP;
import static org.apache.flink.table.api.DataTypes.ROW;
+import static org.apache.flink.table.api.DataTypes.SMALLINT;
import static org.apache.flink.table.api.DataTypes.STRING;
import static org.apache.flink.table.api.DataTypes.TIME;
import static org.apache.flink.table.api.DataTypes.TIMESTAMP;
+import static org.apache.flink.table.api.DataTypes.TINYINT;
import static org.junit.Assert.assertArrayEquals;
/**
@@ -76,6 +78,8 @@ public class AvroRowDataDeSerializationSchemaTest {
public void testSerializeDeserialize() throws Exception {
final DataType dataType = ROW(
FIELD("bool", BOOLEAN()),
+ FIELD("tinyint", TINYINT()),
+ FIELD("smallint", SMALLINT()),
FIELD("int", INT()),
FIELD("bigint", BIGINT()),
FIELD("float", FLOAT()),
@@ -97,45 +101,47 @@ public class AvroRowDataDeSerializationSchemaTest {
final Schema schema = AvroSchemaConverter.convertToSchema(rowType);
final GenericRecord record = new GenericData.Record(schema);
record.put(0, true);
- record.put(1, 33);
- record.put(2, 44L);
- record.put(3, 12.34F);
- record.put(4, 23.45);
- record.put(5, "hello avro");
- record.put(6, ByteBuffer.wrap(new byte[]{1, 2, 4, 5, 6, 7, 8, 12}));
-
- record.put(7, ByteBuffer.wrap(
+ record.put(1, (int) Byte.MAX_VALUE);
+ record.put(2, (int) Short.MAX_VALUE);
+ record.put(3, 33);
+ record.put(4, 44L);
+ record.put(5, 12.34F);
+ record.put(6, 23.45);
+ record.put(7, "hello avro");
+ record.put(8, ByteBuffer.wrap(new byte[]{1, 2, 4, 5, 6, 7, 8, 12}));
+
+ record.put(9, ByteBuffer.wrap(
BigDecimal.valueOf(123456789, 6).unscaledValue().toByteArray()));
List<Double> doubles = new ArrayList<>();
doubles.add(1.2);
doubles.add(3.4);
doubles.add(567.8901);
- record.put(8, doubles);
+ record.put(10, doubles);
- record.put(9, 18397);
- record.put(10, 10087);
- record.put(11, 1589530213123L);
- record.put(12, 1589530213122L);
+ record.put(11, 18397);
+ record.put(12, 10087);
+ record.put(13, 1589530213123L);
+ record.put(14, 1589530213122L);
Map<String, Long> map = new HashMap<>();
map.put("flink", 12L);
map.put("avro", 23L);
- record.put(13, map);
+ record.put(15, map);
Map<String, Map<String, Integer>> map2map = new HashMap<>();
Map<String, Integer> innerMap = new HashMap<>();
innerMap.put("inner_key1", 123);
innerMap.put("inner_key2", 234);
map2map.put("outer_key", innerMap);
- record.put(14, map2map);
+ record.put(16, map2map);
List<Integer> list1 = Arrays.asList(1, 2, 3, 4, 5, 6);
List<Integer> list2 = Arrays.asList(11, 22, 33, 44, 55);
Map<String, List<Integer>> map2list = new HashMap<>();
map2list.put("list1", list1);
map2list.put("list2", list2);
- record.put(15, map2list);
+ record.put(17, map2list);
AvroRowDataSerializationSchema serializationSchema = new AvroRowDataSerializationSchema(rowType);
serializationSchema.open(null);