You need to enable JavaScript to run this app.
导航
S3 外表
最近更新时间:2025.04.29 14:39:55首次发布时间:2024.11.06 13:58:49
我的收藏
有用
有用
无用
无用

引擎提供了与对象存储的集成,允许通过 ByteHouse 管理nS3 上的数据。

用法 - 表引擎

-- 创建单文件表
CREATE TABLE s3_engine_table (name String, value UInt32) ENGINE=CnchS3('http://....' or 'https://' or 's3://', '[format]','[compression]','[ak_id]', '[ak_secret]') 

-- 使用wildcard创建多文件表
CREATE TABLE s3_engine_table_glob_uri (name String, value UInt32) ENGINE=CnchS3('http://....' or 'https://' or 's3://', '[format]','[compression]', '[ak_id]', '[ak_secret]') 

-- 查询
select * from s3_engine_table
select * from s3_engine_table_glob_uri where _file = 'fileSimple*.csv'

-- 插入
insert into s3_engine_table values ('one', 1), ('two', 2), ('three', 3)

查询支持通过 _path_file 列进行裁剪。

CnchS3 引擎参数

用法 - table function

# 查询
select * from CnchS3('http://s3.region.amazonaws.com.cn/bucket/normal.csv', 'name String, id String')
select * from CnchS3('http://s3.region.amazonaws.com.cn/bucket/*.csv', 'name String, id String') where _path like '%test%'


# 插入
insert into function  CnchS3('http://s3.region.amazonaws.com.cn/bucket/normal_write.csv', 'name String, id String') values ('one', '1'), ('two', '2'), ('three', '3')

# 分区插入
# 请确保路径中包含'{_partition_id}'字段
insert into function
    CnchS3('http://s3.region.amazonaws.com.cn/bucket/{_partition_id}_partition_write.csv', 'name String, id String')
    partition by name
values ('one', '1'),('one', '2'),('two', '1'),('two', '2');

select * from jiashuo_db.s3_glob where _file like '%partition_write%' 

Format 和 Compression 为可选参数。需要指定数据的 schema。