Search in sources :

Example 1 with CommentUpdate

use of org.apache.iceberg.view.CommentUpdate in project nessie by projectnessie.

the class TestNessieIcebergViews method testViewColumnComments.

@Test
public void testViewColumnComments() throws NessieNotFoundException {
    // update comment
    CommentUpdate commentUpdate = new CommentUpdate(catalog.getViewCatalog().newViewOps(VIEW_IDENTIFIER));
    String comment = "The column name is id";
    commentUpdate.updateColumnDoc("id", comment);
    Schema schema = commentUpdate.apply();
    assertThat(schema.findField("id").doc()).isEqualTo(comment);
    comment = comment + " and type is integer";
    commentUpdate.updateColumnDoc("id", comment);
    schema = commentUpdate.apply();
    assertThat(schema.findField("id").doc()).isEqualTo(comment);
    commentUpdate.commit();
    View icebergView = catalog.load(VIEW_IDENTIFIER.toString());
    assertThat(icebergView).isNotNull();
    assertThat(icebergView.currentVersion().versionId()).isEqualTo(2);
    assertThat(icebergView.currentVersion().parentId()).isEqualTo(1);
    assertThat(icebergView.properties()).isEmpty();
    assertThat(Paths.get(metadataLocationViews(VIEW_IDENTIFIER.name()))).exists();
    assertThat(metadataFilesForViews(VIEW_IDENTIFIER.name())).isNotNull().hasSize(2);
    verifyCommitMetadata();
    assertThat(api.getCommitLog().refName(BRANCH).get().getLogEntries()).hasSize(3);
    verifyViewInNessie(VIEW_IDENTIFIER, icebergView);
}
Also used : CommentUpdate(org.apache.iceberg.view.CommentUpdate) Schema(org.apache.iceberg.Schema) View(org.apache.iceberg.view.View) IcebergView(org.projectnessie.model.IcebergView) Test(org.junit.jupiter.api.Test)

Aggregations

Schema (org.apache.iceberg.Schema)1 CommentUpdate (org.apache.iceberg.view.CommentUpdate)1 View (org.apache.iceberg.view.View)1 Test (org.junit.jupiter.api.Test)1 IcebergView (org.projectnessie.model.IcebergView)1