LIST
Applies to: Databricks SQL
Databricks Runtime 10.4 LTS and above
Unity Catalog only
Lists the objects immediately contained at the URL.
Syntax
LIST url [ WITH ( CREDENTIAL credential_name ) ] [ LIMIT limit ]
Parameters
-
url
A
STRINGliteral with the location of the cloud storage described as an absolute URL. -
An optional named credential used to access this URL. If you supply a credential it must be sufficient to access the URL. If you do not supply a credential the URL must be contained in an external location to to which you have access.
-
limit
An optional
INTEGERconstant used to limit the number of objects returned.In Databricks Runtime 10.4 LTS the default limit is
1001and only values between 1 and 1001 are supported.
Returns
A result set with the following columns:
path STRING NOT NULL: The full URI of the storage object.name STRING NOT NULL: The name of the storage object, including its extension.size BIGINT NOT NULL: The size of the object in bytes.0for directories.modification_time BIGINT NOT NULL: The Unix timestamp of the object's last modification time in milliseconds. To convert this value to aTIMESTAMPtype, useCAST(modification_time / 1000 AS TIMESTAMP)orto_timestamp(modification_time / 1000).
Examples
SQL
> LIST 's3://us-east-1-dev/some_dir' WITH (CREDENTIAL aws_some_dir) LIMIT 2
path name size modification_time
---------------------------------- ------ ---- -----------------
s3://us-east-1-dev/some_dir/table1 table1 0 1706105124000
s3://us-east-1-dev/some_dir/table2 table2 1024 1706201562000