The Linux Foundation Projects
Delta Lake

将 Delta Sharing 扩展到 Google Cloud Storage

作者:Will GirtenShixiong Zhu

我们很高兴地宣布,开源数据湖项目 Delta Lake 的 Delta Sharing 0.4.0 版本已发布。最新版本引入了几项重要的增强功能和错误修复,包括以下特性:

  • Delta Sharing 现已支持 Google Cloud Storage - 您现在可以在 Google Cloud Platform 上共享 Delta 表 (#81, #105)
  • 用于获取 Delta Share 元数据的新 API - 新增了一个 GetShare REST API,用于按名称查询 Share (#95, #97)
  • Delta Sharing 协议和 REST API 增强功能 - Delta Sharing 协议已扩展,包含 Share ID 和 Table ID,并改进了响应代码和错误代码 (#85, #89, #93, #98)
  • 在 Apache Spark™ 连接器中自定义接收者共享配置文件 - Spark 连接器中新增了一个 Delta Sharing Profile Provider,以便更轻松地访问共享配置文件 (#99, #107)

在这篇博客文章中,我们将详细介绍此版本中的每一项改进。

Delta Sharing 在 Google Cloud Storage 上的应用

此版本新增功能,您现在可以使用 Delta Sharing Server 的参考实现,在 Google Cloud Storage 中共享 Delta 表。

Extending Delta Sharing to GCS

图 1 - 借助 Delta Sharing 0.4.0,您现在可以共享存储在 Google Cloud Storage 上的 Delta 表。

Google Cloud Storage 上的 Delta Sharing 示例

在 Google Cloud Storage 上共享 Delta 表比以往任何时候都更容易!例如,要共享一个名为 Time 的 Delta 表,您只需使用 Google Cloud Storage 上 Delta 表的位置更新 Delta Sharing 服务器配置即可

version: 1
shares:
- name: "vaccineshare"
 schemas:
 - name: "samplecoviddata"
   tables:
   - name: "time"
     location: "gs://deltasharingexample/COVID/Time"
{" "} 代码 1 - 包含 Google Cloud Storage 上 Delta 表位置的 Delta Sharing Server 配置文件。

Delta Sharing 服务器将自动处理 Google Cloud Storage 上的数据以进行 Delta Sharing 查询。

使用 Google Cloud Storage 进行身份验证

Delta Sharing Server 充当 Delta Share 中底层数据的守门员。当接收者查询 Delta Share 中的 Delta 表时,Delta Sharing Server 首先检查权限,以确保数据接收者有权访问数据。接下来,如果允许访问,Delta Sharing Server 将查看构成 Delta 表的文件对象,如果查询中包含谓词,则智能地过滤掉文件。最后,Delta Sharing Server 将生成短期的预签名 URL,允许数据接收者直接从云存储而不是通过 Delta Sharing Server 流式传输数据,从 Delta Sharing 客户端访问文件或文件子集。

Delta Sharing Server Authentication with GCS

图 2 - Delta Sharing Server 充当 Delta Share 中底层数据的守门员。

为了生成短期的文件 URL,Delta Sharing Server 使用 服务帐户 从 Google Cloud Storage 读取 Delta 表。要配置服务帐户凭据,您可以在启动 Delta Sharing Server 之前设置环境变量 GOOGLE_APPLICATION_CREDENTIALS

export GOOGLE_APPLICATION_CREDENTIALS="/config/keyfile.json"
{" "} 代码 2 - 在 Delta Sharing 服务器上将 GCS 密钥文件的位置设置为环境变量。

获取 Delta Share 的新 API

有时,对于接收者来说,检查他们是否仍然有权访问 Delta Share 可能会很有用。此版本添加了一个新的 REST API GetShare,以便用户可以快速测试 Delta Share 是否已超过其过期时间。

例如,要检查您是否仍然有权访问 Delta Share,您只需向共享服务器上的 /shares/{share_name} 端点发送 GET 请求即可

import requests
import json

response = requests.get(
   "https://:8080/delta-sharing/shares/airports",
   headers={
       "Authorization":"Bearer token"
   }
)
print(json.dumps(response.json(), indent=2))
{" "} 代码 3 - 发送到共享服务器的 GET 请求示例,使接收者能够检查他们是否仍然有权访问 Delta Share。

{
	"share": {
		"name": "airports"
	}
}
{" "} 代码 4 - 从 Delta Sharing 0.4.0 版本新增的 GetShare REST API 收到的响应示例。

如果 Delta Share 已超过其有效期,共享服务器将返回 403 HTTP 错误代码。

Delta Sharing 协议增强功能

此版本中包含了 Delta Sharing 协议定义中改进的错误代码和错误消息。例如,如果 Delta Share 未位于 Delta Sharing Server 上,此版本现在包含包含错误详细信息的错误代码和错误消息。

import requests
import json

response = requests.get(
   "https://:8080/delta-sharing/shares/yellowcab",
   headers={
       "Authorization":"Bearer token"
   }
)
print(json.dumps(response.json(), indent=2))
{" "} 代码 5 - 对 Delta Sharing Server 上不存在的 Share 的 GET 请求示例。

{
	"errorCode": "RESOURCE_DOES_NOT_EXIST",
	"message": "share 'yellowcab' not found"
}
{" "} 代码 6 - 包含改进的错误代码和错误详细信息的响应示例,这是 Delta Sharing 0.4.0 版本的新增功能。

此外,此版本扩展了 Delta Sharing 协议,以响应唯一的 Delta Share 和 Table ID。唯一的 ID 有助于数据接收者随着时间的推移消除数据集名称的歧义。当数据接收者是一个大型组织并希望在其组织内对共享数据集应用访问控制时,这尤其有用

自定义接收者共享配置文件

Delta Sharing 配置文件是一个 JSON 配置文件,其中包含接收者访问 Delta Sharing 服务器上共享数据的信息。此版本中添加了一个新的提供程序,使数据接收者可以更轻松地访问 Delta Sharing 配置文件。

/**
 * A provider that provides a Delta Sharing profile for data
 * recipients to access the shared data.
 */
trait DeltaSharingProfileProvider {
 def getProfile: DeltaSharingProfile
}
{" "} 代码 7 - Delta Sharing 配置文件是一个 JSON 配置文件,其中包含接收者访问 Delta Sharing 服务器上共享数据的信息。

接下来

我们已经为 Delta Sharing 的下一个版本准备了许多新功能。您可以在 GitHub 里程碑 中跟踪所有即将发布的版本和计划功能。

致谢

我们要特别感谢 Denny Lee、Lin Zhou、Shixiong Zhu、William Chau、Xiaotong Sun、Kohei Toshimitsu 对此版本的贡献。

访问发行说明以了解有关此版本的更多信息。

LinkedIn 上关注我们的作者