Apache Paimon 使用之Creating Catalogs

2024-03-07 08:04

本文主要是介绍Apache Paimon 使用之Creating Catalogs,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Paimon Catalog 目前支持两种类型的metastores:

filesystem metastore (default),在文件系统中存储元数据和表文件。
hive metastore,将metadata存储在Hive metastore中。用户可以直接从Hive访问表。

1.使用 Filesystem Metastore 创建 Catalog

Flink引擎

Flink SQL注册并使用名为my_catalog的Paimon catalog,元数据和表文件存储在hdfs:///path/to/warehouse下。

CREATE CATALOG my_catalog WITH ('type' = 'paimon','warehouse' = 'hdfs:///path/to/warehouse'
);USE CATALOG my_catalog;

在 Catalog 中创建的 tables,可以使用前缀table-default.定义任何默认表选项。

Spark3引擎

通过 shell 命令注册一个名为paimon的paimon catalog,元数据和表文件存储在hdfs:///path/to/warehouse下。

spark-sql ... \--conf spark.sql.catalog.paimon=org.apache.paimon.spark.SparkCatalog \--conf spark.sql.catalog.paimon.warehouse=hdfs:///path/to/warehouse

对于 catalog 中创建的 tables,可以使用前缀spark.sql.catalog.paimon.table-default.定义默认表选项。

spark-sql启动后,使用以下SQL切换到paimon目录的default数据库。

USE paimon.default;
2.使用 Hive Metastore 创建 Catalog

使用Paimon Hive catalog,对 catalog 的更改将直接影响相应的Hive metastore,在此类 catalog 中创建的表可以直接从 Hive 访问。

要使用Hive catalog,数据库名称、表名和字段名均应小写

Flink 引擎

Flink 中的Paimon Hive catalog依赖于Flink Hive connector bundled jar,首先要下载Hive connector bundled jar,并将其添加到classpath。

以下Flink SQL注册并使用名为my_hive的Paimon Hive catalog,元数据和表文件存储在hdfs:///path/to/warehouse下,元数据也存储在Hive metastore中。

如果Hive需要security authentication,如Kerberos、LDAP、Ranger,或者希望paimon表由Apache Atlas管理(在hive-site.xml中设置"hive.metastore.event.listeners"),可以在hive-site.xml文件路径中指定hive-conf-dir和hadoop-conf-dir参数。

CREATE CATALOG my_hive WITH ('type' = 'paimon','metastore' = 'hive',-- 'uri' = 'thrift://<hive-metastore-host-name>:<port>', default use 'hive.metastore.uris' in HiveConf-- 'hive-conf-dir' = '...', this is recommended in the kerberos environment-- 'hadoop-conf-dir' = '...', this is recommended in the kerberos environment-- 'warehouse' = 'hdfs:///path/to/warehouse', default use 'hive.metastore.warehouse.dir' in HiveConf
);USE CATALOG my_hive;

对于在 catalog 中创建的表,可以使用前缀table-default.定义默认表选项。

此外,还可以创建Flink Generic Catalog。

Spark3引擎

Spark需要包含Hive dependencies。

以下shell命令注册一个名为paimon的Paimon Hive Catalog,元数据和表文件存储在hdfs:///path/to/warehouse下,此外,元数据也存储在Hive metastore中。

spark-sql ... \--conf spark.sql.catalog.paimon=org.apache.paimon.spark.SparkCatalog \--conf spark.sql.catalog.paimon.warehouse=hdfs:///path/to/warehouse \--conf spark.sql.catalog.paimon.metastore=hive \--conf spark.sql.catalog.paimon.uri=thrift://<hive-metastore-host-name>:<port>

对于 Catalog 中创建的表,可以使用前缀spark.sql.catalog.paimon.table-default.定义默认表选项。

spark-sql启动后,可以使用以下SQL切换到paimon catalog的default数据库。

USE paimon.default;

此外,还可以创建Spark Generic Catalog。

当使用Hive Catalog通过alter table更改不兼容的列类型时,需要配置hive.metastore.disallow.incompatible.col.type.changes=false

如果使用的是Hive3,请禁用Hive ACID:

hive.strict.managed.tables=false
hive.create.as.insert.only=false
metastore.create.as.acid=false
3.在Properties中设置Location

如果使用的是对象存储,并且不希望paimon表/数据库的location被hive的文件系统访问,这可能会导致诸如“No filesystem for scheme:s3a”之类的错误,可以通过在属性中配置location来设置表/数据库的location-in-properties。

4.同步Partitions到Hive Metastore

默认,Paimon不会将新创建的分区同步到Hive metastore中,用户将在Hive中看到一个未分区的表,Partition push-down将改为通过filter push-down进行。

如果想在Hive中查看分区表,并将新创建的分区同步到Hive metastore中,请将表属性metastore.partitioned-table设置为true。

5.添加参数到Hive Table

使用table option有助于方便地定义Hive表参数,以hive.前缀的参数将在Hive表的TBLPROPERTIES中自动定义。例如,使用hive.table.owner=Jon将在创建过程中自动将表参数table.owner=Jon添加到表属性中。

6.CatalogOptions
KeyDefaultTypeDescription
fs.allow-hadoop-fallbacktrueBooleanAllow to fallback to hadoop File IO when no file io found for the scheme.
lineage-meta(none)StringThe lineage meta to store table and data lineage information. Possible values: “jdbc”: Use standard jdbc to store table and data lineage information.“custom”: You can implement LineageMetaFactory and LineageMeta to store lineage information in customized storage.
lock-acquire-timeout8 minDurationThe maximum time to wait for acquiring the lock.
lock-check-max-sleep8 sDurationThe maximum sleep time when retrying to check the lock.
lock.enabledfalseBooleanEnable Catalog Lock.
metastore“filesystem”StringMetastore of paimon catalog, supports filesystem and hive.
table.typemanagedEnumType of table. Possible values:“managed”: Paimon owned table where the entire lifecycle of the table data is managed.“external”: The table where Paimon has loose coupling with the data stored in external locations.
uri(none)StringUri of metastore server.
warehouse(none)StringThe warehouse root path of catalog.

FilesystemCatalogOptions

KeyDefaultTypeDescription
case-sensitivetrueBooleanIs case sensitive. If case insensitive, you need to set this option to false, and the table name and fields be converted to lowercase.

HiveCatalogOptions

KeyDefaultTypeDescription
hadoop-conf-dir(none)StringFile directory of the core-site.xml、hdfs-site.xml、yarn-site.xml、mapred-site.xml. Currently, only local file system paths are supported. If not configured, try to load from ‘HADOOP_CONF_DIR’ or ‘HADOOP_HOME’ system environment. Configure Priority: 1.from ‘hadoop-conf-dir’ 2.from HADOOP_CONF_DIR 3.from HADOOP_HOME/conf 4.HADOOP_HOME/etc/hadoop.
hive-conf-dir(none)StringFile directory of the hive-site.xml , used to create HiveMetastoreClient and security authentication, such as Kerberos, LDAP, Ranger and so on. If not configured, try to load from ‘HIVE_CONF_DIR’ env.
location-in-propertiesfalseBooleanSetting the location in properties of hive table/database. If you don’t want to access the location by the filesystem of hive when using a object storage such as s3,oss you can set this option to true.

FlinkCatalogOptions

KeyDefaultTypeDescription
default-database“default”String
disable-create-table-in-default-dbfalseBooleanIf true, creating table in default database is not allowed. Default is false.

这篇关于Apache Paimon 使用之Creating Catalogs的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/782866

相关文章

使用Python和OpenCV库实现实时颜色识别系统

《使用Python和OpenCV库实现实时颜色识别系统》:本文主要介绍使用Python和OpenCV库实现的实时颜色识别系统,这个系统能够通过摄像头捕捉视频流,并在视频中指定区域内识别主要颜色(红... 目录一、引言二、系统概述三、代码解析1. 导入库2. 颜色识别函数3. 主程序循环四、HSV色彩空间详解

Windows下C++使用SQLitede的操作过程

《Windows下C++使用SQLitede的操作过程》本文介绍了Windows下C++使用SQLite的安装配置、CppSQLite库封装优势、核心功能(如数据库连接、事务管理)、跨平台支持及性能优... 目录Windows下C++使用SQLite1、安装2、代码示例CppSQLite:C++轻松操作SQ

Python常用命令提示符使用方法详解

《Python常用命令提示符使用方法详解》在学习python的过程中,我们需要用到命令提示符(CMD)进行环境的配置,:本文主要介绍Python常用命令提示符使用方法的相关资料,文中通过代码介绍的... 目录一、python环境基础命令【Windows】1、检查Python是否安装2、 查看Python的安

Python并行处理实战之如何使用ProcessPoolExecutor加速计算

《Python并行处理实战之如何使用ProcessPoolExecutor加速计算》Python提供了多种并行处理的方式,其中concurrent.futures模块的ProcessPoolExecu... 目录简介完整代码示例代码解释1. 导入必要的模块2. 定义处理函数3. 主函数4. 生成数字列表5.

Python中help()和dir()函数的使用

《Python中help()和dir()函数的使用》我们经常需要查看某个对象(如模块、类、函数等)的属性和方法,Python提供了两个内置函数help()和dir(),它们可以帮助我们快速了解代... 目录1. 引言2. help() 函数2.1 作用2.2 使用方法2.3 示例(1) 查看内置函数的帮助(

Linux脚本(shell)的使用方式

《Linux脚本(shell)的使用方式》:本文主要介绍Linux脚本(shell)的使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录概述语法详解数学运算表达式Shell变量变量分类环境变量Shell内部变量自定义变量:定义、赋值自定义变量:引用、修改、删

Java使用HttpClient实现图片下载与本地保存功能

《Java使用HttpClient实现图片下载与本地保存功能》在当今数字化时代,网络资源的获取与处理已成为软件开发中的常见需求,其中,图片作为网络上最常见的资源之一,其下载与保存功能在许多应用场景中都... 目录引言一、Apache HttpClient简介二、技术栈与环境准备三、实现图片下载与保存功能1.

Python中使用uv创建环境及原理举例详解

《Python中使用uv创建环境及原理举例详解》uv是Astral团队开发的高性能Python工具,整合包管理、虚拟环境、Python版本控制等功能,:本文主要介绍Python中使用uv创建环境及... 目录一、uv工具简介核心特点:二、安装uv1. 通过pip安装2. 通过脚本安装验证安装:配置镜像源(可

LiteFlow轻量级工作流引擎使用示例详解

《LiteFlow轻量级工作流引擎使用示例详解》:本文主要介绍LiteFlow是一个灵活、简洁且轻量的工作流引擎,适合用于中小型项目和微服务架构中的流程编排,本文给大家介绍LiteFlow轻量级工... 目录1. LiteFlow 主要特点2. 工作流定义方式3. LiteFlow 流程示例4. LiteF

使用Python开发一个现代化屏幕取色器

《使用Python开发一个现代化屏幕取色器》在UI设计、网页开发等场景中,颜色拾取是高频需求,:本文主要介绍如何使用Python开发一个现代化屏幕取色器,有需要的小伙伴可以参考一下... 目录一、项目概述二、核心功能解析2.1 实时颜色追踪2.2 智能颜色显示三、效果展示四、实现步骤详解4.1 环境配置4.