Core: Allow customizing FileIO in REST catalog#7064
Conversation
|
@electrum can you take a look and see if this would meet your needs? |
|
I tested this out and it works for us. The simple integration where we ignore config is good enough to have everything go through icebergCatalogInstance.setFileIOBuilder(config -> new ForwardingFileIo(fileSystemFactory.create(identity)));We can extend this to capture the config for overriding S3 credentials, signer, etc. |
|
We'll need the same thing for |
nastra
left a comment
There was a problem hiding this comment.
LGTM once checkstyle/spotless is happy
| String ioImpl = properties.get(CatalogProperties.FILE_IO_IMPL); | ||
| return | ||
| CatalogUtil.loadFileIO( | ||
| ioImpl != null ? ioImpl : ResolvingFileIO.class.getName(), properties, conf); |
There was a problem hiding this comment.
nit: maybe worth inlining this, so that we don't need the null check on ioImpl:
CatalogUtil.loadFileIO(
properties.getOrDefault(CatalogProperties.FILE_IO_IMPL, ResolvingFileIO.class.getName()),
properties,
conf);
There was a problem hiding this comment.
I updated this to be more like the JDBC catalog, where we use getOrDefault on the line above to clean it up.
32ad140 to
5c388c9
Compare
5c388c9 to
33ad0be
Compare
| } | ||
| } | ||
|
|
||
| public void setFileIOBuilder(Function<Map<String, String>, FileIO> ioBuilder) { |
There was a problem hiding this comment.
I looked into adding this to BaseMetastoreCatalog but it didn't make sense. That class is not Configurable and creating an IO requires a Configuration when the subclasses implement it. As a result, this class would need to override both this method and a newFileIO method so it isn't worth it.
There was a problem hiding this comment.
Seeing as how we're duplicating this API across some catalogs, should we pull the set/create into an interface?
There was a problem hiding this comment.
I'd like to see whether we need this more broadly first. It's a pretty narrow use case at the moment.
core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java
Outdated
Show resolved
Hide resolved
danielcweeks
left a comment
There was a problem hiding this comment.
+1 (pending checks)
This adds
setFileIOBuilder(Function<Map<String, String>, FileIO)to theRESTSessionCatalog. This allows another way to customize theFileIOinstances used by the REST catalog. For example, Trino has customFileIOimplementations that manage resources differently thanS3FileIO.The function accepts a string map of config properties, which allows passing context from the catalog and table level for the IO, including
tokenfor remote S3 signing as well as thes3.*properties for access to S3.