[
https://issues.apache.org/jira/browse/AVRO-3219?focusedWorklogId=787423&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-787423
]
ASF GitHub Bot logged work on AVRO-3219:
----------------------------------------
Author: ASF GitHub Bot
Created on: 03/Jul/22 16:29
Start Date: 03/Jul/22 16:29
Worklog Time Spent: 10m
Work Description: KalleOlaviNiemitalo commented on code in PR #1348:
URL: https://github.com/apache/avro/pull/1348#discussion_r912508413
##########
lang/csharp/src/apache/main/Reflect/ClassCache.cs:
##########
@@ -254,15 +254,31 @@ public void LoadClassCache(Type objType, Schema s)
EnumCache.AddEnumNameMapItem(ns, objType);
break;
case UnionSchema us:
- if (us.Schemas.Count == 2 && (us.Schemas[0].Tag ==
Schema.Type.Null || us.Schemas[1].Tag == Schema.Type.Null) && objType.IsClass)
+ if (us.Schemas.Count == 2 && (us.Schemas[0].Tag ==
Schema.Type.Null || us.Schemas[1].Tag == Schema.Type.Null))
{
// in this case objType will match the non null type
in the union
foreach (var o in us.Schemas)
{
- if (o.Tag != Schema.Type.Null)
+ if (o.Tag == Schema.Type.Null)
+ {
+ continue;
+ }
+
+ if (objType.IsClass)
{
LoadClassCache(objType, o);
}
+
+ if (objType.IsGenericType)
+ {
+ var genericType =
objType.GetGenericTypeDefinition();
+ var isNullable = genericType ==
typeof(Nullable<>);
+ var innerType =
objType.GetGenericArguments()[0];
+ if (isNullable && innerType.IsEnum)
+ {
+
LoadClassCache(objType.GetGenericArguments()[0], o);
Review Comment:
Please use `innerType` instead of calling GetGenericArguments again.
Issue Time Tracking
-------------------
Worklog Id: (was: 787423)
Time Spent: 40m (was: 0.5h)
> Not support for nullable enum type fields
> -----------------------------------------
>
> Key: AVRO-3219
> URL: https://issues.apache.org/jira/browse/AVRO-3219
> Project: Apache Avro
> Issue Type: New Feature
> Components: csharp
> Affects Versions: 1.10.2
> Reporter: Zike Yang
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.11.1
>
> Attachments: AVRO-3219.patch
>
> Time Spent: 40m
> Remaining Estimate: 0h
>
> Currently, when the schema contain nullable enum type, it will throw
> Exception`Couldnot find enumeration for avro full name ...` while writing or
> reading.
>
> We need to add support for the nullable enum type.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)