允许在指定集群中的多个节点上并行处理 Azure Blob Storage 中的文件。在发起节点上,它会与集群中的所有节点建立连接,解析 S3 文件路径中的星号,并动态分发各个文件。在工作节点上,它会向发起节点请求下一个待处理任务并执行处理。该过程会重复进行,直到所有任务全部完成。 此表函数与 s3Cluster 表函数 类似。
语法
azureBlobStorageCluster(cluster_name, connection_string|storage_account_url, container_name, blobpath, [account_name, account_key, format, compression, structure])参数
| 参数 | 说明 |
|---|---|
cluster_name |
用于构建远程和本地 server 的一组地址及 connection 参数的集群名称。 |
connection_string |
storage_account_url` — connection_string 包含账户名和 key (创建 connection string) ;你也可以在此处提供 storage account url,并将账户名和账户 key 作为单独参数传入 (参见参数 account_name 和 account_key) |
container_name |
Container 名称 |
blobpath |
文件路径。在 readonly 模式下支持以下 wildcards:*、**、?、{abc,def} 和 {N..M},其中 N、M 表示数字,'abc'、'def' 表示字符串。 |
account_name |
如果使用 storage_account_url,则可在此处指定账户名 |
account_key |
如果使用 storage_account_url,则可在此处指定账户 key |
format |
文件的 format。 |
compression |
支持的值:none、gzip/gz、brotli/br、xz/LZMA、zstd/zst。默认情况下,会根据文件扩展名自动检测压缩方式。 (等同于将其设置为 auto。) |
structure |
表的结构。格式为 'column1_name column1_type, column2_name column2_type, ...'。 |
返回值
一个具有指定结构的表,可用于读取指定文件中的数据或向其中写入数据。
示例
与 AzureBlobStorage 表引擎类似,用户可以使用 Azurite 模拟器在本地开发 Azure Storage。更多详情请参见此处。下文假设可通过主机名 azurite1 访问 Azurite。
使用 cluster_simple 集群中的所有节点,统计文件 test_cluster_*.csv 的数量:
SELECT count(*) FROM azureBlobStorageCluster(
'cluster_simple', 'http://azurite1:10000/devstoreaccount1', 'testcontainer', 'test_cluster_count.csv', 'devstoreaccount1',
'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==', 'CSV',
'auto', 'key UInt64')示例请参见 azureBlobStorage。