findinpath commented on code in PR #15752:
URL: https://github.com/apache/iceberg/pull/15752#discussion_r3288574387
##########
core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java:
##########
@@ -1175,7 +1176,15 @@ private FileIO newFileIO(SessionContext context,
Map<String, String> properties)
private FileIO newFileIO(
SessionContext context, Map<String, String> properties, List<Credential>
storageCredentials) {
if (null != ioBuilder) {
- return ioBuilder.apply(context, properties);
+ FileIO fileIO = ioBuilder.apply(context, properties);
+ if (!storageCredentials.isEmpty()
+ && fileIO instanceof SupportsStorageCredentials ioWithCredentials) {
+ ioWithCredentials.setCredentials(
+ storageCredentials.stream()
+ .map(c -> StorageCredential.create(c.prefix(), c.config()))
+ .collect(Collectors.toList()));
+ }
+ return fileIO;
Review Comment:
This approach is not right :(
With the statement
```
ioBuilder.apply(context, properties);
```
we already create a file system factory in Trino (and also wrap it into a
ForwardingFileIo).
https://github.com/trinodb/trino/blob/ae8daa0a0a07d43c6c36ce8085f7bbe7dd599d03/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/rest/TrinoIcebergRestCatalogFactory.java#L117-L122
Ideally we would need to give the `storageCredentials` at the same time as
the properties to the `ioBuilder`
e.g.
```
ioBuilder.apply(context, properties, storageCredentials);
```
(side note, there is no `TriFunction` in JDK and we'll likely need to
introduce an interface if we agree on making such a change)
cc @nastra @kaveti
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]