@Test public void testIcebergObjectInspector() { ObjectInspector oi = IcebergObjectInspector.create(schema); Assert.assertNotNull(oi); Assert.assertEquals(ObjectInspector.Category.STRUCT, oi.getCategory()); StructObjectInspector soi = (StructObjectInspector) oi; StructField binaryField = soi.getStructFieldRef("binary_field"); Assert.assertEquals(1, binaryField.getFieldID()); Assert.assertEquals("binary_field", binaryField.getFieldName()); Assert.assertEquals("binary comment", binaryField.getFieldComment()); Assert.assertEquals(IcebergBinaryObjectInspector.byteBuffer(), binaryField.getFieldObjectInspector()); StructField booleanField = soi.getStructFieldRef("boolean_field"); Assert.assertEquals(2, booleanField.getFieldID()); Assert.assertEquals("boolean_field", booleanField.getFieldName()); Assert.assertEquals("boolean comment", booleanField.getFieldComment()); Assert.assertEquals(getPrimitiveObjectInspector(boolean.class), booleanField.getFieldObjectInspector()); StructField dateField = soi.getStructFieldRef("date_field"); Assert.assertEquals(3, dateField.getFieldID()); Assert.assertEquals("date_field", dateField.getFieldName()); Assert.assertEquals("date comment", dateField.getFieldComment()); Assert.assertEquals(IcebergDateObjectInspector.get(), dateField.getFieldObjectInspector()); StructField decimalField = soi.getStructFieldRef("decimal_field"); Assert.assertEquals(4, decimalField.getFieldID()); Assert.assertEquals("decimal_field", decimalField.getFieldName()); Assert.assertEquals("decimal comment", decimalField.getFieldComment()); Assert.assertEquals(IcebergDecimalObjectInspector.get(38, 18), decimalField.getFieldObjectInspector()); StructField doubleField = soi.getStructFieldRef("double_field"); Assert.assertEquals(5, doubleField.getFieldID()); Assert.assertEquals("double_field", doubleField.getFieldName()); Assert.assertEquals("double comment", doubleField.getFieldComment()); Assert.assertEquals(getPrimitiveObjectInspector(double.class), doubleField.getFieldObjectInspector()); StructField fixedField = soi.getStructFieldRef("fixed_field"); Assert.assertEquals(6, fixedField.getFieldID()); Assert.assertEquals("fixed_field", fixedField.getFieldName()); Assert.assertEquals("fixed comment", fixedField.getFieldComment()); Assert.assertEquals(IcebergBinaryObjectInspector.byteArray(), fixedField.getFieldObjectInspector()); StructField floatField = soi.getStructFieldRef("float_field"); Assert.assertEquals(7, floatField.getFieldID()); Assert.assertEquals("float_field", floatField.getFieldName()); Assert.assertEquals("float comment", floatField.getFieldComment()); Assert.assertEquals(getPrimitiveObjectInspector(float.class), floatField.getFieldObjectInspector()); StructField integerField = soi.getStructFieldRef("integer_field"); Assert.assertEquals(8, integerField.getFieldID()); Assert.assertEquals("integer_field", integerField.getFieldName()); Assert.assertEquals("integer comment", integerField.getFieldComment()); Assert.assertEquals(getPrimitiveObjectInspector(int.class), integerField.getFieldObjectInspector()); StructField longField = soi.getStructFieldRef("long_field"); Assert.assertEquals(9, longField.getFieldID()); Assert.assertEquals("long_field", longField.getFieldName()); Assert.assertEquals("long comment", longField.getFieldComment()); Assert.assertEquals(getPrimitiveObjectInspector(long.class), longField.getFieldObjectInspector()); StructField stringField = soi.getStructFieldRef("string_field"); Assert.assertEquals(10, stringField.getFieldID()); Assert.assertEquals("string_field", stringField.getFieldName()); Assert.assertEquals("string comment", stringField.getFieldComment()); Assert.assertEquals(getPrimitiveObjectInspector(String.class), stringField.getFieldObjectInspector()); StructField timestampField = soi.getStructFieldRef("timestamp_field"); Assert.assertEquals(11, timestampField.getFieldID()); Assert.assertEquals("timestamp_field", timestampField.getFieldName()); Assert.assertEquals("timestamp comment", timestampField.getFieldComment()); Assert.assertEquals(IcebergTimestampObjectInspector.get(false), timestampField.getFieldObjectInspector()); StructField timestampTzField = soi.getStructFieldRef("timestamptz_field"); Assert.assertEquals(12, timestampTzField.getFieldID()); Assert.assertEquals("timestamptz_field", timestampTzField.getFieldName()); Assert.assertEquals("timestamptz comment", timestampTzField.getFieldComment()); Assert.assertEquals(IcebergTimestampObjectInspector.get(true), timestampTzField.getFieldObjectInspector()); StructField uuidField = soi.getStructFieldRef("uuid_field"); Assert.assertEquals(13, uuidField.getFieldID()); Assert.assertEquals("uuid_field", uuidField.getFieldName()); Assert.assertEquals("uuid comment", uuidField.getFieldComment()); Assert.assertEquals(getPrimitiveObjectInspector(String.class), uuidField.getFieldObjectInspector()); StructField listField = soi.getStructFieldRef("list_field"); Assert.assertEquals(14, listField.getFieldID()); Assert.assertEquals("list_field", listField.getFieldName()); Assert.assertEquals("list comment", listField.getFieldComment()); Assert.assertEquals(getListObjectInspector(String.class), listField.getFieldObjectInspector()); StructField mapField = soi.getStructFieldRef("map_field"); Assert.assertEquals(16, mapField.getFieldID()); Assert.assertEquals("map_field", mapField.getFieldName()); Assert.assertEquals("map comment", mapField.getFieldComment()); Assert.assertEquals(getMapObjectInspector(String.class, int.class), mapField.getFieldObjectInspector()); StructField structField = soi.getStructFieldRef("struct_field"); Assert.assertEquals(19, structField.getFieldID()); Assert.assertEquals("struct_field", structField.getFieldName()); Assert.assertEquals("struct comment", structField.getFieldComment()); ObjectInspector expectedObjectInspector = new IcebergRecordObjectInspector( (Types.StructType) schema.findType(19), ImmutableList.of(getPrimitiveObjectInspector(String.class))); Assert.assertEquals(expectedObjectInspector, structField.getFieldObjectInspector()); }
public static ObjectInspector create(@Nullable Schema schema) { if (schema == null) { return IcebergRecordObjectInspector.empty(); } return TypeUtil.visit(schema, new IcebergObjectInspector()); }
IcebergObjectInspector extends TypeUtil.SchemaVisitor<ObjectInspector> { public static ObjectInspector create(@Nullable Schema schema) { if (schema == null) { return IcebergRecordObjectInspector.empty(); } return TypeUtil.visit(schema, new IcebergObjectInspector()); } }
IcebergObjectInspector extends TypeUtil.SchemaVisitor<ObjectInspector> { public static ObjectInspector create(@Nullable Schema schema) { if (schema == null) { return IcebergRecordObjectInspector.empty(); } return TypeUtil.visit(schema, new IcebergObjectInspector()); }  }
IcebergObjectInspector extends TypeUtil.SchemaVisitor<ObjectInspector> { public static ObjectInspector create(@Nullable Schema schema) { if (schema == null) { return IcebergRecordObjectInspector.empty(); } return TypeUtil.visit(schema, new IcebergObjectInspector()); }  static ObjectInspector create(@Nullable Schema schema); static ObjectInspector create(Types.NestedField... fields); @Override ObjectInspector field(Types.NestedField field, ObjectInspector fieldObjectInspector); @Override ObjectInspector list(Types.ListType listTypeInfo, ObjectInspector listObjectInspector); @Override ObjectInspector map(Types.MapType mapType,
                             ObjectInspector keyObjectInspector, ObjectInspector valueObjectInspector); @Override ObjectInspector primitive(Type.PrimitiveType primitiveType); @Override ObjectInspector schema(Schema schema, ObjectInspector structObjectInspector); @Override ObjectInspector struct(Types.StructType structType, List<ObjectInspector> fieldObjectInspectors); }
IcebergObjectInspector extends TypeUtil.SchemaVisitor<ObjectInspector> { public static ObjectInspector create(@Nullable Schema schema) { if (schema == null) { return IcebergRecordObjectInspector.empty(); } return TypeUtil.visit(schema, new IcebergObjectInspector()); }  static ObjectInspector create(@Nullable Schema schema); static ObjectInspector create(Types.NestedField... fields); @Override ObjectInspector field(Types.NestedField field, ObjectInspector fieldObjectInspector); @Override ObjectInspector list(Types.ListType listTypeInfo, ObjectInspector listObjectInspector); @Override ObjectInspector map(Types.MapType mapType,
                             ObjectInspector keyObjectInspector, ObjectInspector valueObjectInspector); @Override ObjectInspector primitive(Type.PrimitiveType primitiveType); @Override ObjectInspector schema(Schema schema, ObjectInspector structObjectInspector); @Override ObjectInspector struct(Types.StructType structType, List<ObjectInspector> fieldObjectInspectors);  }