ch-robinson / dotnet-avro

An Avro implementation for .NET
https://engineering.chrobinson.com/dotnet-avro/
MIT License
135 stars 51 forks source link

why .net DateTime schema is string #154

Closed xichenAiguang closed 3 years ago

xichenAiguang commented 3 years ago

I am the beginner of Avro, I use below code to test Chr.Avro, I have a property MyDateTime in MyClass which is DateTime type, I found when calling 'builder.schema' to generate schema, 'MyDateTime' is marked as String in output, is it expected? Asked this because I see the official doc say Avro already supported Timestamp.

official doc link: https://avro.apache.org/docs/1.8.0/spec.html#Timestamp

My test class class MyClass { public Decimal MyDecimal { get; set; } public bool MyBool { get; set; } public long? MyLong { get; set; } public DateTime? MyDateTime { get; set; } public string MyString { get; set; } public byte MyByte { get; set; } public short MyShort { get; set; } }

use this code snippet to generate schema

var builder = new SchemaBuilder(); var schema = builder.BuildSchema<MyClass>(); var writer = new JsonSchemaWriter(); Console.WriteLine(writer.Write(schema));

Output snippet {"name":"MyDateTime","type":["null","string"]},