Search in sources :

Example 11 with IcebergView

use of org.projectnessie.model.IcebergView in project nessie by projectnessie.

the class TestNessieIcebergViews method testCreateView.

@Test
public void testCreateView() throws IOException {
    ViewDefinition viewDefinition = ViewDefinition.of(SQL, SCHEMA, CATALOG_NAME, new ArrayList<>());
    TableIdentifier viewIdentifier = ViewUtils.toCatalogTableIdentifier(VIEW_IDENTIFIER + "x");
    catalog.create(viewIdentifier.toString(), viewDefinition, Collections.emptyMap());
    View icebergView = catalog.load(viewIdentifier.toString());
    assertThat(icebergView).isNotNull();
    assertThat(icebergView.currentVersion().versionId()).isEqualTo(1);
    assertThat(icebergView.currentVersion().viewDefinition()).isEqualTo(viewDefinition);
    assertThat(Paths.get(metadataLocationViews(viewIdentifier.name()))).exists();
    assertThat(metadataFilesForViews(viewIdentifier.name())).isNotNull().hasSize(1);
    verifyCommitMetadata();
    assertThat(api.getCommitLog().refName(BRANCH).get().getLogEntries()).hasSize(3);
    verifyViewInNessie(viewIdentifier, icebergView);
}
Also used : TableIdentifier(org.apache.iceberg.catalog.TableIdentifier) ViewDefinition(org.apache.iceberg.view.ViewDefinition) View(org.apache.iceberg.view.View) IcebergView(org.projectnessie.model.IcebergView) Test(org.junit.jupiter.api.Test)

Aggregations

IcebergView (org.projectnessie.model.IcebergView)11 Content (org.projectnessie.model.Content)6 ImmutableIcebergView (org.projectnessie.model.ImmutableIcebergView)5 Test (org.junit.jupiter.api.Test)4 Branch (org.projectnessie.model.Branch)4 ContentKey (org.projectnessie.model.ContentKey)4 IcebergTable (org.projectnessie.model.IcebergTable)4 View (org.apache.iceberg.view.View)3 ImmutableIcebergTable (org.projectnessie.model.ImmutableIcebergTable)3 ByteString (com.google.protobuf.ByteString)2 ArrayList (java.util.ArrayList)2 Schema (org.apache.iceberg.Schema)2 TableIdentifier (org.apache.iceberg.catalog.TableIdentifier)2 CommitFailedException (org.apache.iceberg.exceptions.CommitFailedException)2 CommitStateUnknownException (org.apache.iceberg.exceptions.CommitStateUnknownException)2 ViewDefinition (org.apache.iceberg.view.ViewDefinition)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 CommitMultipleOperationsBuilder (org.projectnessie.client.api.CommitMultipleOperationsBuilder)2 NessieApiV1 (org.projectnessie.client.api.NessieApiV1)2 HttpClientException (org.projectnessie.client.http.HttpClientException)2