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
12 changes: 12 additions & 0 deletions csharp.test/TestColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ public static void TestUnsupportedLogicalTypeOverride()
Contains.Substring("JSON cannot be applied to primitive type INT64"));
}

[Test]
public static void TestInvalidGuidLogicalTypeOverride()
{
using var decimalType = LogicalType.Decimal(29, 3);

var exception = Assert.Throws<ArgumentException>(() => { _ = new Column<Guid>("guid", decimalType); });

Assert.That(
exception?.Message,
Contains.Substring("Invalid logical type override"));
}

private static ExpectedPrimitive[] CreateExpectedPrimitives()
{
return new[]
Expand Down
1 change: 0 additions & 1 deletion csharp.test/TestLogicalTypeRoundtrip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2154,7 +2154,6 @@ private static ExpectedColumn[] CreateExpectedColumns()
Name = "uuid_field",
PhysicalType = PhysicalType.FixedLenByteArray,
LogicalType = LogicalType.Uuid(),
LogicalTypeOverride = LogicalType.Uuid(),
Length = 16,
Values = Enumerable.Range(0, NumRows).Select(i => new Guid(i, 0x1234, 0x5678, 0x9A, 0xBC, 0xDE, 0xF0, 0x12, 0x34, 0x56, 0x7F)).ToArray(),
Min = new Guid(0, 0x1234, 0x5678, 0x9A, 0xBC, 0xDE, 0xF0, 0x12, 0x34, 0x56, 0x7F),
Expand Down
4 changes: 2 additions & 2 deletions csharp/Column.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public Column(Type logicalSystemType, string name, LogicalType? logicalTypeOverr
throw new ArgumentException("decimal type requires a DecimalLogicalType override");
}

if (isUuid && !(logicalTypeOverride is UuidLogicalType))
if (isUuid && logicalTypeOverride != null && !(logicalTypeOverride is UuidLogicalType or NoneLogicalType))
{
throw new ArgumentException("Guid type requires a UuidLogicalType override");
throw new ArgumentException($"Invalid logical type override '{logicalTypeOverride}' for Guid typed column");
}

LogicalSystemType = logicalSystemType ?? throw new ArgumentNullException(nameof(logicalSystemType));
Expand Down