Skip to main content
A table-valued function (TVF) that reads CSV files from Amazon S3. The function can use either a location object (recommended) or direct credentials to access the data. READ_CSV returns a table with data from the specified CSV file, where each cell is read as TEXT.

Syntax

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.
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.

Parameters

Return Type

The result is a table with the data from the CSV file. Each cell is read as a TEXT.
When loading multiple files, Firebolt infers the schema from the most recently modified file. The remaining files must have compatible data types. If types vary between files (e.g., a column contains integers in one file but doubles in another, or is numeric in one file but text in another), the inferred schema may not match all files and thus cause data type errors or query failures. In such cases, we recommend defining an explicit schema using either external tables or COPY FROM into existing tables.

Examples

Using LOCATION object

Best practice Firebolt recommends using a LOCATION object to store credentials for authentication. When using READ_CSV(), the URL parameter in the location should contain only CSV files (see location table-valued functions). The following code example reads a CSV file from the location specified by my_csv_location, treating the first row as a header containing column names:
Example: Using location object with pattern This example shows how to use the PATTERN parameter with a location object to filter specific files:
Returns This reads only the CSV files matching the pattern levels* within the location’s base path, showing specific columns and the source file for verification.

Using static credentials

The url can represent a single file or a glob pattern. If a glob pattern is used, all files matching the pattern will be read. A special column $source_file_name can be used to identify the source file of each row in the result set:
When using glob patterns, the wildcard (*) can only be used at the end of the path. You can use it with any text before or after, such as *.csv, date=2025*.csv, or data_*.csv. The pattern will recursively match files in all subdirectories. For example:
will read all CSV files in the bucket, including those in subdirectories like help_center_assets/firebolt_sample_dataset/*.csv. Example In the following example, the URL is set as the first positional parameter and reads a CSV file:
Returns: Example The following example accepts URL as a named parameter and reads a CSV file with column names in the first row:
Returns Example The following example reads a CSV with headers and reads empty values as empty strings, rather than NULL values:
Returns: Example The following example accepts URL as a named parameter, reads a CSV file with column names in the first row, and infers types for all columns. In this example it allows filtering using numeric comparisons, since the MaxPoints and MinPointsToPass columns are properly typed as numbers rather than strings:
Returns