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

ASF subversion and git services commented on AVRO-2923:
-------------------------------------------------------

Commit 0a5d4c99c21d588d83e2eca2e658b0533c65d391 in avro's branch 
refs/heads/master from Yang
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=0a5d4c9 ]

AVRO-2923: GenericDatum::logicalType() api should return correct type with 
union (#949)

* AVRO-2923: logicalType() api should return correct type with union

logicalType() should behave like type() to return correct logical type 
corresponing to one of the constituent types of the union

* adding test

> GenericDatum::logicalType() API should return the logical type corresponing 
> to one of the constituent types of the union
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: AVRO-2923
>                 URL: https://issues.apache.org/jira/browse/AVRO-2923
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: c++
>    Affects Versions: 1.10.0
>            Reporter: Yang Xu
>            Assignee: Yang Xu
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.11.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> According to the avro document, GenericDatum::logicalType() API should behave 
> Just like GenericDatum::type() or GenericDatum::value() APIs to return the 
> logical type corresponing to one of the constituent types of the union When 
> it was a Union type.
> {code:cpp}
> inline Type GenericDatum::type() const {
>     return (type_ == AVRO_UNION) ?
> #if __cplusplus >= 201703L
>         std::any_cast<GenericUnion>(&value_)->datum().type() :
> #else
>         boost::any_cast<GenericUnion>(&value_)->datum().type() :
> #endif
>         type_;
> }
> template<typename T> T& GenericDatum::value() {
>     return (type_ == AVRO_UNION) ?
> #if __cplusplus >= 201703L
>         std::any_cast<GenericUnion>(&value_)->datum().value<T>() :
>         *std::any_cast<T>(&value_);
> #else
>         boost::any_cast<GenericUnion>(&value_)->datum().value<T>() :
>         *boost::any_cast<T>(&value_);
> #endif
> }
> {code}
> while logicalType api was like this: 
> {code:cpp}
> inline LogicalType GenericDatum::logicalType() const {
>     return logicalType_;
> }
> {code}
> it should also do the GenericUnion check



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

Reply via email to