LIST_STAGE (Lakehouse v1)
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.
SQL Syntax
Section titled “SQL Syntax”LIST_STAGE( LOCATION => '{ internalStage | externalStage | userStage }' [ PATTERN => '<regex_pattern>'])Where:
Internalstage
Section titled “Internalstage”internalStage ::= @<internal_stage_name>[/<path>]Externalstage
Section titled “Externalstage”externalStage ::= @<external_stage_name>[/<path>]Userstage
Section titled “Userstage”userStage ::= @~[/<path>]PATTERN
Section titled “PATTERN”See COPY INTO table.
SQL Examples
Section titled “SQL Examples”SELECT * FROM list_stage(location => '@my_stage/', pattern => '.*[.]log');┌────────────────┬──────┬────────────────────────────────────┬───────────────────────────────┬─────────┐│ name │ size │ md5 │ last_modified │ creator │├────────────────┼──────┼────────────────────────────────────┼───────────────────────────────┼─────────┤│ 2023/meta.log │ 475 │ "4208ff530b252236e14b3cd797abdfbd" │ 2023-04-19 20:23:24.000 +0000 │ NULL ││ 2023/query.log │ 1348 │ "1c6654b207472c277fc8c6207c035e18" │ 2023-04-19 20:23:24.000 +0000 │ NULL │└────────────────┴──────┴────────────────────────────────────┴───────────────────────────────┴─────────┘
-- Equivalent to the following statement:LIST @my_stage PATTERN = '.log';