You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Yang Xu (Jira)" <ji...@apache.org> on 2021/03/12 01:49:00 UTC

[jira] [Commented] (AVRO-2923) GenericDatum::logicalType() API should return the logical type corresponing to one of the constituent types of the union

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

Yang Xu commented on AVRO-2923:
-------------------------------

Can we get this one fixed, it should be a trivial fix and I have a PR ready in github: https://github.com/apache/avro/pull/949

We are working on an avro library upgrade to support logical type and find this problem.

> 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
>            Priority: Minor
>
> 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)