This is an automated email from the ASF dual-hosted git repository.

zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-go.git


The following commit(s) were added to refs/heads/main by this push:
     new 127fbc5  feat(catalog): Make CreateTableOpt public to ease creation of 
custom Catalog Impls (#380)
127fbc5 is described below

commit 127fbc5438ff94df1e295e84fb02410fc1faf9bb
Author: Arnaud Briche <briche.arn...@gmail.com>
AuthorDate: Mon Apr 7 17:12:31 2025 +0200

    feat(catalog): Make CreateTableOpt public to ease creation of custom 
Catalog Impls (#380)
    
    Implement the little change discussed here:
    https://github.com/apache/iceberg-go/issues/377
    
    ---------
    
    Co-authored-by: Matt Topol <zotthewiz...@gmail.com>
---
 catalog/catalog.go        | 19 +++++++++++++------
 catalog/glue/glue.go      |  3 +--
 catalog/internal/utils.go |  7 -------
 catalog/rest/rest.go      |  3 +--
 catalog/sql/sql.go        |  2 +-
 5 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/catalog/catalog.go b/catalog/catalog.go
index 6b2118f..6c4a809 100644
--- a/catalog/catalog.go
+++ b/catalog/catalog.go
@@ -36,7 +36,6 @@ import (
        "strings"
 
        "github.com/apache/iceberg-go"
-       "github.com/apache/iceberg-go/catalog/internal"
        iceinternal "github.com/apache/iceberg-go/internal"
        "github.com/apache/iceberg-go/table"
 )
@@ -68,6 +67,14 @@ type PropertiesUpdateSummary struct {
        Missing []string `json:"missing"`
 }
 
+// CreateTableCfg represents the configuration used for CreateTable operations
+type CreateTableCfg struct {
+       Location      string
+       PartitionSpec *iceberg.PartitionSpec
+       SortOrder     table.SortOrder
+       Properties    iceberg.Properties
+}
+
 // Catalog for iceberg table operations like create, drop, load, list and 
others.
 type Catalog interface {
        // CatalogType returns the type of the catalog.
@@ -128,28 +135,28 @@ func NamespaceFromIdent(ident table.Identifier) 
table.Identifier {
        return ident[:len(ident)-1]
 }
 
-type CreateTableOpt func(*internal.CreateTableCfg)
+type CreateTableOpt func(*CreateTableCfg)
 
 func WithLocation(location string) CreateTableOpt {
-       return func(cfg *internal.CreateTableCfg) {
+       return func(cfg *CreateTableCfg) {
                cfg.Location = strings.TrimRight(location, "/")
        }
 }
 
 func WithPartitionSpec(spec *iceberg.PartitionSpec) CreateTableOpt {
-       return func(cfg *internal.CreateTableCfg) {
+       return func(cfg *CreateTableCfg) {
                cfg.PartitionSpec = spec
        }
 }
 
 func WithSortOrder(order table.SortOrder) CreateTableOpt {
-       return func(cfg *internal.CreateTableCfg) {
+       return func(cfg *CreateTableCfg) {
                cfg.SortOrder = order
        }
 }
 
 func WithProperties(props iceberg.Properties) CreateTableOpt {
-       return func(cfg *internal.CreateTableCfg) {
+       return func(cfg *CreateTableCfg) {
                cfg.Properties = props
        }
 }
diff --git a/catalog/glue/glue.go b/catalog/glue/glue.go
index 8e2bc13..1313a1c 100644
--- a/catalog/glue/glue.go
+++ b/catalog/glue/glue.go
@@ -27,7 +27,6 @@ import (
 
        "github.com/apache/iceberg-go"
        "github.com/apache/iceberg-go/catalog"
-       "github.com/apache/iceberg-go/catalog/internal"
        "github.com/apache/iceberg-go/io"
        "github.com/apache/iceberg-go/table"
        "github.com/apache/iceberg-go/utils"
@@ -236,7 +235,7 @@ func (c *Catalog) CreateTable(ctx context.Context, 
identifier table.Identifier,
        if err != nil {
                return nil, err
        }
-       var cfg internal.CreateTableCfg
+       var cfg catalog.CreateTableCfg
        for _, opt := range opts {
                opt(&cfg)
        }
diff --git a/catalog/internal/utils.go b/catalog/internal/utils.go
index 8ae00a2..204f7ea 100644
--- a/catalog/internal/utils.go
+++ b/catalog/internal/utils.go
@@ -32,13 +32,6 @@ import (
        "github.com/google/uuid"
 )
 
-type CreateTableCfg struct {
-       Location      string
-       PartitionSpec *iceberg.PartitionSpec
-       SortOrder     table.SortOrder
-       Properties    iceberg.Properties
-}
-
 func GetMetadataLoc(location string, newVersion uint) string {
        return fmt.Sprintf("%s/metadata/%05d-%s.metadata.json",
                location, newVersion, uuid.New().String())
diff --git a/catalog/rest/rest.go b/catalog/rest/rest.go
index 133ae4c..ac86428 100644
--- a/catalog/rest/rest.go
+++ b/catalog/rest/rest.go
@@ -37,7 +37,6 @@ import (
 
        "github.com/apache/iceberg-go"
        "github.com/apache/iceberg-go/catalog"
-       "github.com/apache/iceberg-go/catalog/internal"
        iceio "github.com/apache/iceberg-go/io"
        "github.com/apache/iceberg-go/table"
        "github.com/aws/aws-sdk-go-v2/aws"
@@ -735,7 +734,7 @@ func (r *Catalog) CreateTable(ctx context.Context, 
identifier table.Identifier,
                return nil, err
        }
 
-       var cfg internal.CreateTableCfg
+       var cfg catalog.CreateTableCfg
        for _, o := range opts {
                o(&cfg)
        }
diff --git a/catalog/sql/sql.go b/catalog/sql/sql.go
index 34593c0..20afc3a 100644
--- a/catalog/sql/sql.go
+++ b/catalog/sql/sql.go
@@ -292,7 +292,7 @@ func checkValidNamespace(ident table.Identifier) error {
 }
 
 func (c *Catalog) CreateTable(ctx context.Context, ident table.Identifier, sc 
*iceberg.Schema, opts ...catalog.CreateTableOpt) (*table.Table, error) {
-       var cfg internal.CreateTableCfg
+       var cfg catalog.CreateTableCfg
        for _, opt := range opts {
                opt(&cfg)
        }

Reply via email to