Skip to content

Lists files in a stage. This allows you to filter files in a stage based on their extensions and obtain comprehensive details about each file. The function is similar to the DDL command LIST STAGE FILES, but provides you the flexibility to retrieve specific file information with the SELECT statement, such as file name, size, MD5 hash, last modified timestamp, and creator, rather than all file information.

LIST_STAGE(
LOCATION => '{ internalStage | externalStage | userStage }'
[ PATTERN => '<regex_pattern>']
)

Where:

internalStage ::= @<internal_stage_name>[/<path>]
externalStage ::= @<external_stage_name>[/<path>]
userStage ::= @~[/<path>]

See COPY INTO table.

SELECT * FROM list_stage(location => '@my_stage/', pattern => '.*[.]log');
┌────────────────┬──────┬────────────────────────────────────┬───────────────────────────────┬─────────┐
namesize │ md5 │ last_modified │ creator │
├────────────────┼──────┼────────────────────────────────────┼───────────────────────────────┼─────────┤
2023/meta.log475"4208ff530b252236e14b3cd797abdfbd"2023-04-19 20:23:24.000 +0000NULL
2023/query.log1348"1c6654b207472c277fc8c6207c035e18"2023-04-19 20:23:24.000 +0000NULL
└────────────────┴──────┴────────────────────────────────────┴───────────────────────────────┴─────────┘
-- Equivalent to the following statement:
LIST @my_stage PATTERN = '.log';