Skip to main content

list_files(directory_url)

The list_files() SQL function is used to display a list of files from a specified directory URL and returns their names and sizes. Built using object_store which supports passing any object store such as AWS S3, Google Cloud Storage, Azure Blob Storage, WebDAV etc.

Syntax

list_files(directory_url)

Parameters

ParameterTypeOptionalDescriptionPossible ValuesSample Value
directory_urlStringNoThe URL of the directory from which to list files.A valid file URL in string format.'file:///var/lib/clickhouse/user_files'

Usage Example

SELECT * FROM list_files('file:///var/lib/clickhouse/user_files');

Description Of Example

The above example will return a list of files from the specified directory URL. The output is a table with the following columns:

  • name: Contains the name of the file.
  • size: Contains the size of the file in bytes.
  • last_modified: Contains the timestamp of when the file was last modified.
  • e_tag: Contains the entity tag (ETag) of the file, which is a unique identifier assigned to each file for tracking changes.
| name                                      | size    | last_modified       | e_tag                    |
|-------------------------------------------|---------|---------------------|--------------------------|
| var/lib/clickhouse/user_files/output1.tsv | 2595585 | 2024-06-14 08:00:00 | 31027c6-666bf880-279b01 |
| var/lib/clickhouse/user_files/sample.txt | 3541 | 2024-06-14 08:10:00 | eeff9e73-666bfad8-dd5 |
| var/lib/clickhouse/user_files/test.tsv | 5205200 | 2024-06-14 08:20:00 | 84ff9f76-666bfd30-4f6cd0 |
| var/lib/clickhouse/user_files/output2.tsv | 2609751 | 2024-06-14 08:30:00 | 8f2959aa-666bff88-27d257 |