[ 
https://issues.apache.org/jira/browse/AVRO-2380?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17238979#comment-17238979
 ] 

William Maio edited comment on AVRO-2380 at 11/26/20, 12:26 AM:
----------------------------------------------------------------

[~harshvardhan.agrawal] isn't
{code:java}
"long"{code}
and 
{code:java}
{ "type" : "long", "logicalType" : "timestamp-micros" }{code}
conflicting? 

 
{code:java}
Unions may not contain more than one schema with the same type, except for the 
named types record, fixed and enum{code}
from [https://avro.apache.org/docs/current/spec.html]

 

[~lhopcroft] with different types of record of a union. I found out that you 
must have the records defined in advance before using it in a union. That might 
solve your issue?

 

 


was (Author: wmaiouiru):
[~harshvardhan.agrawal] isn't
`"long"`
 and 

`\{ "type" : "long", "logicalType" : "timestamp-micros" }`

conflicting? 

`Unions may not contain more than one schema with the same type, except for the 
named types record, fixed and enum` from 
[https://avro.apache.org/docs/current/spec.html]

 

[~lhopcroft] with different types of record of a union. I found out that you 
must have the records defined in advance before using it in a union. THat might 
solve your issue?

 

 

> Logical types are not supported when the actual datatype is also present in 
> Union
> ---------------------------------------------------------------------------------
>
>                 Key: AVRO-2380
>                 URL: https://issues.apache.org/jira/browse/AVRO-2380
>             Project: Apache Avro
>          Issue Type: Bug
>    Affects Versions: 1.8.2
>            Reporter: Harshvardhan Agrawal
>            Priority: Major
>
> {code:java}
> {
> "name" : "data",
> "type" : {
>  "type" : "map",
>  "values" : {
>   "type" : "array",
>   "items" : {
>    "type" : "map",
>    "values" : [ "string", "long", "null", "double", "float", "int", "boolean" 
> ]
>   }
>  }
> }{code}
> The above schema represents a Map<String, List<Map<String, Object>>> where 
> the values of the inner map could be any of the basic datatypes supported by 
> Avro.
> If we want the Map to support logical types such as timestamp for e.g.
> {code:java}
> {
> "name" : "data",
> "type" : {
>  "type" : "map",
>  "values" : {
>   "type" : "array",
>   "items" : {
>    "type" : "map",
>    "values" : [ "string", "long", "null", "double", "float", "int", "boolean",
>                  { "type" : "long", "logicalType" : "timestamp-micros" }]
>   }
>  }
> }{code}
> The schema parser fails with the following error:
>  
> {code:java}
> Exception in thread "main" org.apache.avro.AvroRuntimeException: Duplicate in 
> union:long at org.apache.avro.Schema$UnionSchema.<init>(Schema.java:854)
> at org.apache.avro.Schema.parse(Schema.java:1341)
> at org.apache.avro.Schema.parse(Schema.java:1311)
> at org.apache.avro.Schema.parse(Schema.java:1306)
> at org.apache.avro.Schema.parse(Schema.java:1311)
> at org.apache.avro.Schema.parse(Schema.java:1269)
> at org.apache.avro.Schema$Parser.parse(Schema.java:1032)
> at org.apache.avro.Schema$Parser.parse(Schema.java:1020)
> {code}
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to