Project: ClickHouse (App Definition and Development / Database)
File: s3Cluster.md

slug: /en/sql-reference/table-functions/s3Cluster sidebar_position: 181 sidebar_label: s3Cluster title: "s3Cluster Table Function" This is an extension to the table function. Allows processing files from and Google Cloud Storage in parallel from many nodes in a specified cluster. On initiator it creates a connection to all nodes in the cluster, discloses asterisks in S3 file path, and dispatches each file dynamically. On the worker node it asks the initiator about the next task to process and processes it. This is repeated until all tasks are finished. Syntax ``` sql s3Cluster(clustername, url [, NOSIGN | accesskeyid, secretaccesskey, [sessiontoken]] [,format] [,structure] [,compression_method]) s3Cluster(clustername, namedcollection[, option=value [,..]]) ``` Arguments `cluster_name` Name of a cluster that is used to build a set of addresses and connection parameters to remote and local servers. `url` path to a file or a bunch of files. Supports following wildcards in readonly mode: ``, `*`, `?`, `{'abc','def'}` and `{N..M}` where `N`, `M` numbers, `abc`, `def` strings. For more information see . `NOSIGN` If this keyword is provided in place of credentials, all the requests will not be signed. `accesskeyid` and `secretaccesskey` Keys that specify credentials to use with given endpoint. Optional. `session_token` - Session token to use with the given keys. Optional when passing keys. `format` The of the file. `structure` Structure of the table. Format `'column1name column1type, column2name column2type, ...'`. `compression_method` Parameter is optional. Supported values: `none`, `gzip/gz`, `brotli/br`, `xz/LZMA`, `zstd/zst`. By default, it will autodetect compression method by file extension. Arguments can also be passed using . In this case `url`, `accesskeyid`, `secretaccesskey`, `format`, `structure`, `compression_method` work in the same way, and some extra parameters are supported: `filename` appended to the url if specified. `useenvironmentcredentials` enabled by default, allows passing extra parameters using environment variables `AWSCONTAINERCREDENTIALSRELATIVEURI`, `AWSCONTAINERCREDENTIALSFULLURI`, `AWSCONTAINERAUTHORIZATIONTOKEN`, `AWSEC2METADATADISABLED`. `nosignrequest` disabled by default. `expirationwindowseconds` default value is 120. Returned value A table with the specified structure for reading or writing data in the specified file. Examples Select the data from all the files in the `/root/data/clickhouse` and `/root/data/database/` folders, using all the nodes in the `cluster_simple` cluster: ``` sql SELECT * FROM s3Cluster( 'cluster_simple', 'http://minio1:9001/root/data/{clickhouse,database}/*', 'minio', 'minio123', 'CSV', 'name String, value UInt32, polygon Array(Array(Tuple(Float64, Float64)))' ) ORDER BY (name, value, polygon); ``` Count the total amount of rows in all files in the cluster `cluster_simple`: :::tip If your listing of files contains number ranges with leading zeros, use the construction with braces for each digit separately or use `?`. ::: For production use cases it is recommended to use . Here is the example: ``` sql CREATE NAMED COLLECTION creds AS accesskeyid = 'minio' secretaccesskey = 'minio123'; SELECT count(*) FROM s3Cluster( 'cluster_simple', creds, url='https://s3-object-url.csv', format='CSV', structure='name String, value UInt32, polygon Array(Array(Tuple(Float64, Float64)))' ) ``` See Also