---
title: FILE functions quickstart
description: Overview of the FILE type and its functions for working with unstructured files in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/gcp/en/sql/language-manual/sql-ref-file-functions-quickstart
---

# FILE functions quickstart

> [!NOTE]
> **Beta**
>
> This feature is in [Beta](https://docs.databricks.com/gcp/en/release-notes/release-types.md).

The `FILE` type represents unstructured files such as documents, images, and audio. Built-in SQL functions create, copy, and read files as `FILE` references.

This page summarizes these functions with reference examples for common operations, such as:

* Listing files in a Unity Catalog volume as `FILE` references with [`list_files`](https://docs.databricks.com/gcp/en/sql/language-manual/functions/list_files.md).
* Reading file metadata, such as `size` and `checksum` (used to identify the file version).
* Filtering files by their metadata.
* Parsing document content with [`ai_parse_document`](https://docs.databricks.com/gcp/en/sql/language-manual/functions/ai_parse_document.md).

For the type reference, see [`FILE` type](https://docs.databricks.com/gcp/en/sql/language-manual/data-types/file-type.md).

For a conceptual overview, see [FILE type and unstructured data](https://docs.databricks.com/gcp/en/unstructured/file.md).

## Requirements

* These examples use the `samples.sec.contracts` dataset, a collection of SEC-filed contract PDFs available in all workspaces by default. To use your own files, point the path at a Unity Catalog volume that contains them.

## Examples

### List files and capture references

To list the files at a path and save the `FILE` references in a table, use [`list_files` table-valued function](https://docs.databricks.com/gcp/en/sql/language-manual/functions/list_files.md):

```sql
CREATE TABLE documents AS
  SELECT path, size, modification_time, file
  FROM list_files('/Volumes/samples/sec/contracts/');
```

### Read file metadata

To read the `uri`, `size`, `content_type`, and `checksum` fields of a `FILE` value, use dot notation:

```sql
SELECT file.uri, file.size, file.content_type, file.checksum
  FROM documents;
```

### Filter files by metadata

To filter rows using file metadata, such as path and size:

```sql
SELECT file.uri
  FROM documents
  WHERE file.uri ILIKE '%.pdf'
    AND file.size > 100000;
```

### Parse document content

To extract structured content from a document, pass a `FILE` value to [`ai_parse_document` function](https://docs.databricks.com/gcp/en/sql/language-manual/functions/ai_parse_document.md):

```sql
SELECT file.uri, ai_parse_document(file) AS parsed
  FROM documents
  WHERE file.uri ILIKE '%.pdf';
```

## Example notebook

The following notebook runs all of the preceding examples against the `samples.sec.contracts` dataset:

#### FILE functions quickstart notebook

[Get notebook](https://docs.databricks.com/notebooks/source/file-functions-quickstart.html)

## Next steps

* [`FILE` type](https://docs.databricks.com/gcp/en/sql/language-manual/data-types/file-type.md)
* [Ingest files as the FILE type](https://docs.databricks.com/gcp/en/ingestion/file.md)
* [Tutorial: Build a file-processing pipeline with the FILE type](https://docs.databricks.com/gcp/en/ldp/tutorial-file-pipelines.md)
