[
https://issues.apache.org/jira/browse/AVRO-3478?focusedWorklogId=787406&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-787406
]
ASF GitHub Bot logged work on AVRO-3478:
----------------------------------------
Author: ASF GitHub Bot
Created on: 03/Jul/22 14:59
Start Date: 03/Jul/22 14:59
Worklog Time Spent: 10m
Work Description: KalleOlaviNiemitalo commented on code in PR #1630:
URL: https://github.com/apache/avro/pull/1630#discussion_r912499135
##########
lang/csharp/src/apache/test/Util/LogicalTypeTests.cs:
##########
@@ -405,6 +405,52 @@ public void TestTimeMicrosecond(string s, string e, bool
expectRangeError)
}
}
+ [TestCase(0, 0, 0)]
+ [TestCase(0, 0, 1)]
+ [TestCase(0, 1, 0)]
+ [TestCase(0, 1, 1)]
+ [TestCase(1, 0, 0)]
+ [TestCase(1, 0, 1)]
+ [TestCase(1, 1, 0)]
+ [TestCase(1, 1, 1)]
+ [TestCase(999, 9999, 99999)]
+ public void TestDuration(int months, int days, int milliseconds)
+ {
+ var durationSchema = (LogicalSchema)Schema.Parse("{\"type\":
{\"type\": \"fixed\", \"size\": 12, \"name\": \"n\"}, \"logicalType\":
\"duration\"}");
Review Comment:
Without the C# string syntax, the schema in this test is:
```JSON
{"type": {"type": "fixed", "size": 12, "name": "n"}, "logicalType":
"duration"}
```
Is that the right way to write a schema for a logical type based on a
complex type? From looking at the Java implementation of Schema.parse, I would
expect the following instead:
```JSON
{"type": "fixed", "size": 12, "name": "n", "logicalType": "duration"}
```
because if the schema is a JSON object, the Java code expects its "type"
property to have a string value rather than a nested object:
<https://github.com/apache/avro/blob/797cec66c4d4b2d4eaf909bfc2a7d98922e2b128/lang/java/avro/src/main/java/org/apache/avro/Schema.java#L1681-L1683>
But then, if you refer to the schema "n" by name from elsewhere, does that
mean the LogicalSchema or the underlying FixedSchema? In the Java
implementation, there is no LogicalSchema class and the LogicalType is just a
property of Schema, so the name "n" would refer to the FixedSchema that has a
LogicalType. In the C# implementation then, the name "n" would have to refer to
the LogicalSchema. Does that mean LogicalSchema would now have to be derived
from NamedSchema rather than UnnamedSchema, and have the same SchemaName as the
underlying FixedSchema? Ugh… perhaps it would be better to delete the
LogicalSchema class and reimplement logical types the same way as in Java.
Issue Time Tracking
-------------------
Worklog Id: (was: 787406)
Remaining Estimate: 21h 40m (was: 21h 50m)
Time Spent: 2h 20m (was: 2h 10m)
> Support duration logical type in C#
> -----------------------------------
>
> Key: AVRO-3478
> URL: https://issues.apache.org/jira/browse/AVRO-3478
> Project: Apache Avro
> Issue Type: Improvement
> Components: csharp
> Reporter: Zoltan Csizmadia
> Priority: Minor
> Labels: pull-request-available
> Original Estimate: 24h
> Time Spent: 2h 20m
> Remaining Estimate: 21h 40m
>
> Support for "duration" logical type
--
This message was sent by Atlassian Jira
(v8.20.10#820010)