You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by ze...@apache.org on 2025/03/20 17:23:59 UTC
(iceberg-go) branch main updated: fix(catalog): strip trailing slash for warehouse paths (#349)
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 d2a8f18 fix(catalog): strip trailing slash for warehouse paths (#349)
d2a8f18 is described below
commit d2a8f1859b6b125ecbd6b6e668edde7692aeb3a6
Author: Matt Topol <zo...@gmail.com>
AuthorDate: Thu Mar 20 13:23:54 2025 -0400
fix(catalog): strip trailing slash for warehouse paths (#349)
fixes #343
---
catalog/sql/sql.go | 6 +++---
io/s3_integration_test.go | 29 +++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/catalog/sql/sql.go b/catalog/sql/sql.go
index b939e9f..34593c0 100644
--- a/catalog/sql/sql.go
+++ b/catalog/sql/sql.go
@@ -24,7 +24,7 @@ import (
"fmt"
"iter"
"maps"
- "path"
+ "net/url"
"slices"
"strings"
"sync"
@@ -265,11 +265,11 @@ func (c *Catalog) getDefaultWarehouseLocation(ctx context.Context, nsname, table
}
if dblocation := dbprops.Get("location", ""); dblocation != "" {
- return path.Join(dblocation, tableName), nil
+ return url.JoinPath(dblocation, tableName)
}
if warehousepath := c.props.Get("warehouse", ""); warehousepath != "" {
- return warehousepath + "/" + path.Join(nsname+".db", tableName), nil
+ return url.JoinPath(warehousepath, nsname+".db", tableName)
}
return "", errors.New("no default path set, please specify a location when creating a table")
diff --git a/io/s3_integration_test.go b/io/s3_integration_test.go
index 95434a4..12e9a0d 100644
--- a/io/s3_integration_test.go
+++ b/io/s3_integration_test.go
@@ -59,3 +59,32 @@ func TestMinioWarehouse(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, tbl)
}
+
+func TestMinioWarehouseNoLocation(t *testing.T) {
+ cat, err := catalog.Load(context.Background(), "default", iceberg.Properties{
+ "uri": ":memory:",
+ sqlcat.DriverKey: sqliteshim.ShimName,
+ sqlcat.DialectKey: string(sqlcat.SQLite),
+ "type": "sql",
+ "warehouse": "s3a://warehouse/iceberg/",
+ io.S3Region: "local",
+ io.S3AccessKeyID: "admin",
+ io.S3SecretAccessKey: "password",
+ // endpoint is passed via AWS_S3_ENDPOINT env var
+ })
+ require.NoError(t, err)
+
+ require.NotNil(t, cat)
+
+ c := cat.(*sqlcat.Catalog)
+ ctx := context.Background()
+ require.NoError(t, c.CreateNamespace(ctx, catalog.ToIdentifier("iceberg-test-2"), nil))
+
+ tbl, err := c.CreateTable(ctx,
+ catalog.ToIdentifier("iceberg-test-2", "test-table-2"),
+ iceberg.NewSchema(0, iceberg.NestedField{
+ Name: "id", Type: iceberg.PrimitiveTypes.Int32, Required: true, ID: 1,
+ }))
+ require.NoError(t, err)
+ require.NotNil(t, tbl)
+}