Search code examples
protocol-buffersavro

Does avro support numeric constants for enum values, similar to protocol buffers enums?


In Protobuf, I can use numeric values for enum constants.

  enum StatusEnum {
    UNKNOWN = 0;
    STARTED = 1;
    STOPPED = 2;
  }

Does avro support numeric values for enum constants in a similar way?


Solution

  • In the binary format an enum is encoded as the zero based position of the symbol in the symbol list, but any library you are using will figure out the actual symbol name and return that rather than the index number.

    So no, avro doesn't support defining what numeric value the symbol will encode to.

    Is there something you are trying to do with the numeric value?