@Override public Builder withName(String name) { builder.name(name); return this; }
public static Schema getSchemaFromType(final Type type, final String name, final String doc) { final SchemaBuilder schema = typeToSchema.getOrDefault(type, () -> handleParametrizedType(type)).get(); schema.name(name); schema.doc(doc); return schema.build(); }
/** * Returns a {@link SchemaBuilder} for a {@link ZonedTime}. You can use the resulting SchemaBuilder * to set additional schema settings such as required/optional, default value, and documentation. * * @return the schema builder */ public static SchemaBuilder builder() { return SchemaBuilder.string() .name(SCHEMA_NAME) .version(1); }
/** * Returns a {@link SchemaBuilder} for a Uuid field. You can use the resulting SchemaBuilder * to set additional schema settings such as required/optional, default value, and documentation. * * @return the schema builder */ public static SchemaBuilder builder() { return SchemaBuilder.string() .name(LOGICAL_NAME) .version(1); }
/** * Returns a {@link SchemaBuilder} for an XML field. You can use the resulting SchemaBuilder * to set additional schema settings such as required/optional, default value, and documentation. * * @return the schema builder */ public static SchemaBuilder builder() { return SchemaBuilder.string() .name(LOGICAL_NAME) .version(1); }
/** * Returns a {@link SchemaBuilder} for a JSON field. You can use the resulting SchemaBuilder * to set additional schema settings such as required/optional, default value, and documentation. * * @return the schema builder */ public static SchemaBuilder builder() { return SchemaBuilder.string() .name(LOGICAL_NAME) .version(1); }
/** * Returns a {@link SchemaBuilder} for a {@link ZonedTimestamp}. You can use the resulting SchemaBuilder * to set additional schema settings such as required/optional, default value, and documentation. * * @return the schema builder */ public static SchemaBuilder builder() { return SchemaBuilder.string() .name(SCHEMA_NAME) .version(1); }
/** * Returns a {@link SchemaBuilder} for a {@link MicroDuration}. The resulting schema will describe a field * with the {@value #SCHEMA_NAME} as the {@link Schema#name() name} and {@link SchemaBuilder#float64()} FLOAT64} for the literal * type storing the number of <em>microseconds</em> for that duration. * <p> * You can use the resulting SchemaBuilder to set or override additional schema settings such as required/optional, default * value, and documentation. * * @return the schema builder */ public static SchemaBuilder builder() { return SchemaBuilder.float64() .name(SCHEMA_NAME) .version(1); }
/** * Returns a {@link SchemaBuilder} for a {@link Date}. The builder will create a schema that describes a field * with the {@value #SCHEMA_NAME} as the {@link Schema#name() name} and {@link SchemaBuilder#int32() INT32} for the literal * type storing the number of <em>days</em> since January 1, 1970, at 00:00:00Z. * <p> * You can use the resulting SchemaBuilder to set or override additional schema settings such as required/optional, default * value, and documentation. * * @return the schema builder */ public static SchemaBuilder builder() { return SchemaBuilder.int32() .name(SCHEMA_NAME) .version(1); }
/** * Returns a {@link SchemaBuilder} for a Bits. You can use the resulting SchemaBuilder * to set additional schema settings such as required/optional, default value, and documentation. * * @param length maximum the number of bits in the set * @return the schema builder */ public static SchemaBuilder builder(int length) { return SchemaBuilder.bytes() .name(LOGICAL_NAME) .parameter(LENGTH_FIELD, Integer.toString(length)) .version(1); }
/** * Returns a {@link SchemaBuilder} for an enumeration. You can use the resulting SchemaBuilder * to set additional schema settings such as required/optional, default value, and documentation. * * @param allowedValues the comma separated list of allowed values; may not be null * @return the schema builder */ public static SchemaBuilder builder(String allowedValues) { return SchemaBuilder.string() .name(LOGICAL_NAME) .parameter(VALUES_FIELD, allowedValues) .version(1); }
/** * Returns a {@link SchemaBuilder} for a set of enumerated values. You can use the resulting SchemaBuilder * to set additional schema settings such as required/optional, default value, and documentation. * * @param allowedValues the comma separated list of allowed values; may not be null * @return the schema builder */ public static SchemaBuilder builder(String allowedValues) { return SchemaBuilder.string() .name(LOGICAL_NAME) .parameter(VALUES_FIELD, allowedValues) .version(1); }
@Before public void setup() throws Exception { builder = SchemaBuilder.struct().name("array"); }
/** * Returns a {@link SchemaBuilder} for a Geography field. You can use the resulting SchemaBuilder * to set additional schema settings such as required/optional, default value, and documentation. * * @return the schema builder */ public static SchemaBuilder builder() { return SchemaBuilder.struct() .name(LOGICAL_NAME) .version(1) .doc("Geography") .field(WKB_FIELD, Schema.BYTES_SCHEMA) .field(SRID_FIELD, Schema.OPTIONAL_INT32_SCHEMA); } }
public static Schema buildSchemaWithAlias(final Schema schema, final String alias) { final SchemaBuilder newSchema = SchemaBuilder.struct().name(schema.name()); for (final Field field : schema.fields()) { newSchema.field((alias + "." + field.name()), field.schema()); } return newSchema; }
private SourceRecord createUnknownRecord() { final Schema recordSchema = SchemaBuilder.struct().name("unknown") .field("id", SchemaBuilder.int8()) .build(); final Struct before = new Struct(recordSchema); before.put("id", (byte)1); return new SourceRecord(new HashMap<>(), new HashMap<>(), "dummy", recordSchema, before); }
private static List<FieldInfo> buildTestSchema(final int size) { final SchemaBuilder dataSourceBuilder = SchemaBuilder.struct().name("TestSchema"); for (int i = 0; i < size; i++) { dataSourceBuilder.field("f_" + i, SchemaUtil.getTypeSchema("STRING")); } return EntityUtil.buildSourceSchemaEntity(dataSourceBuilder.build()); } }
@Before public void setup() throws Exception { record = getFile("restaurants5.json"); val = BsonDocument.parse(record); builder = SchemaBuilder.struct().name("pub"); converter = new MongoDataConverter(ArrayEncoding.ARRAY); }
@Before public void setup() throws Exception { record = getFile("complex_objects.json"); val = BsonDocument.parse(record); builder = SchemaBuilder.struct().name("complex"); avroData = new AvroData(100); converter = new MongoDataConverter(ArrayEncoding.ARRAY); }
@Test public void shouldCreateSchemaForEmptyArrayEncodingArray() throws Exception { final BsonDocument val = BsonDocument.parse(EMPTY_ARRAY); final MongoDataConverter arrayConverter = new MongoDataConverter(ArrayEncoding.ARRAY); for (Entry<String, BsonValue> entry : val.entrySet()) { arrayConverter.addFieldSchema(entry, builder); } final Schema arraySchema = builder.build(); assertThat(arraySchema) .isEqualTo( SchemaBuilder.struct().name("array") .field("_id", Schema.OPTIONAL_INT32_SCHEMA) .field("f", SchemaBuilder.array(Schema.OPTIONAL_STRING_SCHEMA).optional().build()) .build()); }