Skip to main content
A table-valued function (TVF) that reads text files line by line. READ_TEXT returns a table with a single content column of type TEXT NULL, where each row contains one line from the input file. Unlike READ_CSV, READ_TEXT has a fixed output schema and does not parse or split fields — each line is returned as-is. READ_TEXT is useful for ingesting unstructured or semi-structured text data such as log files, where standard CSV parsing would fail due to delimiters or special characters in the content.

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

  • The URL can be passed as either the first positional parameter or a named parameter.
  • If you provide either AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY, you must provide both.
  • Providing an AWS session token is optional.
  • Credentials are not required for accessing public buckets.
  • The URL also accepts the upload:// scheme to read a file sent in the same HTTP request. See Upload and query local files.

Return type

The result is a table with a single column: A special column $source_file_name can be used to identify the source file of each row in the result set.

Examples

Example: Reading a text file The following example reads a text file and returns the first five lines:
Returns Example: Using glob patterns to read multiple files The URL can represent a single file or a glob pattern. If a glob pattern is used, all files matching the pattern are read. Use $source_file_name to identify the source file of each row:
Example: Reading a compressed file
Example: Parsing log files with regular expressions READ_TEXT is well-suited for ingesting log files that would cause errors with READ_CSV due to delimiters or special characters. You can use string functions and regular expressions to extract structured fields from the raw text: