-
Notifications
You must be signed in to change notification settings - Fork 3k
Materialized View Spec #11041
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Materialized View Spec #11041
Changes from 17 commits
8c5d276
afc4a0d
b2d0b68
27783c7
e85ab16
cff9596
a8b52b2
521477f
ed85e95
3bc583c
49d5da8
d18c9da
eb7d71b
8ffff63
6b065f5
0e17881
7e9dc11
efed628
0673113
476aced
a02ff98
9a377e0
3fec943
413ceb4
295035e
25adf5b
ae0b005
95740e0
9b492c9
878b66b
fe2dec7
a2ca4b2
6dffbee
ec2ac6a
48c1553
d154f8d
25d70dd
e07b7ef
9cc611f
e2041f8
b83f1fd
40d1fb7
72f2725
a6bc657
6378991
9e06580
bd0f6c3
8131d61
0fd8dc3
f543a34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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, known as the storage table, which stores the precomputed data. | ||||||
| The metadata for a materialized view extends the Iceberg view metadata, adding a pointer to the precomputed data and refresh information to determine if the data is still fresh. | ||||||
JanKaul marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| The refresh information is composed of data about the so-called "source tables", which are the tables referenced in the query definition of the materialized view. | ||||||
JanKaul marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| The storage table can be in the states of "fresh", "stale" or "invalid", which are determined from the following situations: | ||||||
stevenzwu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| * **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. | ||||||
|
||||||
| * **invalid** -- The current `version_id` of the materialized view does not match the `refresh-version-id` of the refresh state. | ||||||
stevenzwu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
JanKaul marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| ## 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. | ||||||
JanKaul marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| * **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. | ||||||
stevenzwu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| ### View Metadata | ||||||
|
|
||||||
|
|
@@ -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 | | ||||||
|
|
||||||
stevenzwu marked this conversation as resolved.
Show resolved
Hide 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. | ||||||
|
|
||||||
JanKaul marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| #### Summary | ||||||
|
|
||||||
| Summary is a string to string map of metadata about a view version. Common metadata keys are documented here. | ||||||
|
|
@@ -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 | | ||||||
JanKaul marked this conversation as resolved.
Show resolved
Hide 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 | | ||||||
stevenzwu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| | _required_ | `namespace` | A list of strings for namespace levels | | ||||||
| | _required_ | `name` | A string specifying the name of the table/view | | ||||||
stevenzwu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| | _required_ | `name` | A string specifying the name of the table/view | | |
| | _required_ | `name` | A string specifying the name of the table | |
Uh oh!
There was an error while loading. Please reload this page.