How to create object that contains array of string in avro schema?
Asked Answered
R

1

12

What is the correct way to create avro schema for object with array of strings?

I am trying to create avro schema to object that have array of strings according to official documenation? but I get error.

https://avro.apache.org/docs/1.8.1/spec.html

[ERROR] Failed to execute goal org.apache.avro:avro-maven-plugin:1.8.2:schema (default) on project email: Execution default of goal org.apache.avro:avro-maven-plugin:1.8.2:schema failed: "array" is not a defined name. The type of the "parameters" field must be a defined name or a {"type": ...} expression. -> [Help 1]

Why my schema is inccorect?

[
  {
    "type": "record",
    "namespace": "com.example",
    "name": "Topic",
    "fields": [
         { "name": "subject", "type": "string" },
         { "name": "parameters", "type": "array", "items": "string" }
    ]    
  }

]
Retentive answered 8/1, 2019 at 14:27 Comment(0)
O
41

Think this should work:

{ 
  "name":"parameters",  
  "type": { 
      "type": "array",
      "items": "string"
   } 
} 
Olimpia answered 8/1, 2019 at 14:36 Comment(1)
Here is the link to accepting. Simply click the check mark next to the answer.Olimpia

© 2022 - 2024 — McMap. All rights reserved.