Skip to content
Open
Changes from 20 commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
8c5d276
add materialzied view to view spec
JanKaul Aug 21, 2024
afc4a0d
add uuid to source table
JanKaul Aug 29, 2024
b2d0b68
Aktualisieren von view-spec.md
JanKaul Sep 5, 2024
27783c7
improve refresh-state description
JanKaul Sep 7, 2024
e85ab16
remove identifier from refresh-state
JanKaul Sep 19, 2024
cff9596
fix comments
JanKaul Oct 4, 2024
a8b52b2
incorporate comments
JanKaul Nov 21, 2024
521477f
fix MV introduction
JanKaul Nov 25, 2024
ed85e95
Update format/view-spec.md
JanKaul Dec 4, 2024
3bc583c
fix comments
JanKaul Dec 4, 2024
49d5da8
fix spelling
JanKaul Dec 10, 2024
d18c9da
fix view-version-id in refresh-state
JanKaul Dec 15, 2024
eb7d71b
Update format/view-spec.md
JanKaul Jan 10, 2025
8ffff63
Update format/view-spec.md
JanKaul Jan 10, 2025
6b065f5
fix introduction wording
JanKaul Jan 10, 2025
0e17881
rename full identifier to table identifier
JanKaul Feb 12, 2025
7e9dc11
fix comments
JanKaul Feb 18, 2025
efed628
Update format/view-spec.md
JanKaul May 13, 2025
0673113
Update format/view-spec.md
JanKaul May 13, 2025
476aced
Update format/view-spec.md
JanKaul May 13, 2025
d0a81b5
Merge branch 'apache:main' into materialized-view-spec
JanKaul Jul 6, 2025
f09e71d
clarify storage "fresh", "stale" and "invalid"
JanKaul Jul 6, 2025
eadc40a
clarify that refresh-state is set on every storage table snapshot
JanKaul Jul 6, 2025
59f4197
Add reference to from table to MV spec
Jul 6, 2025
7d11caa
Remove optional catalog field from storage table identifier
Jul 6, 2025
b5ae8e4
fix typo
Jul 6, 2025
53d3695
Update format/view-spec.md
stevenzwu Jul 28, 2025
18bb08d
Update format/view-spec.md
JanKaul Aug 20, 2025
4e97b98
fix refresh metadata
JanKaul Aug 20, 2025
e193d39
fix comment
JanKaul Aug 20, 2025
fc98d50
fix duplication
JanKaul Aug 21, 2025
7a35784
fix view-version-id
JanKaul Oct 22, 2025
a02f94b
update refresh-state
JanKaul Oct 22, 2025
c5c5ddc
fix comments
JanKaul Oct 29, 2025
8489919
add max-staleness
JanKaul Nov 26, 2025
6645ab6
fix lint errors
JanKaul Nov 26, 2025
751152a
Add the case for max-staleness being null
JanKaul Nov 26, 2025
701537b
remove last line
JanKaul Nov 26, 2025
5f47e8c
Fix max-staleness description
JanKaul Dec 4, 2025
9156f5f
Add storage table to Source table description
JanKaul Dec 4, 2025
4a2096d
oncorporate comments
JanKaul Dec 6, 2025
965498f
fix other inconsistencies
JanKaul Dec 6, 2025
a6ecfca
update matview spec
JanKaul Dec 17, 2025
47438f5
incorporate comments
JanKaul Dec 18, 2025
fcc76eb
clarify coarse-grained freshness evaluation
JanKaul Dec 18, 2025
4aa25cb
clarify freshness
JanKaul Dec 18, 2025
7861cdf
remove trust point
JanKaul Dec 18, 2025
4d5ceb7
fix spelling
JanKaul Dec 18, 2025
ca9742b
add materialized view to source state description
JanKaul Dec 18, 2025
0314bc7
incorporate comments
JanKaul Dec 18, 2025
72ff725
remove max-staleness
JanKaul Feb 9, 2026
9fce2bf
simplify formulation
JanKaul Feb 9, 2026
12731da
include storage table configuration
JanKaul Feb 9, 2026
ec1c778
fix
JanKaul Feb 9, 2026
8b05299
improve freshness
JanKaul Feb 10, 2026
439c223
fix
JanKaul Feb 10, 2026
490f66f
fixes
JanKaul Feb 11, 2026
abdfed2
mv creation process
JanKaul Feb 25, 2026
d6d0586
add example
JanKaul Feb 25, 2026
55fe6fe
remove nested
JanKaul Feb 25, 2026
2634d1a
fix
JanKaul Mar 4, 2026
c184329
fix new lines
JanKaul Mar 4, 2026
fb8d268
fix empty list
JanKaul Mar 4, 2026
e3d94f2
improve json formating
JanKaul Mar 11, 2026
adc6c16
Update format/view-spec.md
JanKaul Mar 31, 2026
8d0a6fe
Update format/view-spec.md
JanKaul Mar 31, 2026
8aaef30
Update format/view-spec.md
JanKaul Mar 31, 2026
cf83efa
fix language
JanKaul Mar 31, 2026
6c48f2d
fix optional refresh-state
JanKaul Mar 31, 2026
4e3cdac
fix freshness
JanKaul Mar 31, 2026
f81648d
update diamond pattern
JanKaul Mar 31, 2026
1638f87
add non-deterministic functions
JanKaul Apr 30, 2026
5322088
Materialized view spec: universal freshness, recursive dependencies
wmoustafa Jun 2, 2026
89c6094
update dependency definition
JanKaul May 27, 2026
0679460
fixes
JanKaul May 27, 2026
ccd9a92
update refresh-state
JanKaul May 27, 2026
ea664cb
Update format/view-spec.md
JanKaul May 28, 2026
f9226cd
Update format/view-spec.md
JanKaul May 28, 2026
f0e652a
fixes
JanKaul May 28, 2026
e98226d
add wmoustafas appendix
JanKaul May 28, 2026
00fb392
fix appendix
JanKaul Jun 1, 2026
7094416
fix source table definition
JanKaul Jun 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions format/view-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,28 @@ An atomic swap of one view metadata file for another provides the basis for maki

Writers create view metadata files optimistically, assuming that the current metadata location will not be changed before the writer's commit. Once a writer has created an update, it commits by swapping the view's metadata file pointer from the base location to the new location.

### Materialized Views

Materialized views are a type of view with precomputed results from the view query stored as a table.
When queried, engines may return the precomputed data for the materialized views, shifting the cost of query execution to the precomputation step.

Iceberg materialized views are implemented as a combination of an Iceberg view and an underlying Iceberg table, the "storage-table", which stores the precomputed data.
Materialized View metadata is a superset of View metadata with an additional pointer to the storage table and refresh metadata.
Comment thread
JanKaul marked this conversation as resolved.
Outdated
Refresh metadata contains information about the "source tables", tables referenced in the query definition of the materialized view.
Comment thread
JanKaul marked this conversation as resolved.
Outdated
The storage table can be in the states of "fresh", "stale" or "invalid", which are determined from the following situations:
Comment thread
stevenzwu marked this conversation as resolved.
Outdated
* **fresh** -- The `snapshot_id`s of the last refresh operation match the current `snapshot_id`s of the source tables.
* **stale** -- The `snapshot_id`s do not match, indicating that a refresh operation needs to be performed to capture the latest source table changes.
Comment thread
JanKaul marked this conversation as resolved.
Outdated
* **invalid** -- The current `version_id` of the materialized view does not match the `refresh-version-id` of the refresh state.
Comment thread
stevenzwu marked this conversation as resolved.
Outdated
Comment thread
JanKaul marked this conversation as resolved.
Outdated

## Specification

### Terms

* **Schema** -- Names and types of fields in a view.
* **Version** -- The state of a view at some point in time.
* **Storage table** -- Iceberg table that stores the precomputed data of the materialized view.
* **Source table** -- A table reference that occurs in the query definition of the materialized view. The materialized view depends on the data from the source tables.
Comment thread
JanKaul marked this conversation as resolved.
Outdated
* **Source view** -- A view reference that occurs in the query definition of the materialized view. The materialized view depends on the definitions from the source views.
Comment thread
stevenzwu marked this conversation as resolved.
Outdated

### View Metadata

Expand Down Expand Up @@ -82,9 +98,12 @@ Each version in `versions` is a struct with the following fields:
| _required_ | `representations` | A list of [representations](#representations) for the view definition |
| _optional_ | `default-catalog` | Catalog name to use when a reference in the SELECT does not contain a catalog |
| _required_ | `default-namespace` | Namespace to use when a reference in the SELECT is a single identifier |
| _optional_ | `storage-table` | A [storage table identifier](#storage-table-identifier) of the storage table |
Comment thread
JanKaul marked this conversation as resolved.

Comment thread
stevenzwu marked this conversation as resolved.
When `default-catalog` is `null` or not set, the catalog in which the view is stored must be used as the default catalog.

When 'storage-table' is `null` or not set, the entity is a common view, otherwise it is a materialized view.

Comment thread
JanKaul marked this conversation as resolved.
#### Summary

Summary is a string to string map of metadata about a view version. Common metadata keys are documented here.
Expand Down Expand Up @@ -160,6 +179,57 @@ Each entry in `version-log` is a struct with the following fields:
| _required_ | `timestamp-ms` | Timestamp when the view's `current-version-id` was updated (ms from epoch) |
| _required_ | `version-id` | ID that `current-version-id` was set to |

#### Storage Table Identifier

The table identifier for the storage table that stores the precomputed results.

| Requirement | Field name | Description |
Comment thread
JanKaul marked this conversation as resolved.
|-------------|----------------|-------------|
| _optional_ | `catalog` | A string specifying the name of the catalog. If set to `null`, the catalog is the same as the view's catalog |
Comment thread
stevenzwu marked this conversation as resolved.
Outdated
| _required_ | `namespace` | A list of strings for namespace levels |
| _required_ | `name` | A string specifying the name of the table/view |
Comment thread
stevenzwu marked this conversation as resolved.
Outdated
Comment thread
JanKaul marked this conversation as resolved.
Outdated

Comment thread
JanKaul marked this conversation as resolved.
### Storage table metadata
Comment thread
stevenzwu marked this conversation as resolved.

This section describes additional metadata for the storage table that supplements the regular table metadata and is required for materialzied views.
Comment thread
JanKaul marked this conversation as resolved.
Outdated
The property "refresh-state" is set on the table [snapshot summary](https://iceberg.apache.org/spec/#snapshots) to determine the freshness of the precomputed data of the storage table.
Comment thread
stevenzwu marked this conversation as resolved.
Outdated

| Requirement | Field name | Description |
|-------------|-----------------|-------------|
| _required_ | `refresh-state` | A [refresh state](#refresh-state) record stored as a JSON-encoded string |

#### Refresh state

The refresh state record captures the state of all source tables and source views in the fully expanded query tree of the materialized view, including indirect references. Indirect references are the tables/views that are not directly referenced in the query but are nested within other views. The refresh state has the following fields:
Comment thread
stevenzwu marked this conversation as resolved.
Outdated

| Requirement | Field name | Description |
|-------------|----------------|-------------|
| _required_ | `view-version-id` | The `version-id` of the materialized view when the refresh operation was performed |
| _required_ | `source-table-states` | A list of [source table](#source-table) records for all tables that are directly or indirectly referenced in the materialized view query |
| _required_ | `source-view-states` | A list of [source view](#source-view) records for all views that are directly or indirectly referenced in the materialized view query |
Comment thread
stevenzwu marked this conversation as resolved.
Outdated
| _required_ | `refresh-start-timestamp-ms` | A timestamp of when the refresh operation was started |

#### Source table

A source table record captures the state of a source table at the time of the last refresh operation.
Comment thread
stevenzwu marked this conversation as resolved.
Outdated

| Requirement | Field name | Description |
Comment thread
stevenzwu marked this conversation as resolved.
Outdated
|-------------|----------------|-------------|
| _required_ | `uuid` | The uuid of the source table |
| _required_ | `snapshot-id` | Snapshot-id of when the last refresh operation was performed |
| _optional_ | `ref` | Branch name of the source table being referenced in the view query |
Comment thread
stevenzwu marked this conversation as resolved.
Outdated

When `ref` is `null` or not set, it defaults to "main".

#### Source view

A source view record captures the state of a source view at the time of the last refresh operation.

| Requirement | Field name | Description |
|-------------|----------------|-------------|
| _required_ | `uuid` | The uuid of the source view |
| _required_ | `version-id` | Version-id of when the last refresh operation was performed |

## Appendix A: An Example

The JSON metadata file format is described using an example below.
Expand Down