Skip to content
Closed
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
35 changes: 35 additions & 0 deletions src/Parquet.Test/Types/EndToEndDateTimeKindTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using Parquet.Data;
using Parquet.Schema;
using Xunit;

namespace Parquet.Test.Types {
public class EndToEndDateTimeKindTest : TestBase {
private static DateTime BaseDate => DateTime.Parse("2020-06-10T11:12:13", CultureInfo.InvariantCulture);
private static DateTime UtcDate => DateTime.SpecifyKind(BaseDate, DateTimeKind.Utc);
private static DateTime UnknownDate => DateTime.SpecifyKind(BaseDate, DateTimeKind.Unspecified);
private static DateTime LocalDate => DateTime.SpecifyKind(BaseDate, DateTimeKind.Local);

private static DateTime ExpectedUnspecified => DateTime.SpecifyKind(BaseDate, DateTimeKind.Unspecified);
private static DateTime ExpectedLocal => DateTime.SpecifyKind(LocalDate.ToUniversalTime(), DateTimeKind.Unspecified);

[Fact]
public async Task Int96_dates_round_trip_as_unknown() {
var schema = new ParquetSchema(new DataField<DateTime>("datetime"));
DataField field = schema.DataFields[0];
var column = new DataColumn(field, new[] { UtcDate, UnknownDate, LocalDate });

Check failure on line 23 in src/Parquet.Test/Types/EndToEndDateTimeKindTest.cs

View workflow job for this annotation

GitHub Actions / 🧪 Unit Tests - Linux x64

The type or namespace name 'DataColumn' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 23 in src/Parquet.Test/Types/EndToEndDateTimeKindTest.cs

View workflow job for this annotation

GitHub Actions / 🏛️ Build NuGet

The type or namespace name 'DataColumn' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 23 in src/Parquet.Test/Types/EndToEndDateTimeKindTest.cs

View workflow job for this annotation

GitHub Actions / 🏛️ Build NuGet

The type or namespace name 'DataColumn' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 23 in src/Parquet.Test/Types/EndToEndDateTimeKindTest.cs

View workflow job for this annotation

GitHub Actions / 🧪 Unit Tests - MacOS ARM64

The type or namespace name 'DataColumn' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 23 in src/Parquet.Test/Types/EndToEndDateTimeKindTest.cs

View workflow job for this annotation

GitHub Actions / 🧪 Unit Tests - Windows x64

The type or namespace name 'DataColumn' could not be found (are you missing a using directive or an assembly reference?)
DataColumn? actualColumn = await WriteReadSingleColumn(column);

Check failure on line 24 in src/Parquet.Test/Types/EndToEndDateTimeKindTest.cs

View workflow job for this annotation

GitHub Actions / 🧪 Unit Tests - Linux x64

The type or namespace name 'DataColumn' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 24 in src/Parquet.Test/Types/EndToEndDateTimeKindTest.cs

View workflow job for this annotation

GitHub Actions / 🏛️ Build NuGet

The type or namespace name 'DataColumn' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 24 in src/Parquet.Test/Types/EndToEndDateTimeKindTest.cs

View workflow job for this annotation

GitHub Actions / 🏛️ Build NuGet

The type or namespace name 'DataColumn' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 24 in src/Parquet.Test/Types/EndToEndDateTimeKindTest.cs

View workflow job for this annotation

GitHub Actions / 🧪 Unit Tests - MacOS ARM64

The type or namespace name 'DataColumn' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 24 in src/Parquet.Test/Types/EndToEndDateTimeKindTest.cs

View workflow job for this annotation

GitHub Actions / 🧪 Unit Tests - Windows x64

The type or namespace name 'DataColumn' could not be found (are you missing a using directive or an assembly reference?)
Assert.NotNull(actualColumn);

DateTime[] actualValues = Assert.IsType<DateTime[]>(actualColumn.Data);

Check failure on line 27 in src/Parquet.Test/Types/EndToEndDateTimeKindTest.cs

View workflow job for this annotation

GitHub Actions / 🧪 Unit Tests - Linux x64

'DataColumn?' does not contain a definition for 'Data' and no accessible extension method 'Data' accepting a first argument of type 'DataColumn?' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 27 in src/Parquet.Test/Types/EndToEndDateTimeKindTest.cs

View workflow job for this annotation

GitHub Actions / 🏛️ Build NuGet

'DataColumn?' does not contain a definition for 'Data' and no accessible extension method 'Data' accepting a first argument of type 'DataColumn?' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 27 in src/Parquet.Test/Types/EndToEndDateTimeKindTest.cs

View workflow job for this annotation

GitHub Actions / 🏛️ Build NuGet

'DataColumn?' does not contain a definition for 'Data' and no accessible extension method 'Data' accepting a first argument of type 'DataColumn?' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 27 in src/Parquet.Test/Types/EndToEndDateTimeKindTest.cs

View workflow job for this annotation

GitHub Actions / 🧪 Unit Tests - MacOS ARM64

'DataColumn?' does not contain a definition for 'Data' and no accessible extension method 'Data' accepting a first argument of type 'DataColumn?' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 27 in src/Parquet.Test/Types/EndToEndDateTimeKindTest.cs

View workflow job for this annotation

GitHub Actions / 🧪 Unit Tests - Windows x64

'DataColumn?' does not contain a definition for 'Data' and no accessible extension method 'Data' accepting a first argument of type 'DataColumn?' could be found (are you missing a using directive or an assembly reference?)
Assert.Equal(3, actualValues.Length);
Assert.Equal(ExpectedUnspecified, actualValues[0]); // utc will be converted to unspecified in the round trip
Assert.Equal(ExpectedUnspecified, actualValues[1]);
Assert.Equal(ExpectedLocal, actualValues[2]);
Assert.True(actualValues.All(d => d.Kind == DateTimeKind.Unspecified));
}
}
}
2 changes: 1 addition & 1 deletion src/Parquet/Data/NanoTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static implicit operator DateTime(NanoTime nanoTime) {
long timeOfDayTicks = nanoTime._timeOfDayNanos / 100;

var result = new DateTime(Year, Month, Day,
0, 0, 0, DateTimeKind.Utc);
0, 0, 0, DateTimeKind.Unspecified);
result = result.AddTicks(timeOfDayTicks);

return result;
Expand Down
Loading