badalprasadsingh commented on code in PR #2664:
URL: https://github.com/apache/iceberg-go/pull/2664#discussion_r4644107018


##########
catalog/sql/sql.go:
##########
@@ -202,7 +202,7 @@ func init() {
 
                // Here, name is the loader-supplied catalog name and is 
persisted as the
                // catalog_name partition key on every row in the 
iceberg_tables and iceberg_namespace_properties.
-               cat, err := NewCatalog(ctx, name, sqldb, 
SupportedDialect(dialect), p)
+               cat, err := NewCatalog(ctx, name, sqldb, 
SupportedDialect(dialect), p, WithIORegistry(registry))

Review Comment:
   only the hadoop and rest registrars are tested on this path: the sql, glue, 
hive and dynamodb registrars could drop the registry and every test would still 
pass
   
   can we add a `LoadWithOptions` case for each? for dynamodb: 
TestDynamoDBRegistry could create, commit and load a table



##########
catalog/registry.go:
##########
@@ -89,6 +90,28 @@ func (f RegistrarFunc) GetCatalog(ctx context.Context, 
catalogName string, props
        return f(ctx, catalogName, props)
 }
 
+// IORegistryRegistrarFunc is a catalog factory that accepts a catalog-scoped
+// FileIO registry. A nil registry selects the process-wide FileIO registry.
+type IORegistryRegistrarFunc func(context.Context, string, iceberg.Properties, 
*iceio.Registry) (Catalog, error)
+
+func (f IORegistryRegistrarFunc) GetCatalog(ctx context.Context, name string, 
props iceberg.Properties) (Catalog, error) {
+       return f(ctx, name, props, nil)
+}
+
+type loadOptions struct {
+       ioRegistry *iceio.Registry
+}
+
+// LoadOption configures a catalog created by LoadWithOptions.
+type LoadOption func(*loadOptions)
+
+// WithIORegistry selects the FileIO factories for this catalog and its tables.
+// A nil registry uses the process-wide default. Custom catalogs that accept a
+// scoped registry can register an IORegistryRegistrarFunc.

Review Comment:
   in "configuration.md", we still say: a scoped registry "does not affect 
catalog.Load"
   
   please document the new option there, noting that dynamodb gets it only this 
way. please also say, here and in its "Catalog type registry" section, that 
other factories fail with `iceberg.ErrNotImplemented`



##########
catalog/registry_isolation_test.go:
##########
@@ -26,10 +26,19 @@ import (
 
        "github.com/apache/iceberg-go"
        "github.com/apache/iceberg-go/catalog"
+       iceio "github.com/apache/iceberg-go/io"
        "github.com/stretchr/testify/assert"
        "github.com/stretchr/testify/require"
 )
 
+// Load remains usable as a function value and through a caller-defined 
interface.
+var (
+       _ func(context.Context, string, iceberg.Properties) (catalog.Catalog, 
error) = catalog.Load
+       _ interface {
+               Load(context.Context, string, iceberg.Properties) 
(catalog.Catalog, error)
+       } = (*catalog.Registry)(nil)
+)

Review Comment:
   nit: the api compatibility check already fails any pr that changes Load's 
signature without a ! title -> so these lines repeat it
   
   better: drop them, if Load becomes variadic, they have to go anyway



##########
catalog/registry.go:
##########
@@ -192,10 +216,20 @@ func Load(ctx context.Context, name string, props 
iceberg.Properties) (Catalog,
        return defaultRegistry.Load(ctx, name, props)
 }
 
+// LoadWithOptions resolves a catalog like Load and applies options to its 
factory.
+func LoadWithOptions(ctx context.Context, name string, props 
iceberg.Properties, opts ...LoadOption) (Catalog, error) {
+       return defaultRegistry.LoadWithOptions(ctx, name, props, opts...)
+}

Review Comment:
   #2612 chose a trailing variadic option over a separate `...WithOptions` 
function (ig you can check its note in releases.md), can "Load" and 
"Registry.Load" take `opts ...LoadOption instead` of these two new functions? 
direct calls still compile. 
   
   it needs a ! title and a compatibility note like #2612's.



-- 
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]

Reply via email to