Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ public void ToString_ShouldJoinLevelsWithDots() =>
public void Path_ShouldEscapeAndJoinLevelsWithTheEncodedUnitSeparator() =>
IcebergNamespace.Of("a b", "c/d").Path.Should().Be("namespaces/a%20b%1Fc%2Fd", "the Iceberg REST spec joins levels with the 0x1F separator");

[TestMethod]
public void TablesPath_ShouldNestTheTablesCollectionUnderTheNamespace() =>
IcebergNamespace.Of("sales", "europe").TablesPath.Should().Be("namespaces/sales%1Feurope/tables", "the Iceberg REST spec lists and creates tables under the namespace");

[TestMethod]
public void Path_ShouldAcceptLevelsContainingDots() =>
IcebergNamespace.Of("a..b").Path.Should().Be("namespaces/a..b");
Expand Down
5 changes: 5 additions & 0 deletions packages/Storage/Storage.Tests/Common/IcebergTableTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public void Equals_ShouldBeTrue_GivenSameNamespaceAndName() =>
public void Equals_ShouldBeFalse_GivenDifferentName() =>
IcebergNamespace.Of("sales").Table("events").Should().NotBe(IcebergNamespace.Of("sales").Table("orders"));

[TestMethod]
public void CollectionPath_ShouldBeTheTablesCollectionOfItsNamespace() =>
IcebergNamespace.Of("sales", "europe").Table("events").CollectionPath
.Should().Be("namespaces/sales%1Feurope/tables", "a table is created by posting to its namespace's tables");

[TestMethod]
public void Path_ShouldNestTheEscapedNameUnderTheTablesOfItsNamespace() =>
IcebergNamespace.Of("sales", "europe").Table("a/b?c#d").Path
Expand Down
2 changes: 2 additions & 0 deletions packages/Storage/Storage/Common/IcebergNamespace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public override int GetHashCode() =>

internal string Path => $"namespaces/{PathSegment.Escape(this.Joined(), "A namespace", "namespace")}";

internal string TablesPath => $"{this.Path}/tables";

private static void RejectMissing(string[]? levels)
{
if (levels is null)
Expand Down
4 changes: 3 additions & 1 deletion packages/Storage/Storage/Common/IcebergTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ internal IcebergTable(IcebergNamespace @namespace, string name)
/// <inheritdoc />
public override string ToString() => $"{this.Namespace}.{this.Name}";

internal string Path => $"{this.Namespace.Path}/tables/{PathSegment.Escape(this.Name, "A table name", "table")}";
internal string Path => $"{this.CollectionPath}/{PathSegment.Escape(this.Name, "A table name", "table")}";

internal string CollectionPath => this.Namespace.TablesPath;
}
4 changes: 2 additions & 2 deletions packages/Storage/Storage/IcebergCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public async Task<IcebergTableMetadata> CreateTableAsync(IcebergTable table, Ice
{
RequireArgument(table, nameof(table));
RequireArgument(schema, nameof(schema));
var response = await Helpers.MakeRequestAsync<TableMetadataResponse>(this.requestClient, this.options, HttpMethod.Post, this.ResourceUrl($"{table.Namespace.Path}/tables"), CreateTableBody.For(table, schema, options), this.headers(), cancellationToken).ConfigureAwait(false);
var response = await Helpers.MakeRequestAsync<TableMetadataResponse>(this.requestClient, this.options, HttpMethod.Post, this.ResourceUrl(table.CollectionPath), CreateTableBody.For(table, schema, options), this.headers(), cancellationToken).ConfigureAwait(false);
return response!.ToMetadata();
}

Expand Down Expand Up @@ -97,7 +97,7 @@ public Task DeleteTableAsync(IcebergTable table, DeleteTableOptions? options = n
public async Task<IcebergTablePage> ListTablesAsync(IcebergNamespace @namespace, ListTablesOptions? options = null, CancellationToken cancellationToken = default)
{
RequireArgument(@namespace, nameof(@namespace));
var url = ListTablesQuery.For(this.ResourceUrl($"{@namespace.Path}/tables"), options);
var url = ListTablesQuery.For(this.ResourceUrl(@namespace.TablesPath), options);
var response = await Helpers.MakeRequestAsync<ListTablesResponse>(this.requestClient, this.options, HttpMethod.Get, url, null, this.headers(), cancellationToken).ConfigureAwait(false);
return response!.ToPage(@namespace);
}
Expand Down