diff --git a/csharp.test/TestColumn.cs b/csharp.test/TestColumn.cs index f233ce50..0c814de5 100644 --- a/csharp.test/TestColumn.cs +++ b/csharp.test/TestColumn.cs @@ -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(() => { _ = new Column("guid", decimalType); }); + + Assert.That( + exception?.Message, + Contains.Substring("Invalid logical type override")); + } + private static ExpectedPrimitive[] CreateExpectedPrimitives() { return new[] diff --git a/csharp.test/TestLogicalTypeRoundtrip.cs b/csharp.test/TestLogicalTypeRoundtrip.cs index 22f6882f..22be339e 100644 --- a/csharp.test/TestLogicalTypeRoundtrip.cs +++ b/csharp.test/TestLogicalTypeRoundtrip.cs @@ -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), diff --git a/csharp/Column.cs b/csharp/Column.cs index 1905fc4d..1c17198b 100644 --- a/csharp/Column.cs +++ b/csharp/Column.cs @@ -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));