AVROIntermediateDataFormat extends IntermediateDataFormat<GenericRecord> { @Override public void setCSVTextData(String text) { super.validateSchema(schema); this.data = toAVRO(text); } AVROIntermediateDataFormat();  AVROIntermediateDataFormat(org.apache.sqoop.schema.Schema schema); @Override void setCSVTextData(String text); @Override String getCSVTextData(); @Override void setObjectData(Object[] data); @Override Object[] getObjectData(); @Override void write(DataOutput out); @Override void read(DataInput in); @Override Set<String> getJars();  }
@Test public void testInputAsCSVTextInAndDataOut() { String csvText = "10,34,'54','random data'," + getByteFieldString(new byte[] { (byte) -112, (byte) 54 }) + ",'" + String.valueOf(0x0A) + "','ENUM'," + csvArray + "," + map + ",true," + csvDateTime + "," + csvTime + "," + csvDate + ",13.44," + csvSet; dataFormat.setCSVTextData(csvText); GenericRecord avroObject = createAvroGenericRecord(); assertEquals(avroObject.toString(), dataFormat.getData().toString()); }
@Test(expectedExceptions = SqoopException.class) public void testNotSettingSchemaAndSetCSVData() { dataFormat = new AVROIntermediateDataFormat(); dataFormat.setCSVTextData(null); }
@Test(expectedExceptions = SqoopException.class) public void testSchemaNotNullableWithCSV() { Schema overrideSchema = new Schema("Test").addColumn(new Text("one").setNullable(false)); AVROIntermediateDataFormat dataFormat = new AVROIntermediateDataFormat(overrideSchema); dataFormat.setCSVTextData(NULL_VALUE); }