---
title: current_snapshot_version function
description: Learn the syntax of the current\_snapshot\_version function, which returns the snapshot version being processed in an AUTO CDC FROM SNAPSHOT flow.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/current_snapshot_version
---

# `current_snapshot_version` function

Returns the version row selected by the enclosing flow's `WITH VERSION (...)` clause for the snapshot being processed.

This function is available only inside the `FROM SNAPSHOT (...)` clause of an [`AUTO CDC ... FROM SNAPSHOT`](https://docs.databricks.com/aws/en/ldp/developer/ldp-sql-ref-create-flow.md) flow.

## Syntax

```sql
current_snapshot_version()
```

## Arguments

This function takes no arguments.

## Returns

A single-column relation with the same column name and type as the enclosing flow's version query, containing exactly 1 row. The row contains the version selected for the current snapshot-processing iteration.

`current_snapshot_version()` is evaluated only after the version query returns 1 row. If the version query returns 0 rows, the engine does not run the snapshot query, and it ends processing for the flow during that pipeline update.

## Examples

The following flow uses `current_snapshot_version()` to read the file selected by the `WITH VERSION (...)` clause. The version is a single `STRUCT` column, so its fields are accessed with dot notation:

```sql
CREATE FLOW orders_cdc
  AS AUTO CDC INTO orders
  FROM SNAPSHOT (
    SELECT *
    FROM read_files('/Volumes/catalog/schema/landing/orders/', format => 'json')
    WHERE _metadata.file_path = (SELECT version.path FROM current_snapshot_version())
  )
  WITH VERSION (...)
  KEYS (order_id);
```

## Errors

`current_snapshot_version()` is available only inside the `FROM SNAPSHOT (...)` clause of an `AUTO CDC ... FROM SNAPSHOT` flow that declares a `WITH VERSION (...)` clause. Anywhere else, Spark resolves the name as an ordinary table-valued function. Because no such function is defined, it raises `UNRESOLVABLE_TABLE_VALUED_FUNCTION` (`SQLSTATE 42883`).

## Related functions

* [`last_snapshot_version` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/last_snapshot_version.md)
