@@ -136,11 +136,21 @@ func (t *commitTableResponse) UnmarshalJSON(b []byte) (err error) {
136136 return err
137137}
138138
139+ type storageCredential struct {
140+ Prefix string `json:"prefix"`
141+ Config iceberg.Properties `json:"config"`
142+ }
143+
139144type loadTableResponse struct {
140- MetadataLoc string `json:"metadata-location"`
141- RawMetadata json.RawMessage `json:"metadata"`
142- Config iceberg.Properties `json:"config"`
143- Metadata table.Metadata `json:"-"`
145+ MetadataLoc string `json:"metadata-location"`
146+ RawMetadata json.RawMessage `json:"metadata"`
147+ Config iceberg.Properties `json:"config"`
148+ StorageCredentials []storageCredential `json:"storage-credentials"`
149+ Metadata table.Metadata `json:"-"`
150+ }
151+
152+ type loadCredentialsResponse struct {
153+ StorageCredentials []storageCredential `json:"storage-credentials"`
144154}
145155
146156func (t * loadTableResponse ) UnmarshalJSON (b []byte ) (err error ) {
@@ -677,11 +687,13 @@ func checkValidNamespace(ident table.Identifier) error {
677687
678688func (r * Catalog ) tableFromResponse (_ context.Context , identifier []string , metadata table.Metadata , loc string , config iceberg.Properties ) (* table.Table , error ) {
679689 refresher := & vendedCredentialRefresher {
680- mu : semaphore .NewWeighted (1 ),
681- identifier : identifier ,
682- location : loc ,
683- props : config ,
684- fetchConfig : r .fetchTableConfig ,
690+ mu : semaphore .NewWeighted (1 ),
691+ identifier : identifier ,
692+ location : loc ,
693+ props : config ,
694+ fetchCreds : func (ctx context.Context , ident []string ) (iceberg.Properties , error ) {
695+ return r .fetchTableCreds (ctx , ident , loc )
696+ },
685697 }
686698
687699 return table .New (
@@ -693,25 +705,19 @@ func (r *Catalog) tableFromResponse(_ context.Context, identifier []string, meta
693705 ), nil
694706}
695707
696- func (r * Catalog ) fetchTableConfig (ctx context.Context , ident []string ) (iceberg.Properties , error ) {
708+ func (r * Catalog ) fetchTableCreds (ctx context.Context , ident []string , location string ) (iceberg.Properties , error ) {
697709 ns , tbl , err := splitIdentForPath (ident )
698710 if err != nil {
699711 return nil , err
700712 }
701713
702- ret , err := doGet [loadTableResponse ](ctx , r .baseURI , []string {"namespaces" , ns , "tables" , tbl },
714+ ret , err := doGet [loadCredentialsResponse ](ctx , r .baseURI , []string {"namespaces" , ns , "tables" , tbl , "credentials" },
703715 r .cl , map [int ]error {http .StatusNotFound : catalog .ErrNoSuchTable })
704716 if err != nil {
705717 return nil , err
706718 }
707719
708- config := maps .Clone (r .props )
709- maps .Copy (config , ret .Metadata .Properties ())
710- for k , v := range ret .Config {
711- config [k ] = v
712- }
713-
714- return config , nil
720+ return resolveStorageCredentials (ret .StorageCredentials , location ), nil
715721}
716722
717723func (r * Catalog ) ListTables (ctx context.Context , namespace table.Identifier ) iter.Seq2 [table.Identifier , error ] {
@@ -825,6 +831,7 @@ func (r *Catalog) CreateTable(ctx context.Context, identifier table.Identifier,
825831 config := maps .Clone (r .props )
826832 maps .Copy (config , ret .Metadata .Properties ())
827833 maps .Copy (config , ret .Config )
834+ maps .Copy (config , resolveStorageCredentials (ret .StorageCredentials , ret .MetadataLoc ))
828835
829836 return r .tableFromResponse (ctx , identifier , ret .Metadata , ret .MetadataLoc , config )
830837}
@@ -936,6 +943,7 @@ func (r *Catalog) RegisterTable(ctx context.Context, identifier table.Identifier
936943 config := maps .Clone (r .props )
937944 maps .Copy (config , ret .Metadata .Properties ())
938945 maps .Copy (config , ret .Config )
946+ maps .Copy (config , resolveStorageCredentials (ret .StorageCredentials , ret .MetadataLoc ))
939947
940948 return r .tableFromResponse (ctx , identifier , ret .Metadata , ret .MetadataLoc , config )
941949}
@@ -954,9 +962,8 @@ func (r *Catalog) LoadTable(ctx context.Context, identifier table.Identifier) (*
954962
955963 config := maps .Clone (r .props )
956964 maps .Copy (config , ret .Metadata .Properties ())
957- for k , v := range ret .Config {
958- config [k ] = v
959- }
965+ maps .Copy (config , ret .Config )
966+ maps .Copy (config , resolveStorageCredentials (ret .StorageCredentials , ret .MetadataLoc ))
960967
961968 return r .tableFromResponse (ctx , identifier , ret .Metadata , ret .MetadataLoc , config )
962969}
0 commit comments