From d8febde144ae4f2424947caa90a625c4c9d7ab49 Mon Sep 17 00:00:00 2001 From: IG Date: Fri, 2 Feb 2024 10:03:52 +0000 Subject: [PATCH] test for reflecting nullable TimeOnly --- docs/release-history.md | 2 +- .../Serialisation/SchemaReflectorTest.cs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/release-history.md b/docs/release-history.md index c38491ab..e67a9692 100644 --- a/docs/release-history.md +++ b/docs/release-history.md @@ -2,7 +2,7 @@ ### Bug fixes -Fixed regression in schema discovery of nullables. +Fixed regression in schema discovery of nullables for `DateTime`, `DateOnly`, `TimeOnly`. ## 4.23.3 diff --git a/src/Parquet.Test/Serialisation/SchemaReflectorTest.cs b/src/Parquet.Test/Serialisation/SchemaReflectorTest.cs index 7dd6f040..e8d6c622 100644 --- a/src/Parquet.Test/Serialisation/SchemaReflectorTest.cs +++ b/src/Parquet.Test/Serialisation/SchemaReflectorTest.cs @@ -333,6 +333,8 @@ class DatesPoco { public TimeOnly DefaultTimeOnly { get; set; } + public TimeOnly? DefaultNullableTimeOnly { get; set; } + [ParquetMicroSecondsTime] public TimeOnly MicroTimeOnly { get; set; } @@ -422,6 +424,17 @@ public void Type_TimeOnly_Default() { DataField df = s.FindDataField(nameof(DatesPoco.DefaultTimeOnly)); Assert.True(df is TimeOnlyDataField); Assert.Equal(TimeSpanFormat.MilliSeconds, ((TimeOnlyDataField)df).TimeSpanFormat); + Assert.False(df.IsNullable); + } + + [Fact] + public void Type_TimeOnly_Nullable() { + ParquetSchema s = typeof(DatesPoco).GetParquetSchema(true); + + DataField df = s.FindDataField(nameof(DatesPoco.DefaultNullableTimeOnly)); + Assert.True(df is TimeOnlyDataField); + Assert.Equal(TimeSpanFormat.MilliSeconds, ((TimeOnlyDataField)df).TimeSpanFormat); + Assert.True(df.IsNullable); } [Fact]