Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-43361

Allow deserializing protobuf enum fields as integers

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.4.0
    • 3.5.0
    • Protobuf
    • None

    Description

      When deserializing protobuf enum fields, the spark-protobuf library will deserialize them as string values based on the enum name in the proto. E.g. 

      message Person {
        enum Job {
          NOTHING = 0;
          ENGINEER = 1;
          DOCTOR = 2;
        }
        Job job = 1;
      }

      And we have a message like

      Person(job=ENGINEER)

      Then the deserialized value will be:

      {"job": "ENGINEER"}

      However it can be useful to deserialize the enum integer value rather than the name (and this option exists in other major libraries). So, namely:

      {"job": 1}

       

      Examples in other libraries:

      I propose extending spark-protobuf to add this functionality.

      Attachments

        Activity

          People

            justaparth Parth Upadhyay
            justaparth Parth Upadhyay
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: