Source:
public Schema getSchema(HdfsSinkConnectorConfig conf, Path path) { try { log.info("Opening ORC record reader for: {}", path); ReaderOptions readerOptions = new ReaderOptions(conf.getHadoopConfiguration()); Reader reader = OrcFile.createReader(path, readerOptions); if (reader.getObjectInspector().getCategory() == ObjectInspector.Category.STRUCT) { SchemaBuilder schemaBuilder = SchemaBuilder.struct().name("record").version(1); StructObjectInspector objectInspector = (StructObjectInspector) reader.getObjectInspector(); for (StructField schema : objectInspector.getAllStructFieldRefs()) { ObjectInspector fieldObjectInspector = schema.getFieldObjectInspector(); String typeName = fieldObjectInspector.getTypeName(); Schema.Type schemaType; switch (fieldObjectInspector.getCategory()) { case PRIMITIVE: PrimitiveTypeEntry typeEntry = PrimitiveObjectInspectorUtils .getTypeEntryFromTypeName(typeName); if (java.sql.Date.class.isAssignableFrom(typeEntry.primitiveJavaClass)) { schemaType = Date.SCHEMA.type(); } else if (java.sql.Timestamp.class.isAssignableFrom(typeEntry.primitiveJavaClass)) { schemaType = Timestamp.SCHEMA.type(); } else { schemaType = ConnectSchema.schemaType(typeEntry.primitiveJavaClass); } break; case LIST: schemaType = Schema.Type.ARRAY; break; case MAP: schemaType = Schema.Type.MAP; break; default: throw new DataException("Unknown type " + fieldObjectInspector.getCategory().name()); } schemaBuilder.field(schema.getFieldName(), SchemaBuilder.type(schemaType).build()); } return schemaBuilder.build(); } else { throw new ConnectException( "Top level type must be of type STRUCT, but was " + reader.getObjectInspector().getCategory().name() ); } } catch (IOException e) { throw new ConnectException("Failed to get schema for file " + path, e); } }

Target:
public Schema getSchema(HdfsSinkConnectorConfig conf, Path path) { try { log.debug("Opening ORC record reader for: {}", path); ReaderOptions readerOptions = new ReaderOptions(conf.getHadoopConfiguration()); Reader reader = OrcFile.createReader(path, readerOptions); if (reader.getObjectInspector().getCategory() == ObjectInspector.Category.STRUCT) { SchemaBuilder schemaBuilder = SchemaBuilder.struct().name("record").version(1); StructObjectInspector objectInspector = (StructObjectInspector) reader.getObjectInspector(); for (StructField schema : objectInspector.getAllStructFieldRefs()) { ObjectInspector fieldObjectInspector = schema.getFieldObjectInspector(); String typeName = fieldObjectInspector.getTypeName(); Schema.Type schemaType; switch (fieldObjectInspector.getCategory()) { case PRIMITIVE: PrimitiveTypeEntry typeEntry = PrimitiveObjectInspectorUtils .getTypeEntryFromTypeName(typeName); if (java.sql.Date.class.isAssignableFrom(typeEntry.primitiveJavaClass)) { schemaType = Date.SCHEMA.type(); } else if (java.sql.Timestamp.class.isAssignableFrom(typeEntry.primitiveJavaClass)) { schemaType = Timestamp.SCHEMA.type(); } else { schemaType = ConnectSchema.schemaType(typeEntry.primitiveJavaClass); } break; case LIST: schemaType = Schema.Type.ARRAY; break; case MAP: schemaType = Schema.Type.MAP; break; default: throw new DataException("Unknown type " + fieldObjectInspector.getCategory().name()); } schemaBuilder.field(schema.getFieldName(), SchemaBuilder.type(schemaType).build()); } return schemaBuilder.build(); } else { throw new ConnectException( "Top level type must be of type STRUCT, but was " + reader.getObjectInspector().getCategory().name() ); } } catch (IOException e) { throw new ConnectException("Failed to get schema for file " + path, e); } }