DuckDB.NET icon indicating copy to clipboard operation
DuckDB.NET copied to clipboard

Unrecognised type TimestampNs

Open bouvierr opened this issue 1 year ago • 7 comments

I am using DuckDB.NET.Data.Full 0.9.2.

When I call DuckDB.NET.Data.DuckDBDataReader.GetSchemaTable, I get the following exception if any column is of type TIMESTAMP_NS:

System.ArgumentException: Unrecognised type TimestampNs (22) for column TargetDate
   at DuckDB.NET.Data.Internal.Reader.VectorDataReaderBase.GetColumnType()
   at DuckDB.NET.Data.Internal.Reader.VectorDataReaderBase.get_ClrType()
   at DuckDB.NET.Data.DuckDBDataReader.GetFieldType(Int32 ordinal)
   at DuckDB.NET.Data.DuckDBDataReader.GetSchemaTable()

If I change the type to its alias with ALTER TABLE mytable ALTER TargetDate TYPE TIMESTAMP, then GetSchemaTable works fine.

I believe the issue is simply that the code currently supports only the type alias TIMESTAMP and not the official type TIMESTAMP_NS.

bouvierr avatar Feb 07 '24 13:02 bouvierr

It's implemented in the Reader Type Overhaul and will be released after DuckDB 0.10 is released.

Giorgi avatar Feb 07 '24 13:02 Giorgi

Glad to hear this will be fixed in the next release!

I tried out Reader Type Overhaul.

In TimestampTests.QueryScalarTest, if I replace TIMESTAMP by TIMESTAMP_NS in the Command.CommandText, the test fails because we get a DuckDBTimestamp instead of a DateTime. I was wondering if this is the expected behavior? The Date and Time values are all good though.

Thanks.

bouvierr avatar Feb 07 '24 14:02 bouvierr

I made some changes to the returned types in that branch. I will check the behaviour you described.

Giorgi avatar Feb 07 '24 14:02 Giorgi

@bouvierr Can you clarify which test you mean?

Giorgi avatar Feb 07 '24 15:02 Giorgi

this test: https://github.com/Giorgi/DuckDB.NET/blob/86017db53ff55fbe4c794124e4dd3bfbe74f69cb/DuckDB.NET.Test/Parameters/TimestampTests.cs#L21

bouvierr avatar Feb 07 '24 15:02 bouvierr

It should be fixed now.

Giorgi avatar Feb 07 '24 22:02 Giorgi

Awesome. Thanks!

bouvierr avatar Feb 08 '24 14:02 bouvierr

This is now merged into develop and will be included in the next release.

Giorgi avatar Feb 11 '24 19:02 Giorgi