public static Schema createAvroSchema( ResultSet resultSet, String avroSchemaNamespace, String connectionUrl, String avroDoc, boolean useLogicalTypes) throws SQLException { ResultSetMetaData meta = resultSet.getMetaData(); String tableName = "no_table_name"; if (meta.getColumnCount() > 0) { tableName = normalizeForAvro(meta.getTableName(1)); } SchemaBuilder.FieldAssembler<Schema> builder = SchemaBuilder.record(tableName) .namespace(avroSchemaNamespace) .doc(avroDoc) .prop("tableName", tableName) .prop("connectionUrl", connectionUrl) .fields(); return createAvroFields(meta, builder, useLogicalTypes).endRecord(); }
.doc("Schema generated by Kite").fields();
private static Schema schemaFor(StructType structType, String record, String namespace, int recordCount) { // Increment after using the recordCount record = (null == record) ? "record" + recordCount++ : record; LOG.debug("Converting {} to Avro Record schema [{}:{}]", structType, record, namespace); SchemaBuilder.RecordBuilder<Schema> schema = SchemaBuilder.record(record); if (null != namespace) { schema.namespace(namespace); } schema.doc("Auto-generated from Spark DataFrame"); SchemaBuilder.FieldAssembler<Schema> assembler = schema.fields(); StructField[] structFields = structType.fields(); for (StructField f : structFields) { assembler.name(f.name()).type(typeFor(f.dataType(), f.nullable(), recordCount)).noDefault(); } return assembler.endRecord(); }
public FieldAssembler<R> fields() { Schema record = Schema.createRecord(name(), doc(), space(), false); // place the record in the name context, fields yet to be set. completeSchema(record); return new FieldAssembler<R>( context(), names().namespace(record.getNamespace()), record); } }
public FieldAssembler<R> fields() { Schema record = Schema.createRecord(name(), doc(), space(), false); // place the record in the name context, fields yet to be set. completeSchema(record); return new FieldAssembler<R>( context(), names().namespace(record.getNamespace()), record); } }
public FieldAssembler<R> fields() { Schema record = Schema.createRecord(name(), doc(), space(), false); // place the record in the name context, fields yet to be set. completeSchema(record); return new FieldAssembler<>( context(), names().namespace(record.getNamespace()), record); } }
public FieldAssembler<R> fields() { Schema record = Schema.createRecord(name(), doc(), space(), false); // place the record in the name context, fields yet to be set. completeSchema(record); return new FieldAssembler<R>( context(), names().namespace(record.getNamespace()), record); } }