Skip to content

[FLINK-39115][s3] Support URI Handling Utility - #29127

Open
Samrat002 wants to merge 1 commit into
apache:masterfrom
Samrat002:FLINK-39115
Open

[FLINK-39115][s3] Support URI Handling Utility#29127
Samrat002 wants to merge 1 commit into
apache:masterfrom
Samrat002:FLINK-39115

Conversation

@Samrat002

Copy link
Copy Markdown
Contributor

What is the purpose of the change

Add S3URIUtils and remove duplicated helpers.

Brief change log

Introduce S3URIUtils.

Verifying this change

  1. Exisiting UT and IT on Seaweedfs
  2. Running WordCount job with s3 as statebacked for snapshot ,
  3. Write output to s3 using flink job

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (yes / no) no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (yes / no) no
  • The serializers: (yes / no / don't know) no
  • The runtime per-record code paths (performance sensitive): (yes / no / don't know) no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / no / don't know) no
  • The S3 file system connector: (yes / no / don't know) yes

Documentation

  • Does this pull request introduce a new feature? (yes / no) no
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: [Tool Name and Version]

@flinkbot

flinkbot commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@Samrat002

Copy link
Copy Markdown
Contributor Author

@flinkbot run azure

@spuru9 spuru9 left a comment

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.

LGTM. One optional nit.

}

public static String extractKey(String s3Uri) {
String uri = s3Uri.replaceFirst(S3A, S3);

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.

nit: now that extractKey(Path) and extractKey(String) live side by side in the same class, they still use two completely different parsing strategies (one via Path/URI, the other via manual indexOf/substring). Was consolidating them into one implementation considered, or is keeping them separate intentional?

*/
public static String extractBucket(String s3Uri) {
String uri = s3Uri.replaceFirst(S3A, S3);
int bucketStart = uri.indexOf("://") + 3;

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.

This can be -1 but not checked


public static String extractKey(String s3Uri) {
String uri = s3Uri.replaceFirst(S3A, S3);
int bucketStart = uri.indexOf("://") + 3;

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.

This can be -1 but not checked

Comment on lines -92 to -96
*
* <p><b>S3 URI Handling:</b> The {@link #extractKey(Path)} and {@link #extractBucketName(Path)}
* methods expect URIs in the standard {@code s3://bucket/key} format. Other formats like path-style
* ({@code https://s3.amazonaws.com/bucket/key}) or virtual-hosted-style ({@code
* https://bucket.s3.amazonaws.com/key}) are not currently supported.

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.

Now we're dropping the format expectation and we don't have any enforcement in code too. Maybe we should add and blow up early.

}

@Test
void testIsSupportedLocalSchemeAcceptsNoScheme() {

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.

!nit, this test could be folded in parametrised below

}

@ParameterizedTest
@CsvSource({"file:///tmp/foo", "hdfs://bucket/key", "gs://bucket/key"})

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.

Should we also have no schema option test?

@ParameterizedTest
@CsvSource({
"s3://bucket",
"s3://bucket/",

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.

what would happen for s3://bucket//?

@Izeren Izeren left a comment

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.

Thank you @Samrat002, LGTM assuming that CI is green and feedback about indexof checks is addressed

@github-actions github-actions Bot added the community-reviewed-LGTM Applied if there are 2 non-committer approves on a PR. (The submitter cannot approve their own PR.) label Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-reviewed-LGTM Applied if there are 2 non-committer approves on a PR. (The submitter cannot approve their own PR.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants