diff --git a/api/src/main/java/org/apache/iceberg/catalog/SessionCatalog.java b/api/src/main/java/org/apache/iceberg/catalog/SessionCatalog.java index fe29f8918531..dce40b1af7f8 100644 --- a/api/src/main/java/org/apache/iceberg/catalog/SessionCatalog.java +++ b/api/src/main/java/org/apache/iceberg/catalog/SessionCatalog.java @@ -196,6 +196,20 @@ default boolean tableExists(SessionContext context, TableIdentifier ident) { */ Table loadTable(SessionContext context, TableIdentifier ident); + /** + * Load a table with the referenced-by view chain. + * + * @param context session context + * @param ident a table identifier + * @param referencedBy ordered list of view identifiers from outermost to innermost + * @return instance of {@link Table} implementation referred by {@code ident} + * @throws NoSuchTableException if the table does not exist + */ + default Table loadTable( + SessionContext context, TableIdentifier ident, List referencedBy) { + throw new UnsupportedOperationException("Loading a table with referenced-by is not supported"); + } + /** * Drop a table, without requesting that files are immediately deleted. * diff --git a/api/src/main/java/org/apache/iceberg/catalog/SupportsReferencedBy.java b/api/src/main/java/org/apache/iceberg/catalog/SupportsReferencedBy.java new file mode 100644 index 000000000000..8756be96d30c --- /dev/null +++ b/api/src/main/java/org/apache/iceberg/catalog/SupportsReferencedBy.java @@ -0,0 +1,45 @@ +/* + * 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.catalog; + +import java.util.List; +import org.apache.iceberg.Table; +import org.apache.iceberg.view.View; + +/** Catalog methods for loading tables and views with a referenced-by view chain. */ +public interface SupportsReferencedBy { + + /** + * Load a table with the referenced-by view chain. + * + * @param identifier a table identifier + * @param referencedBy ordered list of view identifiers from outermost to innermost + * @return an iceberg table + */ + Table loadTable(TableIdentifier identifier, List referencedBy); + + /** + * Load a view with the referenced-by view chain. + * + * @param identifier a view identifier + * @param referencedBy ordered list of view identifiers from outermost to innermost + * @return an iceberg view + */ + View loadView(TableIdentifier identifier, List referencedBy); +} diff --git a/api/src/main/java/org/apache/iceberg/catalog/ViewSessionCatalog.java b/api/src/main/java/org/apache/iceberg/catalog/ViewSessionCatalog.java index 0e195665f3c2..031c51d1461a 100644 --- a/api/src/main/java/org/apache/iceberg/catalog/ViewSessionCatalog.java +++ b/api/src/main/java/org/apache/iceberg/catalog/ViewSessionCatalog.java @@ -54,6 +54,22 @@ public interface ViewSessionCatalog { */ View loadView(SessionCatalog.SessionContext context, TableIdentifier identifier); + /** + * Load a view with the referenced-by view chain. + * + * @param context session context + * @param identifier a view identifier + * @param referencedBy ordered list of view identifiers from outermost to innermost + * @return instance of {@link View} implementation referred by the identifier + * @throws NoSuchViewException if the view does not exist + */ + default View loadView( + SessionCatalog.SessionContext context, + TableIdentifier identifier, + List referencedBy) { + throw new UnsupportedOperationException("Loading a view with referenced-by is not supported"); + } + /** * Check whether view exists. *