【翻译】Flink Table Api & SQL — Hive Beta
本文翻译自官网:Hive Beta https://ci.apache.org/projects/flink/flink-docs-release-1.9/dev/table/hive/
Apache Hive已将自己确立为数据仓库生态系统的焦点。 它不仅充当用于大数据分析和ETL的SQL引擎,而且也是数据发现, 定义和演变数据的数据管理平台。
Flink提供了与Hive的双重集成。 首先是利用Hive的Metastore作为持久性 catalog,以跨会话存储Flink特定的元数据。 第二个是提供Flink作为读取和写入Hive表的替代引擎。
hive catalog 旨在与现有的 hive 安装程序 “开箱即用” 兼容。 您不需要修改现有的 Hive Metastore 或更改表的数据放置或分区。
Flink支持Hive 2.3.4
,1.2.1
并且依赖于Hive对其他次要版本的兼容性保证。
如果您使用其他次要Hive版本,例如1.2.2或2.3.1,则还可以选择最接近的版本1.2.1(对于1.2.2)或2.3.4(对于2.3.1)来解决。 例如,您要使用Flink在SQL客户端中集成2.3.1 hive版本,只需在YAML配置中将hive-version设置为2.3.4。 通过Table API创建HiveCatalog实例时,类似地传递版本字符串。
欢迎用户使用此替代方法尝试不同的版本。 由于仅测试了2.3.4和1.2.1,所以可能存在意外问题。 我们将在将来的版本中测试并支持更多版本。
依赖
为了与Hive集成,用户在他们的项目中需要以下依赖项。
hive 2.3.4
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-hive_2.11</artifactId>
<version>1.9.0</version>
<scope>provided</scope>
</dependency> <!-- Hadoop Dependencies --> <dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-hadoop-compatibility_2.11</artifactId>
<version>1.9.0</version>
<scope>provided</scope>
</dependency> <!-- Hive 2.3.4 is built with Hadoop 2.7.2. We pick 2.7.5 which flink-shaded-hadoop is pre-built with, but users can pick their own hadoop version, as long as it's compatible with Hadoop 2.7.2 --> <dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-shaded-hadoop-2-uber</artifactId>
<version>2.7.5-8.0</version>
<scope>provided</scope>
</dependency> <!-- Hive Metastore -->
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-exec</artifactId>
<version>2.3.4</version>
</dependency>
hive 1.2.1
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-hive_2.11</artifactId>
<version>1.9.0</version>
<scope>provided</scope>
</dependency> <!-- Hadoop Dependencies --> <dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-hadoop-compatibility_2.11</artifactId>
<version>1.9.0</version>
<scope>provided</scope>
</dependency> <!-- Hive 1.2.1 is built with Hadoop 2.6.0. We pick 2.6.5 which flink-shaded-hadoop is pre-built with, but users can pick their own hadoop version, as long as it's compatible with Hadoop 2.6.0 --> <dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-shaded-hadoop-2-uber</artifactId>
<version>2.6.5-8.0</version>
<scope>provided</scope>
</dependency> <!-- Hive Metastore -->
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-metastore</artifactId>
<version>1.2.1</version>
</dependency> <dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-exec</artifactId>
<version>1.2.1</version>
</dependency> <dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libfb303</artifactId>
<version>0.9.3</version>
</dependency>
连接到Hive
通过表环境或YAML配置,使用Hive catalog 连接到现有的Hive安装程序。
val name = "myhive"
val defaultDatabase = "mydatabase"
val hiveConfDir = "/opt/hive-conf"
val version = "2.3.4" // or 1.2.1 val hive = new HiveCatalog(name, defaultDatabase, hiveConfDir, version)
tableEnv.registerCatalog("myhive", hive)
支持的类型
当前HiveCatalog
支持具有以下映射的大多数Flink数据类型:
Flink Data Type | Hive Data Type |
---|---|
CHAR(p) | CHAR(p) |
VARCHAR(p) | VARCHAR(p) |
STRING | STRING |
BOOLEAN | BOOLEAN |
TINYINT | TINYINT |
SMALLINT | SMALLINT |
INT | INT |
BIGINT | LONG |
FLOAT | FLOAT |
DOUBLE | DOUBLE |
DECIMAL(p, s) | DECIMAL(p, s) |
DATE | DATE |
BYTES | BINARY |
ARRAY<T> | LIST<T> |
MAP<K, V> | MAP<K, V> |
ROW | STRUCT |
局限性
Hive数据类型中的以下限制会影响Flink和Hive之间的映射:
CHAR(p)
最大长度为255VARCHAR(p)
最大长度为65535- Hive
MAP
仅支持原始键类型,而FlinkMAP
可以是任何数据类型 - 不支持Hive的 UNION 类型
- Flink的
INTERVAL
类型不能映射到HiveINTERVAL
类型 - Hive不支持 Flink
TIMESTAMP_WITH_TIME_ZONE
和TIMESTAMP_WITH_LOCAL_TIME_ZONE
- 由于精度差异,Flink的
TIMESTAMP_WITHOUT_TIME_ZONE
类型无法映射到Hive的TIMESTAMP
类型。 - Hive不支持Flink 的 MULTISET
欢迎关注Flink菜鸟公众号,会不定期更新Flink(开发技术)相关的推文
【翻译】Flink Table Api & SQL — Hive Beta的更多相关文章
- 【翻译】Flink Table Api & SQL — Catalog Beta 版
本文翻译自官网:Catalogs Beta https://ci.apache.org/projects/flink/flink-docs-release-1.9/dev/table/catalog ...
- 【翻译】Flink Table Api & SQL — Hive —— 在 scala shell 中使用 Hive 连接器
本文翻译自官网:Use Hive connector in scala shell https://ci.apache.org/projects/flink/flink-docs-release-1 ...
- 【翻译】Flink Table Api & SQL — Hive —— Hive 函数
本文翻译自官网:Hive Functions https://ci.apache.org/projects/flink/flink-docs-release-1.9/dev/table/hive/h ...
- 【翻译】Flink Table Api & SQL — Hive —— 读写 Hive 表
本文翻译自官网:Reading & Writing Hive Tables https://ci.apache.org/projects/flink/flink-docs-release-1 ...
- Flink Table Api & SQL 翻译目录
Flink 官网 Table Api & SQL 相关文档的翻译终于完成,这里整理一个安装官网目录顺序一样的目录 [翻译]Flink Table Api & SQL —— Overv ...
- 【翻译】Flink Table Api & SQL — SQL客户端Beta 版
本文翻译自官网:SQL Client Beta https://ci.apache.org/projects/flink/flink-docs-release-1.9/dev/table/sqlCl ...
- 【翻译】Flink Table Api & SQL —Streaming 概念 —— 表中的模式匹配 Beta版
本文翻译自官网:Detecting Patterns in Tables Beta https://ci.apache.org/projects/flink/flink-docs-release-1 ...
- 【翻译】Flink Table Api & SQL — 流概念
本文翻译自官网:Streaming Concepts https://ci.apache.org/projects/flink/flink-docs-release-1.9/dev/table/st ...
- 【翻译】Flink Table Api & SQL — 性能调优 — 流式聚合
本文翻译自官网:Streaming Aggregation https://ci.apache.org/projects/flink/flink-docs-release-1.9/dev/table ...
随机推荐
- Python入门篇-函数、参数及参数解构
Python入门篇-函数.参数及参数解构 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.函数概述 1>.函数的作用即分类 函数 数学定义:y=f(x) ,y是x的函数,x ...
- 百度语音合成api/sdk及demo
1.流程 1)换取token 用Api Key 和 SecretKey.访问https://openapi.baidu.com/oauth/2.0/token 换取 token // appKey = ...
- header中Content-Disposition的作用与使用方法
下载文件的时候会使用: Content-disposition 是 MIME 协议的扩展,MIME 协议指示 MIME 用户代理如何显示附加的文件.Content-disposition其实可以控制用 ...
- CentOS7安装Postman
1. 进入官网:https://www.getpostman.com/downloads/2. 点击下载3. 直接安装:tar zxvf ***.tar.gz4. 确认当前目录: pwd /home/ ...
- O(n) 取得数组中每个元素右边最后一个比它大的元素
题目 2019.9.7,icpc徐州网络赛的E题 XKC's basketball team ,计蒜客上还可以做. 链接:https://nanti.jisuanke.com/t/41387 Inpu ...
- 《Java周边》vue开发环境搭建(windows)
1. NodeJs 安装包下载 百度云:链接: https://pan.baidu.com/s/169TdKRLZd0dXbKSGTr8evw 提取码: th4a 复制这段内容后打开百度网盘手机App ...
- 《逆袭团队》第八次团队作业:Alpha冲刺
项目 内容 软件工程 任课教师博客主页链接 作业链接地址 团队作业8:Alpha冲刺 团队名称 逆袭团队 具体目标 完成最后冲刺阶段的5次博客 一.团队项目github仓库地址:Github 二.Sc ...
- 深度学习Keras框架笔记之核心层基类
Keras的Layers,就是构成网络的每一层.Keras实现了很多层,包括核心层.卷基层.RNN网络层等诸多常用的网络结构.下面开介绍核心层中包含了哪些内容.因为这个核心层我现在还没有全部用到,所以 ...
- 通过iptables限制docker容器端口
如何限制docker暴露的对外访问端口 docker 会在iptables上加上自己的转发规则,如果直接在input链上限制端口是没有效果的.这就需要限制docker的转发链上的DOCKER表. # ...
- pageContext 和 config 内置对象
forword("目标页面") : 使当前页面跳转到另一个目标页面 include("目标页面") ;使当前页面包含另一个页面的信息