Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hive: Add View support for HIVE catalog #9852

Merged
merged 17 commits into from
Sep 13, 2024
Merged

Conversation

nk1506
Copy link
Contributor

@nk1506 nk1506 commented Mar 2, 2024

This changes include:

  1. Introduction of common metadata interface(BaseMetadata) for table and view.
  2. Refactor for HiveTableOperation to have common code for table and view commits.

Ref: #9682 , #9461 , #8907

Copy link
Collaborator

@szehon-ho szehon-ho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for combining the earlier prs. It's clearer now.

Some preliminary comments.

@nastra please take a look as well to see if there are any major concerns.

.palantir/revapi.yml Outdated Show resolved Hide resolved
.palantir/revapi.yml Outdated Show resolved Hide resolved

HiveViewOperations spyOps = spy(ops);

failCommitAndThrowException(spyOps);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think it's missing calling commit here where it should be expecting the exception that is being set up in failCommitAndThrowException.

Can you please update the test to

@Test
  public void testThriftExceptionUnknownStateIfNotInHistoryFailureOnCommit()
      throws TException, InterruptedException {
    HiveViewOperations ops = (HiveViewOperations) ((BaseView) view).operations();
    ViewMetadata metadataV1 = ops.current();
    assertThat(metadataV1.properties()).hasSize(0);

    view.updateProperties().set("k1", "v1").commit();
    ops.refresh();
    ViewMetadata metadataV2 = ops.current();
    assertThat(metadataV2.properties()).hasSize(1).containsEntry("k1", "v1");

    HiveViewOperations spyOps = spy(ops);

    failCommitAndThrowException(spyOps);

    assertThatThrownBy(() -> spyOps.commit(metadataV2, metadataV1))
            .isInstanceOf(CommitStateUnknownException.class)
            .hasMessageStartingWith("Datacenter on fire");

    ops.refresh();

    assertThat(ops.current()).as("Current metadata should not have changed").isEqualTo(metadataV2);
    assertThat(metadataFileExists(metadataV2)).as("Current metadata should still exist").isTrue();
    assertThat(metadataFileCount(ops.current()))
        .as(
            "New metadata files should still exist, new location not in history but"
                + " the commit may still succeed")
        .isEqualTo(2);
  }


/** Pretends we throw an error while persisting that actually does commit serverside. */
@Test
public void testThriftExceptionSuccessOnCommit() throws TException, InterruptedException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please update this one to

@Test
  public void testThriftExceptionSuccessOnCommit() throws TException, InterruptedException {
    HiveViewOperations ops = (HiveViewOperations) ((BaseView) view).operations();

    ViewMetadata metadataV1 = ops.current();
    assertThat(metadataV1.properties()).hasSize(0);

    view.updateProperties().set("k1", "v1").commit();
    ops.refresh();
    ViewMetadata metadataV2 = ops.current();
    assertThat(metadataV2.properties()).hasSize(1).containsEntry("k1", "v1");

    HiveViewOperations spyOps = spy(ops);

    // Simulate a communication error after a successful commit
    commitAndThrowException(ops, spyOps);
    // Shouldn't throw because the commit succeeds even though an exception is thrown
    spyOps.commit(metadataV2, metadataV1);

    assertThat(ops.current()).as("Current metadata should have not changed").isEqualTo(metadataV2);
    assertThat(metadataFileExists(ops.current()))
        .as("Current metadata file should still exist")
        .isTrue();
  }

@nk1506
Copy link
Contributor Author

nk1506 commented Sep 13, 2024

Build is failing because of flaky issue #11046

Copy link
Contributor

@nastra nastra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will wait a bit with merging in case @danielcweeks has some additional comments

@nastra nastra closed this Sep 13, 2024
@nastra nastra reopened this Sep 13, 2024
@nastra
Copy link
Contributor

nastra commented Sep 13, 2024

thanks @nk1506 for your patience here. Also thanks for everyone that helped out with reviews

@nastra nastra merged commit e449d34 into apache:main Sep 13, 2024
91 of 94 checks passed
@nk1506
Copy link
Contributor Author

nk1506 commented Sep 13, 2024

Thanks @nastra and @danielcweeks for your reviews and feedback.

@nqvuong1998
Copy link

Hi @nastra @danielcweeks , Is this pull request scheduled for inclusion in the v1.7 release?

@nastra
Copy link
Contributor

nastra commented Sep 17, 2024

@nqvuong1998 yes that will be shipped with 1.7.0

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants