use of org.apache.gobblin.converter.avro.JsonElementConversionFactory.RecordConverter in project incubator-gobblin by apache.
the class JsonElementConversionFactoryTest method schemaWithRecordOfEnum.
@Test
public void schemaWithRecordOfEnum() throws Exception {
String testName = "schemaWithRecordOfEnum";
JsonObject schema = getSchemaData(testName).getAsJsonObject();
JsonObject expected = getExpectedSchema(testName).getAsJsonObject();
RecordConverter converter = new RecordConverter(new JsonSchema(schema), state, buildNamespace(state.getExtract().getNamespace(), "something"));
Assert.assertEquals(avroSchemaToJsonElement(converter), expected);
}
use of org.apache.gobblin.converter.avro.JsonElementConversionFactory.RecordConverter in project incubator-gobblin by apache.
the class JsonElementConversionFactoryTest method schemaWithRecordOfRecord.
@Test
public void schemaWithRecordOfRecord() throws Exception {
String testName = "schemaWithRecordOfRecord";
JsonObject schema = getSchemaData(testName).getAsJsonObject();
JsonObject expected = getExpectedSchema(testName).getAsJsonObject();
RecordConverter converter = new RecordConverter(new JsonSchema(schema), state, buildNamespace(state.getExtract().getNamespace(), "something"));
Assert.assertEquals(avroSchemaToJsonElement(converter), expected);
}
use of org.apache.gobblin.converter.avro.JsonElementConversionFactory.RecordConverter in project incubator-gobblin by apache.
the class JsonElementConversionFactoryTest method schemaWithRecord.
@Test
public void schemaWithRecord() throws DataConversionException, SchemaConversionException, UnsupportedDateTypeException {
String testName = "schemaWithRecord";
JsonObject schema = getSchemaData(testName).getAsJsonObject();
JsonObject expected = getExpectedSchema(testName).getAsJsonObject();
JsonSchema jsonSchema = new JsonSchema(schema);
jsonSchema.setColumnName("dummy1");
RecordConverter converter = new RecordConverter(jsonSchema, state, buildNamespace(state.getExtract().getNamespace(), "something"));
Assert.assertEquals(avroSchemaToJsonElement(converter), expected);
}
use of org.apache.gobblin.converter.avro.JsonElementConversionFactory.RecordConverter in project incubator-gobblin by apache.
the class JsonElementConversionFactoryTest method schemaWithMapValuesAsJsonArray.
@Test(expectedExceptions = IllegalStateException.class)
public void schemaWithMapValuesAsJsonArray() throws Exception {
String testName = "schemaWithMapValuesAsJsonArray";
JsonObject schema = getSchemaData(testName).getAsJsonObject();
new RecordConverter(new JsonSchema(schema), state, buildNamespace(state.getExtract().getNamespace(), "something"));
}
use of org.apache.gobblin.converter.avro.JsonElementConversionFactory.RecordConverter in project incubator-gobblin by apache.
the class JsonIntermediateToAvroConverter method convertSchema.
@Override
public Schema convertSchema(JsonArray schema, WorkUnitState workUnit) throws SchemaConversionException {
try {
JsonSchema jsonSchema = new JsonSchema(schema);
jsonSchema.setColumnName(workUnit.getExtract().getTable());
recordConverter = new RecordConverter(jsonSchema, workUnit, workUnit.getExtract().getNamespace());
} catch (UnsupportedDateTypeException e) {
throw new SchemaConversionException(e);
}
Schema recordSchema = recordConverter.schema();
if (workUnit.getPropAsBoolean(CONVERTER_AVRO_NULLIFY_FIELDS_ENABLED, DEFAULT_CONVERTER_AVRO_NULLIFY_FIELDS_ENABLED)) {
return this.generateSchemaWithNullifiedField(workUnit, recordSchema);
}
return recordSchema;
}
Aggregations