Skip to content

[Server] Consolidate Iceberg FileIO behind FileOperations - #1687

Merged
yili-db merged 2 commits into
unitycatalog:mainfrom
yili-db:stack/fileiofactory
Aug 5, 2026
Merged

yili-db merged 2 commits into
unitycatalog:mainfrom
yili-db:stack/fileiofactory

Conversation

@yili-db

@yili-db yili-db commented Jul 20, 2026 •

Copy link
Copy Markdown
Collaborator

🥞 Stacked PR

Use this link to review incremental changes.


PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes
Fold FileIOFactory into FileOperations as the single entry point for storage access, including credential-vended ResolvingFileIO for cloud paths and an expanded SimpleLocalFileIO for local paths.

  • Move SimpleLocalFileIO from service/iceberg to persist/utils
  • Wire MetadataService and TableConfigService through FileOperations
  • Create FileOperations at server startup with StorageCredentialVendor
  • Remove FileOperations from Repositories and unused repository fields

@yili-db
yili-db requested review from openinx and tdas as code owners July 20, 2026 02:22
@yili-db
yili-db force-pushed the stack/fileiofactory branch from fb080f2 to 2dfdd12 Compare July 20, 2026 07:46
@yili-db
yili-db requested a review from timothyw553 July 23, 2026 00:42
return CompletableFuture.supplyAsync(() -> TableMetadataParser.read(fileIO, metadataLocation))
.join();
FileIO fileIO = fileOperations.getFileIO(metadataLocation);
return TableMetadataParser.read(fileIO, metadataLocation.toString());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I saw below getFileIO builds a ResolvingFileIO. here, should we be closing it by calling fileIO.close()?
or maybe something like

  try (FileIO fileIO = fileOperations.getFileIO(metadataLocation)) {
    return TableMetadataParser.read(fileIO, metadataLocation.toString());
  }

Comment on lines +100 to +104
case S3, GS, ABFS, ABFSS -> {
ResolvingFileIO fileio = new ResolvingFileIO();
fileio.initialize(getFileIOConfig(path));
yield fileio;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this needs tests

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

something that lets FileOperations.getFileIO("s3://…") build a real ResolvingFileIO and read through it against the S3Mock

Comment on lines +163 to +168
String s3Region = s3BucketRegionMap.get(path.getStorageBase());
return Map.of(
S3FileIOProperties.ACCESS_KEY_ID, awsCredentials.getAccessKeyId(),
S3FileIOProperties.SECRET_ACCESS_KEY, awsCredentials.getSecretAccessKey(),
S3FileIOProperties.SESSION_TOKEN, awsCredentials.getSessionToken(),
AwsClientProperties.CLIENT_REGION, s3Region);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

When you call the .get(key) method on a Java Map and the key is not found, the method returns null. It does not throw an exception.

in this case s3Region may be null, right? should we add a guard before this map

Comment on lines +126 to +127
TemporaryCredentials cred =
storageCredentialVendor.vendCredential(path, Set.of(CredentialContext.Privilege.SELECT));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

recently I've discovered that there may be instances where deployments may actually just rely on ambient credentials for reading un-vended GCP tables. so I wonder, will that behaviour persist here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes ambient credentials on server can also be used for vending a temp table cred. This is where it is picked up for S3:

        // Otherwise just defer to DefaultCredentialsProvider
        credentialsProvider = DefaultCredentialsProvider.create();

return getS3Config(path, cred.getAwsTempCredentials());
} else {
// Cloud vend returned no recognized credential type; nothing to configure.
return Map.of();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is it better to throw directly here with a clear message?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I guess even if it's impossible, better to throw I think (up to you)

}
Stream<Path> walk;
try {
walk = Files.walk(dirPath);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Files.walk(dirPath, FileVisitOption.FOLLOW_LINKS) to follow symlinks like in server/src/main/java/io/unitycatalog/server/persist/utils/FileOperations.java

@yili-db yili-db Jul 23, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It's intentionally removed. FOLLOW_LINKS is dangerous.

@timothyw553 timothyw553 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Some comments.

@yili-db
yili-db requested a review from timothyw553 July 23, 2026 07:32

@timothyw553 timothyw553 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Generally looks good to me


private final ServerProperties serverProperties;
private final StorageCredentialVendor storageCredentialVendor;
private final Map<NormalizedURL, String> s3BucketRegionMap;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I understand it's the correct direction to unify all cloud storage access in a abstracted FileOperations, but seems like we are implementing all the cloud storage operations inside this FileOperations class ? ultimately I assume we will need an abstraction to fully decouple those cloud storage access into several fully isolated classes, so that one cloud won't perceive and access any other cloud resource.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The core part of this file is the getFileIO, getFileIOConfig and get*Config functions which directly generates cloud specific FileIO objects. s3BucketRegionMap happens to be part of this process.

Other than that, all the other functions will be cloud agnostic. The abstraction is already handled by getFileIOConfig. Different cloud implementation of actual file IO is implemented by ResolvingFileIO (and its delegation).

case FILE, NULL -> SimpleLocalFileIO.deleteDirectory(url.toString());
// Currently we can NOT delete the path in cloud storage. We will update this in future
// when UC OSS begins using the hadoopfs libraries.
case S3 -> {}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Shouldn't we throw rather than silent return ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

If it throws, deleting a managed entity on cloud would simply fail. This is incomplete and pre-existing.

* Returns an Iceberg {@link FileIO} for reading the given location. Local paths use {@link
* SimpleLocalFileIO}; cloud paths use a credential-vended {@link ResolvingFileIO}.
*/
// TODO: Cache fileIOs

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

That's really important, otherwise, every access will exhaustively consume all the resources by creating massive fileIO instance.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes. But not in this PR yet.

case FILE, NULL -> new SimpleLocalFileIO();
case S3, GS, ABFS, ABFSS -> {
ResolvingFileIO fileio = new ResolvingFileIO();
fileio.initialize(getFileIOConfig(path));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Actually, you can use HadoopFileIO directly to get a FileIO https://github.com/apache/iceberg/blob/main/core/src/main/java/org/apache/iceberg/hadoop/HadoopFileIO.java. that will automatically address your fileIO cache problem, since the FileSystem will have the cache by default.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The downsides of using Hadoop FS (hadoop-client-runtime) is heavy dependency. It's a shaded uber-jar of an entire ecosystem that weighs ~30 MB, ~18,000 classes adding to the server runtime.
For now I don't see a good reason to adopt that yet.

return Map.of();
}

// FIXME!! privileges are defaulted to READ only here for now as Iceberg REST impl doesn't

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If iceberg rest impl does not support vending write cred, then the IRC cannot support write for now right ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

IRC write support is not implemented yet.

@openinx openinx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I skimmed this PR again, and I'm looking forward to seeing few answers from the questions:

  1. Seems like we are agreed to reuse the existing iceberg FileIO as the fundermental storage abstraction. then will we consider to use the abstracted approach to initialize the concrete FileIO instance ? as I like to see we fully isolate those cloud vender into separate and isolated classes, rather than mixing them together, which may distract us.

  2. As long term we will require the server side cloud credential renewal and caching work, without the 1st abstraction and isolation, it may not clearly solve and support server-side credential renwal and caching.

@yili-db

yili-db commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator Author

I skimmed this PR again, and I'm looking forward to seeing few answers from the questions:

  1. Seems like we are agreed to reuse the existing iceberg FileIO as the fundermental storage abstraction. then will we consider to use the abstracted approach to initialize the concrete FileIO instance ? as I like to see we fully isolate those cloud vender into separate and isolated classes, rather than mixing them together, which may distract us.
  2. As long term we will require the server side cloud credential renewal and caching work, without the 1st abstraction and isolation, it may not clearly solve and support server-side credential renwal and caching.

Thanks for the second pass @openinx. Answers to the two questions:

1. Isolating the concrete FileIO per cloud. The concrete per-cloud FileIO objects are already isolated — getFileIO returns Iceberg's ResolvingFileIO, which dispatches by scheme to S3FileIO / GCSFileIO / ADLSFileIO. No cloud accesses another cloud's resources at the FileIO level.

What's centralized in FileOperations today is only the config assembly (getS3Config / getGCSConfig / getADLSConfig) that turns vended credentials into the property map used to initialize each FileIO. They're already separate methods, and I agree they could be extracted into per-cloud classes (e.g. a scheme-keyed config provider with one impl per cloud). I'd prefer to do that as a follow-up — this PR is intentionally a focused consolidation: folding FileIOFactory into FileOperations and removing the config logic that was previously duplicated across both FileIOFactory and TableConfigService.

2. Server-side credential renewal + caching. Agreed, and neither is implemented in this PR (see the // TODO: Cache fileIOs). The relevant point is that all vending now goes through the single getFileIOConfig entry point, which is where caching (keyed by storage base, expiry-aware) and renewal naturally belong. The per-cloud config isolation from Q1 pairs with that work, so I'd like to tackle them together in the follow-up.

@yili-db
yili-db requested a review from openinx July 28, 2026 23:46
yili-db added 2 commits July 28, 2026 17:28
Fold FileIOFactory into FileOperations as the single entry point for storage access, including credential-vended ResolvingFileIO for cloud paths and an expanded SimpleLocalFileIO for local paths.
- Move SimpleLocalFileIO from service/iceberg to persist/utils
- Wire MetadataService and TableConfigService through FileOperations
- Create FileOperations at server startup with StorageCredentialVendor
- Remove FileOperations from Repositories and unused repository fields

Signed-off-by: Yi Li <[email protected]>
Signed-off-by: Yi Li <[email protected]>
@yili-db
yili-db force-pushed the stack/fileiofactory branch from 6460fc7 to 3268eee Compare July 29, 2026 00:30
@yili-db
yili-db merged commit db04af9 into unitycatalog:main Aug 5, 2026
16 checks passed
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.

3 participants