将apache Iceberg表写入azure ADLS / S3而不使用外部目录

sha*_*359 0 amazon-s3 apache-iceberg

我正在尝试在云对象存储上创建冰山表格式。

\n

在下图中我们可以看到冰山表格式需要一个目录。该目录存储当前元数据指针,该指针指向最新的元数据。Iceberg 快速入门文档列出了 JDBC、Hive MetaStore、AWS Glue、Nessie 和 HDFS 作为可以使用的目录列表。

\n

在此输入图像描述

\n

我的目标是将当前元数据指针(version-hint.text)以及表数据的其余部分(元数据、清单列表、清单、镶木地板数据文件)存储在对象存储本身中。

\n
\n

以HDFS为目录,table\xe2\x80\x99s元数据文件夹中有一个名为version-hint.text的文件,其内容为当前元数据文件的版本号。

\n
\n

将 HDFS 视为可能的目录之一,我应该能够使用 ADLS 或 S3 来存储当前元数据指针以及其余数据。例如:spark 使用 ABFSS 接口连接到 ADLS 并创建冰山表和目录。

\n

我的问题是

\n
    \n
  • 使用版本提示文件作为 ADLS/S3 中的当前元数据指针是否安全?如果我这样做,我会失去任何冰山功能吗?查看一位贡献者的评论表明它对于生产来说并不理想。
  • \n
\n
\n

版本提示文件用于 Hadoop 表,之所以这样命名,是因为它们适用于 HDFS。我们还将它们用于本地 FS\n测试,但它们不能与 S3 安全地同时使用。对于 S3,您需要一个元存储来在交换表元数据位置时强制执行原子性。您可以使用iceberg-hive 中的\nHive 元存储。

\n
\n
    \n
  • 看看这个线程的评论,version-hint.text 文件是可选的吗?
  • \n
\n
\n

我们遍历可能的元数据位置,仅当\n没有新快照可用时才停止

\n
\n

有人可以澄清一下吗?

\n

我正在尝试使用 Iceberg 进行 POC。此时的要求是能够至少每10分钟将新数据从数据块写入到表中。这个频率将来可能会增加。

\n

数据一旦写入,将被databricks和dremio读取。

\n

小智 7

I would definitely try to use a catalog other than the HadoopCatalog / hdfs type for production workloads.

As somebody who works on Iceberg regularly (I work at Tabular), I can say that we do think of the hadoop catalog as being more for testing.

The major reason for that, as mentioned in your threads, is that the catalog provides an atomic locking compare-and-swap operation for the current top level metadata.json file. This compare and swap operation allows for the query that's updating the table to grab a lock for the table after doing its work (optimistic locking), write out the new metadata file, update the state in the catalog to point to the new metadata file, and then release that lock.

The lock isn't something that really works out of the box with HDFS / hadoop type catalog. And then it becomes possible for two concurrent actions to write out a metadata file, and then one sets it and the other's work gets erased or undefined behavior occurs as ACID compliance is lost.

If you have an RDS instance or some sort of JDBC database, I would suggest that you consider using that temporarily. There's also the DynamoDB catalog, and if you're using Dremio then nessie can be used as your catalog as well

In the next version of Iceberg -- the next major version after 0.14, which will likely be 1.0.0, there is a procedure to register tables into a catalog, which makes it easy to move a table from one catalog to another in a very efficient metadata only operation, such as CALL catalog.system.register_table('$new_table_name', '$metadata_file_location');

因此,如果您从 JDBC 目录等简单的目录开始,然后转向其他目录,您就不会被锁定在一个目录中。如果您只是在制定 POC,您可以从 Hadoop 目录开始,然后在您更熟悉后转向 JDBC 目录之类的内容,但重要的是要了解 hadoop 类型目录的潜在陷阱,因为它不会没有对表示当前表状态的元数据文件进行原子比较和交换锁定操作。

还有一个选项可以为 hadoop 目录提供锁定机制,例如 Zookeeper 或 etcd,但这是一个有点高级的功能,需要您编写自己的自定义锁定实现。

因此,我仍然认为 JDBC 目录是最容易上手的,因为大多数人可以从他们的云提供商处获取 RDBMS 或轻松启动一个 RDBMS——尤其是现在您将能够有效地将表移动到新目录使用当前主分支或下一个主要 Iceberg 版本中的代码,无需担心太多。

看看这个线程的评论,version-hint.text 文件是可选的吗?

是的,version-hint.txthadoop 类型目录使用该文件来尝试提供表当前顶级元数据文件所在的权威位置。soversion-hint.txt只能在 hadoop 目录中找到,因为其他目录以自己的特定机制存储它。RDBMS 实例中的表用于在使用 JDBC 目录甚至 Hive 目录(由 Hive Metastore(通常是 RDBMS)支持)时存储所有目录“版本提示”。其他目录包括 DynamoDB 目录。

如果您有更多问题,Apache Iceberg slack非常活跃。

请随意查看 docker-spark-iceberg 入门教程(我帮助创建的),其中包括 Jupyter 笔记本和 docker-compose 设置。

它使用 Postgres 支持的 JDBC 目录。这样,您可以通过 ssh 进入容器并运行 psql 命令以及查看本地计算机上的表数据来了解目录正在做什么。还有一些带有示例数据的不错的教程! https://github.com/tabular-io/docker-spark-iceberg