2015-03-02 5 views
2

Я хотел бы знать, как будет схема avro для этого документа в json.Как создать схему Avro?

tweet.json:

{ "_id" : { "$oid" : "54d148b471eb130b1e8b4567" }, "nome" : "Marco Correia", "tweet" : "This and a simple tweet", "datahora" : "Tue Feb 03 22:15:54 +0000 2015" } 

Я делаю такую ​​схему, но дает ошибку.

schema.avsc:

{ 
    "type" : "record", 
    "name" : "twitter_schema", 
    "namespace" : "com.miguno.avro", 
    "fields" : [ 
    { 
     "name" : "_id", "type": "array","items": "bytes" 
    }, 

    { "name" : "nome","type" : "string","doc" : "Name of the user account on Twitter.com" }, 
    { "name" : "tweet", "type" : "string","doc" : "The content of the user's Twitter message" }, 
    { "name" : "datahora", "type" : "string","doc" : "Unix epoch time in seconds"} 

    ], 
    "doc:" : "A basic schema for storing Twitter messages" 
} 

ответ

0

Следующая схема должна работать

{ 
    "type" : "record", 
    "name" : "twitter_schema", 
    "namespace" : "com.miguno.avro", 
    "fields" : [ 

     {"name": "_id", "type": 
      { 
       "type" : "record", "name" : "Id", "namespace" : "com.miguno.avro", 
       "fields" : [ 
        { "name" : "oid","type" : "string"} 
       ] 
      } 
     }, 
     { "name" : "nome","type" : "string","doc" : "Name of the user account on Twitter.com" }, 
     { "name" : "tweet", "type" : "string","doc" : "The content of the user's Twitter message" }, 
     { "name" : "datahora", "type" : "string","doc" : "Unix epoch time in seconds"} 

    ] 
} 
Смежные вопросы