nastra commented on code in PR #12014: URL: https://github.com/apache/iceberg/pull/12014#discussion_r1942420149
########## core/src/main/java/org/apache/iceberg/ViewVersionTable.java: ########## @@ -0,0 +1,120 @@ +/* + * 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. + */ +package org.apache.iceberg; + +import java.util.stream.Collectors; +import org.apache.iceberg.io.CloseableIterable; +import org.apache.iceberg.types.Types; +import org.apache.iceberg.view.SQLViewRepresentation; +import org.apache.iceberg.view.View; +import org.apache.iceberg.view.ViewVersion; + +public class ViewVersionTable extends BaseViewMetadataTable { + + static final Schema VIEW_VERSION_SCHEMA = + new Schema( + Types.NestedField.required(1, "version-id", Types.IntegerType.get()), + Types.NestedField.required(2, "schema-id", Types.IntegerType.get()), + Types.NestedField.required(3, "timestamp-ms", Types.TimestampType.withoutZone()), + Types.NestedField.required( + 4, + "summary", + Types.MapType.ofRequired(6, 7, Types.StringType.get(), Types.StringType.get())), + Types.NestedField.required( + 8, + "representations", + Types.ListType.ofRequired( + 9, + Types.StructType.of( + Types.NestedField.required(10, "type", Types.StringType.get()), + Types.NestedField.required(11, "sql", Types.StringType.get()), + Types.NestedField.required(12, "dialect", Types.StringType.get())))), + Types.NestedField.optional(13, "default-catalog", Types.StringType.get()), + Types.NestedField.required(14, "default-namespace", Types.StringType.get())); + + ViewVersionTable(View view) { + super(view, view.name() + ".version"); + } + + @Override + public TableScan newScan() { + return new ViewVersionTableScan(this); + } + + @Override + public Schema schema() { + return VIEW_VERSION_SCHEMA; + } + + private DataTask task(BaseTableScan scan) { + return ViewMetadataReadTask.of( + location(), + schema(), + scan.schema(), + operations().current().versions(), + ViewVersionTable::viewVersionToRow); + } + + private class ViewVersionTableScan extends BaseViewMetadataTableScan { + ViewVersionTableScan(Table table) { + super(table, VIEW_VERSION_SCHEMA, ViewMetadataTableType.VERSION); + } + + ViewVersionTableScan(Table table, TableScanContext context) { + super(table, VIEW_VERSION_SCHEMA, ViewMetadataTableType.VERSION, context); + } + + @Override + protected TableScan newRefinedScan(Table table, Schema schema, TableScanContext context) { + return new ViewVersionTableScan(table, context); + } + + @Override + protected CloseableIterable<FileScanTask> doPlanFiles() { + return CloseableIterable.withNoopClose(ViewVersionTable.this.task(this)); + } + + @Override + public CloseableIterable<FileScanTask> planFiles() { + // override planFiles to avoid the check for a current snapshot because this metadata table is Review Comment: I don't think this comment applies for views, so it can be removed -- 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-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org