Skip to content

Commit 00de88a

Browse files
committed
Don't require passing a logical type override for Guid typed columns
1 parent 071fcfa commit 00de88a

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

csharp.test/TestColumn.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ public static void TestUnsupportedLogicalTypeOverride()
7676
Contains.Substring("JSON cannot be applied to primitive type INT64"));
7777
}
7878

79+
[Test]
80+
public static void TestInvalidGuidLogicalTypeOverride()
81+
{
82+
using var decimalType = LogicalType.Decimal(29, 3);
83+
84+
var exception = Assert.Throws<ArgumentException>(() => { _ = new Column<Guid>("guid", decimalType); });
85+
86+
Assert.That(
87+
exception?.Message,
88+
Contains.Substring("Invalid logical type override"));
89+
}
90+
7991
private static ExpectedPrimitive[] CreateExpectedPrimitives()
8092
{
8193
return new[]

csharp.test/TestLogicalTypeRoundtrip.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2154,7 +2154,6 @@ private static ExpectedColumn[] CreateExpectedColumns()
21542154
Name = "uuid_field",
21552155
PhysicalType = PhysicalType.FixedLenByteArray,
21562156
LogicalType = LogicalType.Uuid(),
2157-
LogicalTypeOverride = LogicalType.Uuid(),
21582157
Length = 16,
21592158
Values = Enumerable.Range(0, NumRows).Select(i => new Guid(i, 0x1234, 0x5678, 0x9A, 0xBC, 0xDE, 0xF0, 0x12, 0x34, 0x56, 0x7F)).ToArray(),
21602159
Min = new Guid(0, 0x1234, 0x5678, 0x9A, 0xBC, 0xDE, 0xF0, 0x12, 0x34, 0x56, 0x7F),

csharp/Column.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ public Column(Type logicalSystemType, string name, LogicalType? logicalTypeOverr
5555
throw new ArgumentException("decimal type requires a DecimalLogicalType override");
5656
}
5757

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

6363
LogicalSystemType = logicalSystemType ?? throw new ArgumentNullException(nameof(logicalSystemType));

0 commit comments

Comments
 (0)