Hi gang,

I'm trying to build a JSON schema with a custom type as the field instead
of just a String.  Is "java-class" supposed to work in that use case?  I
can't seem to make any progress.

Example schema (Foo.avsc):

{
    "namespace" : "com.example",
    "type" : "record",
    "name" : "Foo",
    "fields" : [
        { "name" : "batchId", "type" : "long" },
        { "name" : "timestamp", "type" : "string", "java-class" :
"com.example.Timestamp" }
    ]
}

The Timestamp class has a public constructor which takes a single String
argument.  I even tried annotating it with @Stringable.  However, the
generated java class always uses String, not my custom type.

$ java -jar ~/Downloads/avro-tools-1.7.6.jar compile -string schema
src/main/avro/Foo.avsc /tmp/foo
>From the generated .java file

...

  /**

   * All-args constructor.

   */

  public Foo(java.lang.Long batchId, java.lang.String timestamp) {

    this.batchId = batchId;

    this.timestamp = timestamp;

  }

...

Any help appreciated,

- Ian.

Reply via email to