[
https://issues.apache.org/jira/browse/AVRO-3468?focusedWorklogId=747300&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-747300
]
ASF GitHub Bot logged work on AVRO-3468:
----------------------------------------
Author: ASF GitHub Bot
Created on: 24/Mar/22 15:52
Start Date: 24/Mar/22 15:52
Worklog Time Spent: 10m
Work Description: anekdoti commented on a change in pull request #1622:
URL: https://github.com/apache/avro/pull/1622#discussion_r834465296
##########
File path: lang/csharp/src/apache/test/Specific/SpecificTests.cs
##########
@@ -440,6 +441,69 @@ public void TestEmbeddedGenerics()
Assert.AreEqual(0, dstRecord.UserMatrix[2].Count);
}
+ private static void serializeGeneric<T>(string writerSchema, T actual,
out Stream stream, out Schema ws)
+ {
+ var ms = new MemoryStream();
+ Encoder e = new BinaryEncoder(ms);
+ ws = Schema.Parse(writerSchema);
+ GenericWriter<T> w = new GenericWriter<T>(ws);
+ w.Write(actual, e);
+ ms.Flush();
+ ms.Position = 0;
+ stream = ms;
+ }
+
+
+ [Test]
+ public void DeserializeToLogicalTypeWithDefault()
+ {
+ var writerSchemaString = @"{
+ ""type"": ""record"",
+ ""name"": ""RecordWithOptionalLogicalType"",
+ ""namespace"": ""Avro.Test.Specific.return"",
+ ""fields"": [
+ ]}";
+
+ var writerSchema = Schema.Parse(writerSchemaString);
+
+ Stream stream;
+
+ serializeGeneric(writerSchemaString,
+ mkRecord(new object[] { }, (RecordSchema)writerSchema),
+ out stream,
+ out _);
+
+ RecordWithOptionalLogicalType output =
deserialize<RecordWithOptionalLogicalType>(stream, writerSchema,
RecordWithOptionalLogicalType._SCHEMA);
+
+ Assert.AreEqual(output.x, new DateTime(1970, 1, 11));
+
+ }
+
+ private static GenericRecord mkRecord(object[] kv, RecordSchema s)
Review comment:
Sure!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 747300)
Time Spent: 1h (was: 50m)
> Default values for logical types not supported
> ----------------------------------------------
>
> Key: AVRO-3468
> URL: https://issues.apache.org/jira/browse/AVRO-3468
> Project: Apache Avro
> Issue Type: Bug
> Components: csharp
> Affects Versions: 1.11.0
> Reporter: Lucas Heimberg
> Priority: Major
> Labels: pull-request-available
> Time Spent: 1h
> Remaining Estimate: 0h
>
> The C# implementation of Avro does not support default values for logical
> types on deserialization. It seems that the method EncodeDefaultValue in
> Avro.IO.Resolver is lacking a case for logical types that resorts to the base
> schema.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)