Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-2923

GenericDatum::logicalType() API should return the logical type corresponing to one of the constituent types of the union

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.10.0
    • 1.11.0
    • c++

    Description

      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.

      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
      }
      

      while logicalType api was like this:

      inline LogicalType GenericDatum::logicalType() const {
          return logicalType_;
      }
      

      it should also do the GenericUnion check

      Attachments

        Activity

          People

            yxu Yang Xu
            yxu Yang Xu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m