Skip to content

Move all analyticscore references behind a AnalyticsCoreUtil class#16258

Merged
kevinjqliu merged 2 commits into
apache:mainfrom
talatuyarer:gcs-analytics-core-dependency
May 12, 2026
Merged

Move all analyticscore references behind a AnalyticsCoreUtil class#16258
kevinjqliu merged 2 commits into
apache:mainfrom
talatuyarer:gcs-analytics-core-dependency

Conversation

@talatuyarer
Copy link
Copy Markdown
Contributor

We dont want to load analytics classes if users does not use analytic feature.

https://lists.apache.org/thread/mv0xhgoqvj2doh74g4wr8pgft3ozj0hz

@github-actions github-actions Bot added the GCP label May 8, 2026
Copy link
Copy Markdown
Contributor

@kevinjqliu kevinjqliu left a comment

Choose a reason for hiding this comment

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

i grepped for import.*analyticscore, looks like theres still an import in gcp/src/main/java/org/apache/iceberg/gcp/gcs/GcsInputStreamWrapper.java
i would expect all the imports for analytics-core isolated in AnalyticsCoreUtil.java

EDIT: ok looks like GcsInputStreamWrapper is only called by AnalyticsCoreUtil. no issues here

Comment thread gcp/src/main/java/org/apache/iceberg/gcp/gcs/BaseGCSFile.java
Comment thread gcp/src/main/java/org/apache/iceberg/gcp/gcs/PrefixedStorage.java Outdated
Comment thread gcp/src/main/java/org/apache/iceberg/gcp/gcs/GCSInputFile.java Outdated
Comment thread gcp/src/main/java/org/apache/iceberg/gcp/gcs/GCSOutputFile.java Outdated
Comment thread gcp/src/main/java/org/apache/iceberg/gcp/gcs/AnalyticsCoreUtil.java
@RussellSpitzer
Copy link
Copy Markdown
Member

i grepped for import.*analyticscore, looks like theres still an import in gcp/src/main/java/org/apache/iceberg/gcp/gcs/GcsInputStreamWrapper.java i would expect all the imports for analytics-core isolated in AnalyticsCoreUtil.java

EDIT: ok looks like GcsInputStreamWrapper is only called by AnalyticsCoreUtil. no issues here

This is actually a good call, you might as well make GcsinputStreamwrapper an inner class of AnalyticsCoreUtil and remove the possibility of another caller accidentally using it.

Copy link
Copy Markdown
Contributor

@kevinjqliu kevinjqliu left a comment

Choose a reason for hiding this comment

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

i tested this locally by adding this to the build.gradle's `iceberg-gcp' entry:

  task testWithoutAnalyticsCore(type: Test) {
    useJUnitPlatform()
    description = 'Runs tests without gcs-analytics-core on the classpath'
    classpath = test.classpath.filter {
      // exclude all JARs from the com.google.cloud.gcs.analytics group (analyticscore classes)
      !it.path.contains('com.google.cloud.gcs.analytics/')
    }
    jvmArgs += project.property('extraJvmArgs')
    include '**/TestGCSFileIO.class'
    include '**/TestGCSInputStream.class'
    include '**/TestGCSOutputStream.class'
    include '**/TestGCSLocation.class'
  }

This filters out the analytics-core library. And everything ran successfully.

Comment thread gcp/src/main/java/org/apache/iceberg/gcp/gcs/PrefixedStorage.java Outdated
Comment thread gcp/src/main/java/org/apache/iceberg/gcp/gcs/PrefixedStorage.java
Comment thread gcp/src/main/java/org/apache/iceberg/gcp/gcs/PrefixedStorage.java
Comment thread gcp/src/main/java/org/apache/iceberg/gcp/gcs/BaseGCSFile.java
@talatuyarer talatuyarer requested a review from RussellSpitzer May 9, 2026 00:00
Copy link
Copy Markdown
Contributor Author

@talatuyarer talatuyarer left a comment

Choose a reason for hiding this comment

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

I believe I have addressed all comments.

Comment thread gcp/src/main/java/org/apache/iceberg/gcp/gcs/PrefixedStorage.java
Comment thread gcp/src/main/java/org/apache/iceberg/gcp/gcs/PrefixedStorage.java
Comment thread gcp/src/main/java/org/apache/iceberg/gcp/gcs/PrefixedStorage.java Outdated
Comment thread gcp/src/main/java/org/apache/iceberg/gcp/gcs/BaseGCSFile.java
Comment thread gcp/src/main/java/org/apache/iceberg/gcp/gcs/AnalyticsCoreUtil.java
Copy link
Copy Markdown
Contributor

@kevinjqliu kevinjqliu left a comment

Choose a reason for hiding this comment

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

LGTM

have a few minor nits

Comment thread gcp/src/main/java/org/apache/iceberg/gcp/gcs/BaseGCSFile.java Outdated
Comment thread gcp/src/main/java/org/apache/iceberg/gcp/gcs/BaseGCSFile.java Outdated
@talatuyarer talatuyarer force-pushed the gcs-analytics-core-dependency branch from d2a613f to 6c6289b Compare May 9, 2026 04:36
@talatuyarer talatuyarer requested a review from kevinjqliu May 9, 2026 04:37
Comment thread gcp/src/test/java/org/apache/iceberg/gcp/gcs/TestGcsInputFile.java

private AnalyticsCoreUtil() {}

static AutoCloseable createFileSystem(Map<String, String> properties, Credentials credentials) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here better to return GcsFileSystem rather than AutoCloseable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Returning GcsFileSystem would expose the analytics-core class in the method descriptor, which is the opposite of what we're trying to achieve (e.g., PrefixedStorage.gcsFileSystem()). Could you clarify if there's another reason for the suggestion? @aihuaxu

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@talatuyarer I think you can return GcsFileSystem here but the caller can still use AutoCloseable, right?

But it's nit.

@talatuyarer talatuyarer requested a review from aihuaxu May 12, 2026 17:56
Copy link
Copy Markdown
Contributor

@aihuaxu aihuaxu left a comment

Choose a reason for hiding this comment

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

LGTM.

@kevinjqliu kevinjqliu added this to the Iceberg 1.11.0 milestone May 12, 2026
Copy link
Copy Markdown
Contributor

@kevinjqliu kevinjqliu left a comment

Choose a reason for hiding this comment

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

LGTM thanks for fixing this

@kevinjqliu kevinjqliu merged commit 42f3d01 into apache:main May 12, 2026
36 checks passed
@kevinjqliu
Copy link
Copy Markdown
Contributor

Thanks for the fix @talatuyarer and everyone for reviewing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants