RussellSpitzer commented on code in PR #16961: URL: https://github.com/apache/iceberg/pull/16961#discussion_r4241439793
########## format/index-spec.md: ########## @@ -0,0 +1,753 @@ +--- +title: "Index Spec" +--- +<!-- + - Licensed to the Apache Software Foundation (ASF) under one or more + - contributor license agreements. See the NOTICE file distributed with + - this work for additional information regarding copyright ownership. + - The ASF licenses this file to You under the Apache License, Version 2.0 + - (the "License"); you may not use this file except in compliance with + - the License. You may obtain a copy of the License at + - + - http://www.apache.org/licenses/LICENSE-2.0 + - + - Unless required by applicable law or agreed to in writing, software + - distributed under the License is distributed on an "AS IS" BASIS, + - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + - See the License for the specific language governing permissions and + - limitations under the License. + --> +# Iceberg Index Specification + +## Background and Motivation + +An index is a secondary store of data from a table that is structured to accelerate specific access patterns. +An index is derived from the rows of a source table and is stored separately from table data, so it can be built, +refreshed, or dropped without rewriting the table. + +An index is most valuable when it is a property of the table rather than of the engine that built it. This +specification defines a common format for index metadata and a common storage architecture for index data, so that any +engine can build an index, maintain it, and use it to plan queries against the table. + +## Goals + +* **Independence** -- An index is committed as a separate object, without modifying its source table. +* **Consistency** -- An index reflects exactly the live rows of a single state of its source table. +* **Read-optimized** -- An index is structured for fast reads, at the cost of extra work when writing. +* **Incrementality** -- An index is refreshed by writing only the index data affected by the table's changes. +* **Scalability** -- An index supports any table size that the table spec supports. +* **Portability** -- An index is readable and maintainable by any engine, not only the one that wrote it. +* **Extensibility** -- An index type or ordering strategy can be added without disrupting existing indexes or + engines that do not implement it. + +## Overview + +Index state is maintained in index metadata files. All changes to index state create a new metadata file and replace +the old metadata with an atomic swap, as defined in [Commits and Concurrency](#commits-and-concurrency). An index +metadata file tracks the index definition, index properties, and extracts of a single index. A table may have +any number of indexes, including multiple indexes of the same type. + +An extract represents the state of an index for one snapshot of its source table and is used to access the +complete set of index data files for that state. The index data of an extract is organized as a +[tracking file](#tracking-file) that lists a set of [region files](#region-files). Index data files are immutable and +may be referenced by more than one extract. + +## Specification + +### Terms + +* **Index** -- A structure that accelerates retrieval of rows from a source table. +* **Extract** -- The state of an index for a single snapshot of the source table. +* **Index entry** -- The values produced by the index fields for one indexed row of the source table. +* **Ordering key** -- The tuple of values that determines the position of an index entry within an extract. +* **Tracking file** -- A file that lists the region files of an extract; one per extract. +* **Region file** -- A file that stores the index entries for a range of ordering keys; a subset of an extract. + +### Locations in Metadata + +Location strings stored in index metadata are classified and resolved as defined by +[paths in metadata](spec.md#paths-in-metadata) in the table specification. Relative locations are resolved against the +index `location`, which must be an absolute location. + +### Index Definition + +An index is defined by a source table, an index type, identity fields, materialized fields, non-materialized fields, and +an ordering key. The definition is fixed when the index is created and must not change for the lifetime of the index, +so region files remain readable through every extract that references them. A different definition requires a +new index. + +Index properties configure how an index is written and maintained, such as the target size of region files. Any commit +may change properties, and readers must not depend on them. + +#### Index Type + +The index type defines the logical category of an index and the class of queries it accelerates. + +| Type | Description | +|----------|------------------------------------------------------------------------------------------------------------------------| +| `scalar` | Accelerates point lookups on ordering key fields, and range filters when the ordering expressions are order preserving | + +This specification defines a single index type, `scalar`. Future specifications may define additional types. + +Writers must write `index-type` in lower case. Readers must match it case-insensitively. + +#### Index Fields + +An index field defines one value of an index entry, produced for an indexed row of the source table. An index declares +three lists of index fields: + +* [Identity fields](#identity-fields) store a source table field in region files as is, so a reader can return the Review Comment: Additional notes: It may be useful to store expressions directly in the schema when we are representing a materialized column. For example something like { schema { fields { 1: {expression } } } We would use this to represent a generated column (one which is written into data files as well as stats vs an expression field which only optionally writes into stats.) TODO figure out how this works with complex types? This would additionally be useful for sort orders which would then just be defined on a field ids as they currently are. Sort Order on Hilbert (A, B, C) looks like { Sort-order - field 35 asc expressions (stats-only fields ) { 35: { HilbertCurve Expression on (a,b,c) } ########## format/index-spec.md: ########## @@ -0,0 +1,753 @@ +--- +title: "Index Spec" +--- +<!-- + - Licensed to the Apache Software Foundation (ASF) under one or more + - contributor license agreements. See the NOTICE file distributed with + - this work for additional information regarding copyright ownership. + - The ASF licenses this file to You under the Apache License, Version 2.0 + - (the "License"); you may not use this file except in compliance with + - the License. You may obtain a copy of the License at + - + - http://www.apache.org/licenses/LICENSE-2.0 + - + - Unless required by applicable law or agreed to in writing, software + - distributed under the License is distributed on an "AS IS" BASIS, + - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + - See the License for the specific language governing permissions and + - limitations under the License. + --> +# Iceberg Index Specification + +## Background and Motivation + +An index is a secondary store of data from a table that is structured to accelerate specific access patterns. +An index is derived from the rows of a source table and is stored separately from table data, so it can be built, +refreshed, or dropped without rewriting the table. + +An index is most valuable when it is a property of the table rather than of the engine that built it. This +specification defines a common format for index metadata and a common storage architecture for index data, so that any +engine can build an index, maintain it, and use it to plan queries against the table. + +## Goals + +* **Independence** -- An index is committed as a separate object, without modifying its source table. +* **Consistency** -- An index reflects exactly the live rows of a single state of its source table. +* **Read-optimized** -- An index is structured for fast reads, at the cost of extra work when writing. +* **Incrementality** -- An index is refreshed by writing only the index data affected by the table's changes. +* **Scalability** -- An index supports any table size that the table spec supports. +* **Portability** -- An index is readable and maintainable by any engine, not only the one that wrote it. +* **Extensibility** -- An index type or ordering strategy can be added without disrupting existing indexes or + engines that do not implement it. + +## Overview + +Index state is maintained in index metadata files. All changes to index state create a new metadata file and replace +the old metadata with an atomic swap, as defined in [Commits and Concurrency](#commits-and-concurrency). An index +metadata file tracks the index definition, index properties, and extracts of a single index. A table may have +any number of indexes, including multiple indexes of the same type. + +An extract represents the state of an index for one snapshot of its source table and is used to access the +complete set of index data files for that state. The index data of an extract is organized as a +[tracking file](#tracking-file) that lists a set of [region files](#region-files). Index data files are immutable and +may be referenced by more than one extract. + +## Specification + +### Terms + +* **Index** -- A structure that accelerates retrieval of rows from a source table. +* **Extract** -- The state of an index for a single snapshot of the source table. +* **Index entry** -- The values produced by the index fields for one indexed row of the source table. +* **Ordering key** -- The tuple of values that determines the position of an index entry within an extract. +* **Tracking file** -- A file that lists the region files of an extract; one per extract. +* **Region file** -- A file that stores the index entries for a range of ordering keys; a subset of an extract. + +### Locations in Metadata + +Location strings stored in index metadata are classified and resolved as defined by +[paths in metadata](spec.md#paths-in-metadata) in the table specification. Relative locations are resolved against the +index `location`, which must be an absolute location. + +### Index Definition + +An index is defined by a source table, an index type, identity fields, materialized fields, non-materialized fields, and +an ordering key. The definition is fixed when the index is created and must not change for the lifetime of the index, +so region files remain readable through every extract that references them. A different definition requires a +new index. + +Index properties configure how an index is written and maintained, such as the target size of region files. Any commit +may change properties, and readers must not depend on them. + +#### Index Type + +The index type defines the logical category of an index and the class of queries it accelerates. + +| Type | Description | +|----------|------------------------------------------------------------------------------------------------------------------------| +| `scalar` | Accelerates point lookups on ordering key fields, and range filters when the ordering expressions are order preserving | + +This specification defines a single index type, `scalar`. Future specifications may define additional types. + +Writers must write `index-type` in lower case. Readers must match it case-insensitively. + +#### Index Fields + +An index field defines one value of an index entry, produced for an indexed row of the source table. An index declares +three lists of index fields: + +* [Identity fields](#identity-fields) store a source table field in region files as is, so a reader can return the Review Comment: @talatuyarer ^ worth thinking about -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
