rdblue commented on code in PR #7913: URL: https://github.com/apache/iceberg/pull/7913#discussion_r1342187882
########## core/src/main/java/org/apache/iceberg/rest/CatalogHandlers.java: ########## @@ -374,4 +385,107 @@ static TableMetadata commit(TableOperations ops, UpdateTableRequest request) { return ops.current(); } + + public static BaseView baseView(View view) { + Preconditions.checkArgument(view instanceof BaseView, "View must be a BaseView"); + return (BaseView) view; + } + + public static ListTablesResponse listViews(ViewCatalog catalog, Namespace namespace) { + return ListTablesResponse.builder().addAll(catalog.listViews(namespace)).build(); + } + + public static LoadViewResponse createView( + ViewCatalog catalog, Namespace namespace, CreateViewRequest request) { + request.validate(); + + ViewMetadata viewMetadata = request.metadata(); + ViewBuilder viewBuilder = + catalog + .buildView(TableIdentifier.of(namespace, request.name())) + .withSchema(viewMetadata.schema()) + .withProperties(viewMetadata.properties()) + .withDefaultNamespace(viewMetadata.currentVersion().defaultNamespace()) + .withDefaultCatalog(viewMetadata.currentVersion().defaultCatalog()); + viewMetadata.currentVersion().representations().stream() + .filter(r -> r instanceof SQLViewRepresentation) + .map(r -> (SQLViewRepresentation) r) + .forEach(r -> viewBuilder.withQuery(r.dialect(), r.sql())); Review Comment: This is another problem. If there are representations that are not supported, this should reject them, not silently ignore them. -- 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