Skip to content

file ​

Reads a regular file under the server's configured user_files_path and exposes its decoded rows in FROM. It is a server-side source; the native client's FROM INFILE instead reads files on the client machine.

Syntax ​

text
file('path', format_name, 'column Type, ...')
file('path', form)
file('path', parquet_metadata)

Arguments ​

  • path — A relative path below user_files_path.
  • format_name — A registered input format, using its snake_case name.
  • column Type, ... — The explicit schema used to decode the rows.

All input formats require a schema except form, which infers String fields, and parquet_metadata, which supplies a fixed footer schema. Formats used here must support input.

Path rules ​

Absolute paths, parent traversal, symlinks escaping the configured root and nonregular files are rejected. A symlink that resolves to a confined regular file is permitted. Confined server file access currently requires Unix.

Compression, archives, path patterns and writing files are not supported. These rules are separate from client-side INFILE options.

Example ​

Reading a CSV file ​

Create people.csv under the configured user_files_path with these contents:

text
1,Ada
2,Grace

The schema converts the first field to UInt64 and the second to String:

sql
SELECT id, name
FROM file('people.csv', csv, 'id UInt64, name String')
ORDER BY id
FORMAT csv;
text
1,"Ada"
2,"Grace"

The resulting source can be filtered, joined or used in INSERT ... SELECT like other table sources. See the file loading guide and format reference.