You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Philip Sanetra (Jira)" <ji...@apache.org> on 2021/02/16 09:00:03 UTC
[jira] [Created] (AVRO-3046) avrogen does not map inner record
namespaces
Philip Sanetra created AVRO-3046:
------------------------------------
Summary: avrogen does not map inner record namespaces
Key: AVRO-3046
URL: https://issues.apache.org/jira/browse/AVRO-3046
Project: Apache Avro
Issue Type: Bug
Components: csharp
Affects Versions: 1.10.1
Reporter: Philip Sanetra
The avrogen tool for C# fails to map the namespaces of inner records.
Example:
{code:java}
{
"type": "record",
"name": "ExampleRecord",
"namespace": "com.example",
"fields": [
{
"name": "Id",
"type": "string",
"logicalType": "UUID"
},
{
"name": "InnerRecord",
"type": {
"type": "record",
"name": "InnerRecord",
"fields": [
{
"name": "Id",
"type": "string",
"logicalType": "UUID"
}
]
}
}
]
}
{code}
Command:
{code:java}
avrogen -s ./example.avsc ./dotnet --namespace "com.example:Example"
{code}
Result:
{code:java}
// ------------------------------------------------------------------------------
// <auto-generated>
// Generated by avrogen, version 1.10.0.0
// Changes to this file may cause incorrect behavior and will be lost if code
// is regenerated
// </auto-generated>
// ------------------------------------------------------------------------------
namespace Example
{
using System;
using System.Collections.Generic;
using System.Text;
using Avro;
using Avro.Specific;
public partial class ExampleRecord : ISpecificRecord
{
public static Schema _SCHEMA = Avro.Schema.Parse("{\"type\":\"record\",\"name\":\"ExampleRecord\",\"namespace\":\"com.example\",\"fields\":[{\"nam" +
"e\":\"Id\",\"type\":\"string\"},{\"name\":\"InnerRecord\",\"type\":{\"type\":\"record\",\"name\":\"I" +
"nnerRecord\",\"namespace\":\"com.example\",\"fields\":[{\"name\":\"Id\",\"type\":\"string\"}]}}" +
"]}");
private string _Id;
private com.example.InnerRecord _InnerRecord;
public virtual Schema Schema
{
get
{
return ExampleRecord._SCHEMA;
}
}
public string Id
{
get
{
return this._Id;
}
set
{
this._Id = value;
}
}
public com.example.InnerRecord InnerRecord
{
get
{
return this._InnerRecord;
}
set
{
this._InnerRecord = value;
}
}
public virtual object Get(int fieldPos)
{
switch (fieldPos)
{
case 0: return this.Id;
case 1: return this.InnerRecord;
default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Get()");
};
}
public virtual void Put(int fieldPos, object fieldValue)
{
switch (fieldPos)
{
case 0: this.Id = (System.String)fieldValue; break;
case 1: this.InnerRecord = (com.example.InnerRecord)fieldValue; break;
default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Put()");
};
}
}
}
{code}
In this case the InnerRecord is referenced via "com.Example.InnerRecord", but it should be "Example.InnerRecord".
--
This message was sent by Atlassian Jira
(v8.3.4#803005)