commonlib/src/main/java/com/streamsets/pipeline/lib/generator/avro/AvroSchemaGenerator.java
public static Schema buildSchema(Map<String, Schema> fields, Object... levels) {
    List<Schema.Field> recordFields = new ArrayList<>(fields.size());

    for (Map.Entry<String, Schema> entry : fields.entrySet()) {
      recordFields.add(new Schema.Field(
          entry.getKey(), entry.getValue(),
          null,   // Avro's Schema.Field constructor requires doc.
          entry.getValue().getJsonProp("default"))
      );
    }

    Schema recordSchema;
    if (levels.length == 0) {
      recordSchema = Schema.createRecord(schemaName, null, null, false);
    } else {
      LinkedList<String> lvl = (LinkedList<String>)levels[0];
      recordSchema = Schema.createRecord(joiner.join(lvl), null, null, false);
    }
    recordSchema.setFields(recordFields);
    return recordSchema;
  }
public static Schema buildSchema(Map<String, Schema> fields, Object... levels) {
    List<Schema.Field> recordFields = new ArrayList<>(fields.size());

    for (Map.Entry<String, Schema> entry : fields.entrySet()) {
      recordFields.add(new Schema.Field(
          entry.getKey(), entry.getValue(),
          null,   // Avro's Schema.Field constructor requires doc.
          entry.getValue().getJsonProp("default"))
      );
    }

    Schema recordSchema;
    if (levels.length == 0) {
      recordSchema = Schema.createRecord(schemaName, null, null, false);
    } else {
      LinkedList<String> lvl = (LinkedList<String>)levels[0];
      recordSchema = Schema.createRecord(joiner.join(lvl), null, null, false);
    }
    recordSchema.setFields(recordFields);
    return recordSchema;
  }
public static Schema buildSchema ( Map < String , Schema > fields , Object ... levels ) { List < Schema . Field > recordFields = new ArrayList <> ( fields . size ( ) ) ; for ( Map . Entry < String , Schema > entry : fields . entrySet ( ) ) { recordFields . add ( new Schema . Field ( entry . getKey ( ) , entry . getValue ( ) , null , // Avro's Schema.Field constructor requires doc. entry . getValue ( ) . getJsonProp ( "default" ) ) ) ; } Schema recordSchema ; if ( levels . length == 0 ) { recordSchema = Schema . createRecord ( schemaName , null , null , false ) ; } else { LinkedList < String > lvl = ( LinkedList < String > ) levels [ 0 ] ; recordSchema = Schema . createRecord ( joiner . join ( lvl ) , null , null , false ) ; } recordSchema . setFields ( recordFields ) ; return recordSchema ; }
Build a schema with type "record". This will be the top level schema and contains fields
Build a schema with type record . This will be the top level schema and contains fields