Skip to content

Commit

Permalink
Use awscfg from catalog creation when loading data from glue
Browse files Browse the repository at this point in the history
  • Loading branch information
curtisr7 committed Feb 3, 2025
1 parent 97a9566 commit ea242f3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
3 changes: 3 additions & 0 deletions catalog/glue/glue.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ type glueAPI interface {
type Catalog struct {
glueSvc glueAPI
catalogId *string
awsCfg *aws.Config
}

// NewCatalog creates a new instance of glue.Catalog with the given options.
Expand All @@ -146,6 +147,7 @@ func NewCatalog(opts ...Option) *Catalog {
return &Catalog{
glueSvc: glue.NewFromConfig(glueOps.awsConfig),
catalogId: catalogId,
awsCfg: &glueOps.awsConfig,
}
}

Expand Down Expand Up @@ -204,6 +206,7 @@ func (c *Catalog) LoadTable(ctx context.Context, identifier table.Identifier, pr
return nil, fmt.Errorf("missing metadata location for table %s.%s", database, tableName)
}

ctx = context.WithValue(ctx, io.AwsCfgCtxKey, c.awsCfg)

Check failure on line 209 in catalog/glue/glue.go

View workflow job for this annotation

GitHub Actions / ubuntu-latest go1.23

should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)

Check failure on line 209 in catalog/glue/glue.go

View workflow job for this annotation

GitHub Actions / windows-latest go1.23

should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)

Check failure on line 209 in catalog/glue/glue.go

View workflow job for this annotation

GitHub Actions / macos-latest go1.23

should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)
// TODO: consider providing a way to directly access the S3 iofs to enable testing of the catalog.
iofs, err := io.LoadFS(ctx, props, location)
if err != nil {
Expand Down
19 changes: 16 additions & 3 deletions io/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,23 @@ func ParseAWSConfig(ctx context.Context, props map[string]string) (*aws.Config,
return awscfg, nil
}

const AwsCfgCtxKey string = "awsConfig"

func createS3Bucket(ctx context.Context, parsed *url.URL, props map[string]string) (*blob.Bucket, error) {
awscfg, err := ParseAWSConfig(ctx, props)
if err != nil {
return nil, err
var (
awscfg *aws.Config
err error
)
if v := ctx.Value(AwsCfgCtxKey); v != nil {
if a, ok := v.(*aws.Config); ok {

Check failure on line 117 in io/s3.go

View workflow job for this annotation

GitHub Actions / ubuntu-latest go1.23

this value of a is never used (SA4006)

Check failure on line 117 in io/s3.go

View workflow job for this annotation

GitHub Actions / windows-latest go1.23

this value of a is never used (SA4006)

Check failure on line 117 in io/s3.go

View workflow job for this annotation

GitHub Actions / macos-latest go1.23

this value of a is never used (SA4006)
awscfg = a

Check failure on line 118 in io/s3.go

View workflow job for this annotation

GitHub Actions / ubuntu-latest go1.23

this value of awscfg is never used (SA4006)

Check failure on line 118 in io/s3.go

View workflow job for this annotation

GitHub Actions / windows-latest go1.23

this value of awscfg is never used (SA4006)

Check failure on line 118 in io/s3.go

View workflow job for this annotation

GitHub Actions / macos-latest go1.23

this value of awscfg is never used (SA4006)
}
return nil, fmt.Errorf("invalid awsConfig type: %T", v)
} else {
awscfg, err = ParseAWSConfig(ctx, props)
if err != nil {
return nil, err
}
}

endpoint, ok := props[S3EndpointURL]
Expand Down

0 comments on commit ea242f3

Please sign in to comment.