You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2021/12/08 07:15:47 UTC

[GitHub] [iceberg] jzhuge commented on a change in pull request #3188: Add common view format spec

jzhuge commented on a change in pull request #3188:
URL: https://github.com/apache/iceberg/pull/3188#discussion_r764601325



##########
File path: site/docs/view-spec.md
##########
@@ -0,0 +1,254 @@
+<!--
+ - 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.
+ -->
+ 
+# View Support in Iceberg
+
+## Background and Motivation
+
+Most compute engines (e.g. Trino and Apache Spark ) support logical views, commonly known as ‘views’. A view is a logical table that can be referenced by future queries. Views do not contain any data. Instead, the query stored by the view is executed every time the view is referenced by another query. Views and tables occupy the same namespace.
+Each compute engine stores the metadata of the view in its proprietary format in the metastore of choice. Thus, views created from one engine can not be read or altered easily from another engine even when engines share the metastore as well as the storage system. This document standardizes the view metadata for ease of sharing the views across engines.
+
+## Goals
+
+* A common metadata format for view metadata, similar to how Iceberg supports a common table format for tables.
+* The view metadata format specification
+  * includes storage format as well as APIs to write/read the metadata.
+  * supports versioning of views to track how a view evolved over time.
+
+## Overview
+
+### Storage Format
+
+The view metadata storage and retrieval mirrors how Iceberg table metadata is stored and retrieved. The view metadata is stored in a JSON file on S3 for ease of tracking the evolution of the view. Metastore continues to hold the view object with some properties such as database name, owner, create time, last access time and an indication that the object is a view. 
+
+Each ‘CREATE OR REPLACE VIEW’ statement creates a new view version metadata file for that view. The view version metadata file has following fields:
+
+
+| Required/Optional | Field Name | Description |
+|-------------------|------------|-------------|
+| Required | format-version | Json format version number for the view metadata spec. The view metadata spec and the corresponding format-version is independent of table spec. Starts with 1 and is incremented when there is a breaking change to view metadata. |
+| Required | object-type    | String identifying the type of object this metadata file is for. ‘View’ for all objects covered in this spec. |
+| Required | location | Location of the view metadata files |
+| Required | current-version-id | Current / latest version of the view. Set to ‘1’ when the view is first created. |
+| Optional | properties | A string to string map of view properties. Contains pre-set properties such as ‘comment’ describing the view, does not contain arbitrary metadata. |
+| Required | versions | An array of structs describing the last few versions of the view. Controlled by the table property: “version.history.num_entries”. See more below. |
+| Required | version-log | An array of structs describing the log of created versions. See more below. |
+| Optional | schemas | A list of schemas and alias-comment maps stored as objects with schema-id. See more below |
+| Optional | current-schema-id | ID of the current schema of the view |
+
+
+‘schemas’ is an array of structs with a field as shown below:

Review comment:
       Some catalogs may decide to analyze the schema when using the view thus there is no need to store the schema when creating the view.




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org