> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firebolt.io/llms.txt
> Use this file to discover all available pages before exploring further.

> Reference material for READ_FILES function

# READ_FILES

A table-valued function (TVF) that reads a file of any supported format, inferring the format and dispatching to the matching reader (`READ_PARQUET`, `READ_CSV`, `READ_JSON`, `READ_AVRO`). Use it when you do not want to name the format up front. Like the other read TVFs, it accepts a `LOCATION` object or direct credentials, and reads a single file or a glob of files.

`READ_FILES` also has a shorthand: a string literal in the `FROM` clause is read as `READ_FILES`, so

```sql theme={"theme":{"light":"css-variables","dark":"css-variables"}}
SELECT * FROM '/data/events/2026-06-01.parquet';
```

is equivalent to `SELECT * FROM READ_FILES('/data/events/2026-06-01.parquet')`. This works for local paths and for object storage that does not need credentials (for example public Amazon S3 buckets); to pass credentials or a `LOCATION`, call `READ_FILES(...)` directly.

## Format inference

The format is inferred by listing the objects the path points at and inspecting the most recent one's name, after stripping any compression suffix (`.gz`, `.zst`, `.br`, ...). The path itself does not need an extension: a directory or glob resolves from the files it matches, so `s3://bucket/events/*` containing only `.json.gz` objects reads as gzip-compressed JSON. Recognized extensions:

| Extension                    | Format                                 |
| :--------------------------- | :------------------------------------- |
| `.parquet`                   | Parquet                                |
| `.csv`                       | CSV                                    |
| `.tsv`                       | TSV (read as CSV with a tab delimiter) |
| `.json`, `.jsonl`, `.ndjson` | JSON                                   |
| `.avro`                      | Avro                                   |
| `.orc`                       | ORC                                    |

If the matched objects have no usable extension, `READ_FILES` cannot infer the format; use the format-specific TVF (`READ_PARQUET`, `READ_CSV`, ...) instead.

## Syntax

```sql theme={"theme":{"light":"css-variables","dark":"css-variables"}}
-- Using LOCATION object (recommended)
READ_FILES (
  LOCATION => 'location_name'
  [, PATTERN => <pattern>]
  [, COMPRESSION => <file_compression>]
)
|
-- Using static credentials
READ_FILES (
  URL => <url>
  [, COMPRESSION => <file_compression>]
  [, AWS_ACCESS_KEY_ID => <aws_access_key_id>]
  [, AWS_SECRET_ACCESS_KEY => <aws_secret_access_key>]
  [, AWS_SESSION_TOKEN => <aws_session_token>]
  [, AWS_ROLE_ARN => <aws_role_arn>]
  [, AWS_ROLE_EXTERNAL_ID => <aws_role_external_id>]
)
|
-- Shorthand: a string literal in the FROM clause
SELECT * FROM '<path>';
```

When you pass `AWS_ROLE_ARN`, set the optional `AWS_ROLE_EXTERNAL_ID` to add a customer-controlled condition to your role's trust policy.

<Note>
  For role-based AWS access you can additionally set an external ID. An external ID is a value you choose and control that AWS checks when Firebolt assumes your role, adding a second condition on top of your account's unique IAM principal. Configuring one is a recommended best practice. See [IAM roles](/security#iam-roles).
</Note>

## Parameters

| Parameter               | Description                                                                                                                                                                                                                                                                                                                   | Supported input types |
| :---------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------- |
| `LOCATION`              | The name of a location object that contains the Amazon S3 URL and credentials. Firebolt recommends using `LOCATION` to store credentials for authentication. For a comprehensive guide, see [LOCATION objects](/security/guides/location).                                                                                    | `TEXT`                |
| `PATTERN`               | When using `LOCATION`, an optional glob pattern to filter files within the location's URL path, applied relative to the location's base path.                                                                                                                                                                                 | `TEXT`                |
| `URL`                   | The location of your files. The expected format is `s3://{bucket_name}/{full_file_path_glob_pattern}`. A local path is supported only where local file system access is enabled, and may be an absolute or relative path (relative paths resolve against the engine's working directory), optionally prefixed with `file://`. | `TEXT`                |
| `COMPRESSION`           | The compression type of the input. If unset, it is inferred from the most recent object's extension.                                                                                                                                                                                                                          | `TEXT`                |
| `AWS_ACCESS_KEY_ID`     | The AWS access key ID.                                                                                                                                                                                                                                                                                                        | `TEXT`                |
| `AWS_SECRET_ACCESS_KEY` | The AWS secret access key.                                                                                                                                                                                                                                                                                                    | `TEXT`                |
| `AWS_SESSION_TOKEN`     | The AWS session token.                                                                                                                                                                                                                                                                                                        | `TEXT`                |
| `AWS_ROLE_ARN`          | The AWS role arn.                                                                                                                                                                                                                                                                                                             | `TEXT`                |
| `AWS_ROLE_EXTERNAL_ID`  | The AWS role external ID.                                                                                                                                                                                                                                                                                                     | `TEXT`                |

Parquet, JSON, and Avro read nested objects as `STRUCT`; ORC flattens them into separate columns. CSV and TSV are read with default dialect options (comma or tab delimiter, no header row, types inferred). To control the CSV dialect (header, quote, delimiter, null string), use [`READ_CSV`](/reference-sql/functions-reference/table-valued/read_csv).

## Return Type

A table with the data from the file. Column names and types are inferred the same way the format-specific TVF infers them.

## Examples

Read a single Parquet file, inferring the format from the extension:

```sql theme={"theme":{"light":"css-variables","dark":"css-variables"}}
SELECT * FROM READ_FILES('s3://firebolt-publishing-public/help_center_assets/firebolt_sample_dataset/levels.parquet');
```

The bare-path shorthand reads the same file, and works across deployment modes for public data:

```sql theme={"theme":{"light":"css-variables","dark":"css-variables"}}
SELECT * FROM 's3://firebolt-publishing-public/help_center_assets/firebolt_sample_dataset/levels.parquet';
```

Read all matching files with a glob. The format is inferred from the matched objects, so the pattern itself needs no extension:

```sql theme={"theme":{"light":"css-variables","dark":"css-variables"}}
SELECT * FROM READ_FILES('s3://firebolt-publishing-public/help_center_assets/firebolt_sample_dataset/*');

SELECT * FROM 's3://firebolt-publishing-public/help_center_assets/firebolt_sample_dataset/levels*';
```

Read a gzip-compressed CSV; both the format and the compression are inferred from the object name:

```sql theme={"theme":{"light":"css-variables","dark":"css-variables"}}
SELECT * FROM READ_FILES('s3://my-bucket/exports/report.csv.gz');
```
