I'm trying to translate a schema that I have in Spark which is defined for
Parquet, and I would like to use it within Avro too.

  StructField("one_level", StructType(List(StructField(
    "inner_level",
    MapType(
      StringType,
      StructType(
        List(
          StructField("field1", StringType),
          StructField("field2", ArrayType(StringType))
        )
      )
    )
  )
)), nullable = false)

However, in Avro I haven't seen any examples of Maps containing Record type
objects...

Tried a sample input with an online Avro schema generator, taking this
input.

{
"one_level": {
    "inner_level": {
        "sample1": {
            "field1": "sample",
            "field2": ["a", "b"],
        },
        "sample2": {
            "field1": "sample2",
            "field2": ["a", "b"]
        }
    }
}

}

It prompts this output.

    {
  "name": "MyClass",
  "type": "record",
  "namespace": "com.acme.avro",
  "fields": [
    {
      "name": "one_level",
      "type": {
        "name": "one_level",
        "type": "record",
        "fields": [
          {
            "name": "inner_level",
            "type": {
              "name": "inner_level",
              "type": "record",
              "fields": [
                {
                  "name": "sample1",
                  "type": {
                    "name": "sample1",
                    "type": "record",
                    "fields": [
                      {
                        "name": "field1",
                        "type": "string"
                      },
                      {
                        "name": "field2",
                        "type": {
                          "type": "array",
                          "items": "string"
                        }
                      }
                    ]
                  }
                },
                {
                  "name": "sample2",
                  "type": {
                    "name": "sample2",
                    "type": "record",
                    "fields": [
                      {
                        "name": "field1",
                        "type": "string"
                      },
                      {
                        "name": "field2",
                        "type": {
                          "type": "array",
                          "items": "string"
                        }
                      }
                    ]
                  }
                }
              ]
            }
          }
        ]
      }
    }
  ]
}

Which isn't absolutely what I'm looking for. Is it possible to define such
schema in Avro?

Reply via email to