private void setColumnsIfPossible(WorkUnitState state) throws SerDeException { AvroObjectInspectorGenerator aoig = new AvroObjectInspectorGenerator( AvroSerdeUtils.determineSchemaOrReturnErrorSchema(state.getProperties())); List<String> columnNames = aoig.getColumnNames(); List<TypeInfo> columnTypes = aoig.getColumnTypes(); state.setProp(IOConstants.COLUMNS, StringUtils.join(columnNames, ",")); state.setProp(IOConstants.COLUMNS_TYPES, StringUtils.join(columnTypes, ",")); }
@Override public void initialize(Configuration configuration, Properties properties) throws SerDeException { // Reset member variables so we don't get in a half-constructed state if(schema != null) LOG.info("Resetting already initialized AvroSerDe"); schema = null; oi = null; columnNames = null; columnTypes = null; schema = AvroSerdeUtils.determineSchemaOrReturnErrorSchema(properties); if(configuration == null) { LOG.info("Configuration null, not inserting schema"); } else { // force output files to have a .avro extension configuration.set("hive.output.file.extension", ".avro"); configuration.set(AvroSerdeUtils.AVRO_SERDE_SCHEMA, schema.toString(false)); } badSchema = schema.equals(SchemaResolutionProblem.SIGNAL_BAD_SCHEMA); AvroObjectInspectorGenerator aoig = new AvroObjectInspectorGenerator(schema); this.columnNames = aoig.getColumnNames(); this.columnTypes = aoig.getColumnTypes(); this.oi = aoig.getObjectInspector(); }
private void setColumnsIfPossible(WorkUnitState state) throws SerDeException { AvroObjectInspectorGenerator aoig = new AvroObjectInspectorGenerator( AvroSerdeUtils.determineSchemaOrReturnErrorSchema(state.getProperties())); List<String> columnNames = aoig.getColumnNames(); List<TypeInfo> columnTypes = aoig.getColumnTypes(); state.setProp(IOConstants.COLUMNS, StringUtils.join(columnNames, ",")); state.setProp(IOConstants.COLUMNS_TYPES, StringUtils.join(columnTypes, ",")); }