Skip to content
Open
4 changes: 2 additions & 2 deletions .github/workflows/go-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ jobs:
env:
AWS_S3_ENDPOINT: "${{ env.AWS_S3_ENDPOINT }}"
AWS_REGION: "us-east-1"
run: |
run: |
go test -tags integration -v -run="^TestScanner" ./table
go test -tags integration -v ./io
go test -tags integration -v ./io/...
go test -tags integration -v -run="^TestRestIntegration$" ./catalog/rest
go test -tags=integration -v ./catalog/hive/...
- name: Run spark integration tests
Expand Down
1 change: 1 addition & 0 deletions catalog/glue/glue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (

"github.com/apache/iceberg-go"
"github.com/apache/iceberg-go/catalog"
_ "github.com/apache/iceberg-go/io/gocloud"
"github.com/apache/iceberg-go/table"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
Expand Down
1 change: 1 addition & 0 deletions catalog/rest/rest_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/apache/iceberg-go/catalog"
"github.com/apache/iceberg-go/catalog/rest"
"github.com/apache/iceberg-go/io"
_ "github.com/apache/iceberg-go/io/gocloud"
"github.com/apache/iceberg-go/table"
"github.com/apache/iceberg-go/view"
"github.com/stretchr/testify/require"
Expand Down
1 change: 1 addition & 0 deletions catalog/sql/sql_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/apache/iceberg-go/catalog"
"github.com/apache/iceberg-go/catalog/sql"
"github.com/apache/iceberg-go/io"
_ "github.com/apache/iceberg-go/io/gocloud"
"github.com/apache/iceberg-go/table"
"github.com/stretchr/testify/suite"
)
Expand Down
1 change: 1 addition & 0 deletions catalog/sql/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/apache/iceberg-go/catalog"
"github.com/apache/iceberg-go/catalog/internal"
sqlcat "github.com/apache/iceberg-go/catalog/sql"
_ "github.com/apache/iceberg-go/io/gocloud"
"github.com/apache/iceberg-go/table"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
Expand Down
1 change: 1 addition & 0 deletions cmd/iceberg/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/apache/iceberg-go/catalog/hive"
"github.com/apache/iceberg-go/catalog/rest"
"github.com/apache/iceberg-go/config"
_ "github.com/apache/iceberg-go/io/gocloud"
"github.com/apache/iceberg-go/table"

awsconfig "github.com/aws/aws-sdk-go-v2/config"
Expand Down
54 changes: 54 additions & 0 deletions io/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package io

// Constants for S3 configuration options
const (
S3Region = "s3.region"
S3SessionToken = "s3.session-token"
S3SecretAccessKey = "s3.secret-access-key"
S3AccessKeyID = "s3.access-key-id"
S3EndpointURL = "s3.endpoint"
S3ProxyURI = "s3.proxy-uri"
S3ConnectTimeout = "s3.connect-timeout"
S3SignerURI = "s3.signer.uri"
S3ForceVirtualAddressing = "s3.force-virtual-addressing"
)

// Constants for GCS configuration options
const (
GCSEndpoint = "gcs.endpoint"
GCSKeyPath = "gcs.keypath"
GCSJSONKey = "gcs.jsonkey"
GCSCredType = "gcs.credtype"
GCSUseJSONAPI = "gcs.usejsonapi" // set to anything to enable
)

// Constants for Azure configuration options
const (
ADLSSasTokenPrefix = "adls.sas-token."
ADLSConnectionStringPrefix = "adls.connection-string."
ADLSSharedKeyAccountName = "adls.auth.shared-key.account.name"
ADLSSharedKeyAccountKey = "adls.auth.shared-key.account.key"
ADLSEndpoint = "adls.endpoint"
ADLSProtocol = "adls.protocol"

// Not in use yet
// ADLSReadBlockSize = "adls.read.block-size-bytes"
// ADLSWriteBlockSize = "adls.write.block-size-bytes"
)
31 changes: 9 additions & 22 deletions io/azure.go → io/gocloud/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

package io
package gocloud
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to nesting, all integration tests aren't running in CI anymore

Copy link
Contributor Author

@alessandro-nori alessandro-nori Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 😬 ! Fixed it in 4556800

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍🏻


import (
"context"
Expand All @@ -28,6 +28,7 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
"github.com/apache/iceberg-go/io"
"gocloud.dev/blob"
"gocloud.dev/blob/azureblob"
)
Expand All @@ -36,20 +37,6 @@ import (
// https://github.com/apache/iceberg/blob/2114bf631e49af532d66e2ce148ee49dd1dd1f1f/azure/src/main/java/org/apache/iceberg/azure/adlsv2/ADLSLocation.java#L47
var adlsURIPattern = regexp.MustCompile(`^(abfss?|wasbs?)://([^/?#]+)(.*)?$`)

// Constants for Azure configuration options
const (
AdlsSasTokenPrefix = "adls.sas-token."
AdlsConnectionStringPrefix = "adls.connection-string."
AdlsSharedKeyAccountName = "adls.auth.shared-key.account.name"
AdlsSharedKeyAccountKey = "adls.auth.shared-key.account.key"
AdlsEndpoint = "adls.endpoint"
AdlsProtocol = "adls.protocol"

// Not in use yet
// AdlsReadBlockSize = "adls.read.block-size-bytes"
// AdlsWriteBlockSize = "adls.write.block-size-bytes"
)

// adlsLocation represents the parsed components of an Azure Data Lake Storage URI
type adlsLocation struct {
accountName string // Azure storage account name
Expand Down Expand Up @@ -119,25 +106,25 @@ func newAdlsLocation(adlsURI *url.URL) (*adlsLocation, error) {

// Construct a Azure bucket from a URL
func createAzureBucket(ctx context.Context, parsed *url.URL, props map[string]string) (*blob.Bucket, error) {
adlsSasTokens := propertiesWithPrefix(props, AdlsSasTokenPrefix)
adlsConnectionStrings := propertiesWithPrefix(props, AdlsConnectionStringPrefix)
adlsSasTokens := propertiesWithPrefix(props, io.ADLSSasTokenPrefix)
adlsConnectionStrings := propertiesWithPrefix(props, io.ADLSConnectionStringPrefix)

// Construct the client
location, err := newAdlsLocation(parsed)
if err != nil {
return nil, err
}

sharedKeyAccountName := props[AdlsSharedKeyAccountName]
endpoint := props[AdlsEndpoint]
protocol := props[AdlsProtocol]
sharedKeyAccountName := props[io.ADLSSharedKeyAccountName]
endpoint := props[io.ADLSEndpoint]
protocol := props[io.ADLSProtocol]

var client *container.Client

if sharedKeyAccountName != "" {
sharedKeyAccountKey, ok := props[AdlsSharedKeyAccountKey]
sharedKeyAccountKey, ok := props[io.ADLSSharedKeyAccountKey]
if !ok || sharedKeyAccountKey == "" {
return nil, fmt.Errorf("azure authentication: shared-key requires both %s and %s", AdlsSharedKeyAccountName, AdlsSharedKeyAccountKey)
return nil, fmt.Errorf("azure authentication: shared-key requires both %s and %s", io.ADLSSharedKeyAccountName, io.ADLSSharedKeyAccountKey)
}

containerURL, err := createContainerURL(location.accountName, protocol, endpoint, "", location.containerName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

//go:build integration

package io_test
package gocloud_test

import (
"context"
Expand All @@ -30,6 +30,7 @@ import (
"github.com/apache/iceberg-go/catalog"
sqlcat "github.com/apache/iceberg-go/catalog/sql"
"github.com/apache/iceberg-go/io"
_ "github.com/apache/iceberg-go/io/gocloud"
"github.com/stretchr/testify/suite"
"github.com/uptrace/bun/driver/sqliteshim"
"gocloud.dev/blob/azureblob"
Expand Down Expand Up @@ -64,10 +65,10 @@ func (s *AzureBlobIOTestSuite) TestAzureBlobWarehouseKey() {
sqlcat.DriverKey: sqliteshim.ShimName,
sqlcat.DialectKey: string(sqlcat.SQLite),
"type": "sql",
io.AdlsSharedKeyAccountName: accountName,
io.AdlsSharedKeyAccountKey: accountKey,
io.AdlsEndpoint: endpoint,
io.AdlsProtocol: protocol,
io.ADLSSharedKeyAccountName: accountName,
io.ADLSSharedKeyAccountKey: accountKey,
io.ADLSEndpoint: endpoint,
io.ADLSProtocol: protocol,
}

cat, err := catalog.Load(context.Background(), "default", properties)
Expand Down Expand Up @@ -99,7 +100,7 @@ func (s *AzureBlobIOTestSuite) TestAzuriteWarehouseConnectionString() {
sqlcat.DriverKey: sqliteshim.ShimName,
sqlcat.DialectKey: string(sqlcat.SQLite),
"type": "sql",
io.AdlsConnectionStringPrefix + accountName: connectionString,
io.ADLSConnectionStringPrefix + accountName: connectionString,
}

cat, err := catalog.Load(context.Background(), "default", properties)
Expand Down
2 changes: 1 addition & 1 deletion io/azure_test.go → io/gocloud/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

package io
package gocloud

import (
"context"
Expand Down
9 changes: 5 additions & 4 deletions io/blob.go → io/gocloud/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

package io
package gocloud

import (
"context"
Expand All @@ -26,6 +26,7 @@ import (
"path/filepath"
"strings"

icebergio "github.com/apache/iceberg-go/io"
"gocloud.dev/blob"
)

Expand Down Expand Up @@ -103,7 +104,7 @@ func (bfs *blobFileIO) preprocess(path string) (string, error) {
return bfs.keyExtractor(path)
}

func (bfs *blobFileIO) Open(path string) (File, error) {
func (bfs *blobFileIO) Open(path string) (icebergio.File, error) {
var err error
path, err = bfs.preprocess(path)
if err != nil {
Expand Down Expand Up @@ -133,7 +134,7 @@ func (bfs *blobFileIO) Remove(name string) error {
return bfs.Delete(bfs.ctx, name)
}

func (bfs *blobFileIO) Create(name string) (FileWriter, error) {
func (bfs *blobFileIO) Create(name string) (icebergio.FileWriter, error) {
return bfs.NewWriter(bfs.ctx, name, true, nil)
}

Expand Down Expand Up @@ -185,7 +186,7 @@ func (bfs *blobFileIO) NewWriter(ctx context.Context, path string, overwrite boo
nil
}

func createBlobFS(ctx context.Context, bucket *blob.Bucket, keyExtractor KeyExtractor) IO {
func createBlobFS(ctx context.Context, bucket *blob.Bucket, keyExtractor KeyExtractor) icebergio.IO {
return &blobFileIO{Bucket: bucket, keyExtractor: keyExtractor, ctx: ctx}
}

Expand Down
2 changes: 1 addition & 1 deletion io/blob_test.go → io/gocloud/blob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

package io
package gocloud

import (
"context"
Expand Down
22 changes: 7 additions & 15 deletions io/gcs.go → io/gocloud/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,21 @@
// specific language governing permissions and limitations
// under the License.

package io
package gocloud

import (
"context"
"net/url"

"cloud.google.com/go/storage"

"github.com/apache/iceberg-go/io"
"gocloud.dev/blob"
"gocloud.dev/blob/gcsblob"
"gocloud.dev/gcp"
"google.golang.org/api/option"
)

// Constants for GCS configuration options
const (
GCSEndpoint = "gcs.endpoint"
GCSKeyPath = "gcs.keypath"
GCSJSONKey = "gcs.jsonkey"
GCSCredType = "gcs.credtype"
GCSUseJsonAPI = "gcs.usejsonapi" // set to anything to enable
)

var allowedGCSCredTypes = map[string]option.CredentialsType{
"service_account": option.ServiceAccount,
"authorized_user": option.AuthorizedUser,
Expand All @@ -48,22 +40,22 @@ var allowedGCSCredTypes = map[string]option.CredentialsType{
// ParseGCSConfig parses GCS properties and returns a configuration.
func ParseGCSConfig(props map[string]string) *gcsblob.Options {
var o []option.ClientOption
if url := props[GCSEndpoint]; url != "" {
if url := props[io.GCSEndpoint]; url != "" {
o = append(o, option.WithEndpoint(url))
}
var credType option.CredentialsType
if key := props[GCSCredType]; key != "" {
if key := props[io.GCSCredType]; key != "" {
if ct, ok := allowedGCSCredTypes[key]; ok {
credType = ct
}
}
if key := props[GCSJSONKey]; key != "" {
if key := props[io.GCSJSONKey]; key != "" {
o = append(o, option.WithAuthCredentialsJSON(credType, []byte(key)))
}
if path := props[GCSKeyPath]; path != "" {
if path := props[io.GCSKeyPath]; path != "" {
o = append(o, option.WithAuthCredentialsFile(credType, path))
}
if _, ok := props[GCSUseJsonAPI]; ok {
if _, ok := props[io.GCSUseJSONAPI]; ok {
o = append(o, storage.WithJSONReads())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

//go:build integration

package io_test
package gocloud_test

import (
"bytes"
Expand All @@ -32,6 +32,7 @@ import (
"github.com/apache/iceberg-go/catalog"
sqlcat "github.com/apache/iceberg-go/catalog/sql"
"github.com/apache/iceberg-go/io"
_ "github.com/apache/iceberg-go/io/gocloud"
"github.com/stretchr/testify/suite"
"github.com/uptrace/bun/driver/sqliteshim"
)
Expand Down Expand Up @@ -114,7 +115,7 @@ func (s *GCSIOTestSuite) TestGCSWarehouse() {
"type": "sql",
"warehouse": fmt.Sprintf("gs://%s/iceberg/", gcsBucketName),
io.GCSEndpoint: fmt.Sprintf("http://%s/", gcsEndpoint),
io.GCSUseJsonAPI: "true",
io.GCSUseJSONAPI: "true",
}

cat, err := catalog.Load(context.Background(), "default", properties)
Expand Down
Loading
Loading