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

Upgrade Iceberg to 1.8 #1126

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Conversation

liamzwbao
Copy link
Contributor

@liamzwbao liamzwbao commented Mar 6, 2025

Changes

@@ -215,6 +215,10 @@ public void initialize(String name, Map<String, String> properties) {
name,
this.catalogName);

// Ensure catalogProperties is assigned before calling metricsReporter() for proper
// functionality.
catalogProperties = properties;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Curious, why it wasn't failing before?

Copy link
Contributor Author

@liamzwbao liamzwbao Mar 19, 2025

Choose a reason for hiding this comment

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

This case was not covered before and was discovered via a new test added in 1.8, original PR

@liamzwbao liamzwbao requested a review from ebyhr March 10, 2025 23:37
@liamzwbao liamzwbao force-pushed the upgrade-iceberg branch 3 times, most recently from 6597414 to 49fa57b Compare March 14, 2025 00:31
@flyrain
Copy link
Contributor

flyrain commented Mar 18, 2025

cc @gh-yzou

@@ -215,6 +215,10 @@ public void initialize(String name, Map<String, String> properties) {
name,
this.catalogName);

// Ensure catalogProperties is assigned before calling metricsReporter() for proper
// functionality.
catalogProperties = properties;
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious, why it wasn't failing before?

@liamzwbao liamzwbao force-pushed the upgrade-iceberg branch 2 times, most recently from 0425f53 to 4314016 Compare March 19, 2025 01:46
file ->
tryDelete(
tableId, fileIO, manifestFile.path(), file.path().toString(), null, 1))
.map(file -> tryDelete(tableId, fileIO, manifestFile.path(), file.location(), null, 1))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

file.path() is deprecated in 1.8 and replaced by file.location(). See link

@liamzwbao liamzwbao force-pushed the upgrade-iceberg branch 2 times, most recently from 7d0073d to 2c436f6 Compare March 19, 2025 23:33
@@ -65,6 +66,10 @@ public abstract class PolarisRestCatalogViewIntegrationBase extends ViewCatalogT

@BeforeAll
static void setup(PolarisApiEndpoints apiEndpoints, ClientCredentials credentials) {
// Set preferredAssumptionException as Quarkus does not suppress JUnit4's
// AssumptionViolatedException
org.assertj.core.api.Assumptions.setPreferredAssumptionException(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be done via a global ServiceLoader-based class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your advice! Done by using QuarkusTestBeforeClassCallback

public Path createTempDirectory(
AnnotatedElementContext elementContext, ExtensionContext extensionContext)
throws Exception {
Path basePath = Paths.get(BASE_LOCATION.replaceFirst("file://", ""));
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to customize tmp locations?

I'm -1 on this particular diff fragment. It look overly complicated and obscure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fixes the test createViewWithCustomMetadataLocation.

One possible solution is to add the customMetadataLocation to allowedLocations when the user specifies it like #193. However, since this feels more like a bug fix, it might be out of scope for this PR.

How about we override and temporarily skip the test for now, and leave a TODO to fix it in a followup PR? What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

@liamzwbao would you mind give some more details about why the test was failing? was it because the customMetadataLocation configured with .withProperty(ViewProperties.WRITE_METADATA_LOCATION, customLocation) is not in the allowed location, and Polaris fails during validation? and you are changing the temp dir here to be under the allowed location?

If it is designed that the provided custom metadata location must be one under allowed location, then adding customMetadataLocation to allowedLocations doesn't sounds the right fix me, and we probably should fix the test. I see we can overwrite the test, one way is to overwrite the test with correct configuration, and provide comments there about why are we overwriting the test.

Copy link
Contributor Author

@liamzwbao liamzwbao Mar 23, 2025

Choose a reason for hiding this comment

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

was it because the customMetadataLocation configured with .withProperty(ViewProperties.WRITE_METADATA_LOCATION, customLocation) is not in the allowed location, and Polaris fails during validation? and you are changing the temp dir here to be under the allowed location?

Yes.

I've tried overriding the test and adding custom config, but since tempDir is a private field in the superclass, I can't access it to include it in the storage config when recreating the catalog using managementApi.createCatalog. The workaround is to hardcode a path like file:///var/folders/6k as tempDir is always generated under this path, but it isn't ideal. I have no control over the tempDir generation unless I rewrite the factory.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I meant completely overwrite the test to use a valid customLocation and location for it. The test seems using

 String location = Paths.get(tempDir.toUri().toString()).toString();
 String customLocation = Paths.get(tempDir.toUri().toString(), "custom-location").toString();

If BASE_LOCATION is a valid location, then we override the while test as following

 TableIdentifier identifier = TableIdentifier.of("ns", "view");

    if (requiresNamespaceCreate()) {
      catalog().createNamespace(identifier.namespace());
    }

    assertThat(catalog().viewExists(identifier)).as("View should not exist").isFalse();

    String location = BASE_LOCATION;
    String customLocation = BASE_LOCATION/custom-location

    View view =
        catalog()
            .buildView(identifier)
            .withSchema(SCHEMA)
            .withDefaultNamespace(identifier.namespace())
            .withDefaultCatalog(catalog().name())
            .withQuery("spark", "select * from ns.tbl")
            .withProperty(ViewProperties.WRITE_METADATA_LOCATION, customLocation)
            .withLocation(location)
            .create();

    assertThat(view).isNotNull();
    assertThat(catalog().viewExists(identifier)).as("View should exist").isTrue();
    assertThat(view.properties()).containsEntry("write.metadata.path", customLocation);
    assertThat(((BaseView) view).operations().current().metadataFileLocation())
        .isNotNull()
        .startsWith(customLocation);

In that case, you shouldn't need tempDir anymore. one quick question, is that the only test that is failing?

@liamzwbao liamzwbao force-pushed the upgrade-iceberg branch 2 times, most recently from 4224337 to d5aaaf3 Compare March 21, 2025 18:52
private static class CustomTempDirFactory implements TempDirFactory {
@Override
public Path createTempDirectory(
AnnotatedElementContext elementContext, ExtensionContext extensionContext)
Copy link
Contributor

Choose a reason for hiding this comment

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

is that temp dir creation for the same reason as above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants