Esempio n. 1
0
 @Test
 public void test_getOrcField_enum() throws Exception {
   final SchemaBuilder.FieldAssembler<Schema> builder =
       SchemaBuilder.record("testRecord").namespace("any.data").fields();
   builder.name("enumField").type().enumeration("enum").symbols("a", "b", "c").enumDefault("a");
   Schema testSchema = builder.endRecord();
   TypeInfo orcType = NiFiOrcUtils.getOrcField(testSchema.getField("enumField").schema());
   assertEquals(TypeInfoCreator.createString(), orcType);
 }
Esempio n. 2
0
 @Test
 public void test_getOrcField_array() throws Exception {
   final SchemaBuilder.FieldAssembler<Schema> builder =
       SchemaBuilder.record("testRecord").namespace("any.data").fields();
   builder.name("array").type().array().items().longType().noDefault();
   Schema testSchema = builder.endRecord();
   TypeInfo orcType = NiFiOrcUtils.getOrcField(testSchema.getField("array").schema());
   assertEquals(TypeInfoFactory.getListTypeInfo(TypeInfoCreator.createLong()), orcType);
 }
Esempio n. 3
0
 @Test
 public void test_getOrcField_map() throws Exception {
   final SchemaBuilder.FieldAssembler<Schema> builder =
       SchemaBuilder.record("testRecord").namespace("any.data").fields();
   builder.name("map").type().map().values().doubleType().noDefault();
   Schema testSchema = builder.endRecord();
   TypeInfo orcType = NiFiOrcUtils.getOrcField(testSchema.getField("map").schema());
   assertEquals(
       TypeInfoFactory.getMapTypeInfo(
           TypeInfoCreator.createString(), TypeInfoCreator.createDouble()),
       orcType);
 }
Esempio n. 4
0
 @Test
 public void test_getOrcField_union() throws Exception {
   final SchemaBuilder.FieldAssembler<Schema> builder =
       SchemaBuilder.record("testRecord").namespace("any.data").fields();
   builder.name("union").type().unionOf().intType().and().booleanType().endUnion().noDefault();
   Schema testSchema = builder.endRecord();
   TypeInfo orcType = NiFiOrcUtils.getOrcField(testSchema.getField("union").schema());
   assertEquals(
       TypeInfoFactory.getUnionTypeInfo(
           Arrays.asList(TypeInfoCreator.createInt(), TypeInfoCreator.createBoolean())),
       orcType);
 }
Esempio n. 5
0
 public static Schema buildPrimitiveAvroSchema() {
   // Build a fake Avro record with all primitive types
   final SchemaBuilder.FieldAssembler<Schema> builder =
       SchemaBuilder.record("test.record").namespace("any.data").fields();
   builder.name("int").type().intType().noDefault();
   builder.name("long").type().longType().longDefault(1L);
   builder.name("boolean").type().booleanType().booleanDefault(true);
   builder.name("float").type().floatType().floatDefault(0.0f);
   builder.name("double").type().doubleType().doubleDefault(0.0);
   builder.name("bytes").type().bytesType().noDefault();
   builder.name("string").type().stringType().stringDefault("default");
   return builder.endRecord();
 }
Esempio n. 6
0
 @Test
 public void test_getOrcField_record() throws Exception {
   final SchemaBuilder.FieldAssembler<Schema> builder =
       SchemaBuilder.record("testRecord").namespace("any.data").fields();
   builder.name("int").type().intType().noDefault();
   builder.name("long").type().longType().longDefault(1L);
   builder.name("array").type().array().items().stringType().noDefault();
   Schema testSchema = builder.endRecord();
   TypeInfo orcType = NiFiOrcUtils.getOrcField(testSchema);
   assertEquals(
       TypeInfoFactory.getStructTypeInfo(
           Arrays.asList("int", "long", "array"),
           Arrays.asList(
               TypeInfoCreator.createInt(),
               TypeInfoCreator.createLong(),
               TypeInfoFactory.getListTypeInfo(TypeInfoCreator.createString()))),
       orcType);
 }
Esempio n. 7
0
 public static Schema buildComplexAvroSchema() {
   // Build a fake Avro record with nested  types
   final SchemaBuilder.FieldAssembler<Schema> builder =
       SchemaBuilder.record("complex.record").namespace("any.data").fields();
   builder.name("myInt").type().unionOf().nullType().and().intType().endUnion().nullDefault();
   builder.name("myMap").type().map().values().doubleType().noDefault();
   builder
       .name("myEnum")
       .type()
       .enumeration("myEnum")
       .symbols("ABC", "DEF", "XYZ")
       .enumDefault("ABC");
   builder
       .name("myLongOrFloat")
       .type()
       .unionOf()
       .longType()
       .and()
       .floatType()
       .endUnion()
       .noDefault();
   builder.name("myIntList").type().array().items().intType().noDefault();
   return builder.endRecord();
 }