diff --git a/src/test/org/apache/sqoop/TestAvroImport.java b/src/test/org/apache/sqoop/TestAvroImport.java index 2666f503..3aded598 100644 --- a/src/test/org/apache/sqoop/TestAvroImport.java +++ b/src/test/org/apache/sqoop/TestAvroImport.java @@ -38,6 +38,7 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; +import org.apache.sqoop.testutil.ArgumentArrayBuilder; import org.apache.sqoop.testutil.AvroTestUtils; import org.apache.sqoop.testutil.CommonArgs; import org.apache.sqoop.testutil.HsqldbTestServer; @@ -94,6 +95,25 @@ public void testAvroImport() throws IOException { avroImportTestHelper(null, null); } + @Test + public void testAvroFileNameWithQueryImport() throws IOException { + setCurTableName("AVRO_FILE_NAME_QUERY_IMPORT"); + createTableWithColTypes(new String[] {"int"}, new String[] {"1"}); + ArgumentArrayBuilder builder = new ArgumentArrayBuilder(); + String[] args = builder + .withOption("connect", HsqldbTestServer.getUrl()) + .withOption("query", "select * from AVRO_FILE_NAME_QUERY_IMPORT where $CONDITIONS") + .withOption("as-avrodatafile") + .withOption("m", "1") + .withOption("target-dir", getWarehouseDir() + "/AVRO_FILE_NAME_QUERY_IMPORT") + .withOption("class-name", "customAvroFile") + .build(); + + runImport(args); + + verifySchemaFileName("customAvroFile.avsc"); + } + @Test public void testDeflateCompressedAvroImport() throws IOException { this.setCurTableName("Deflate_Compressed_Avro_Import_Test_1"); @@ -366,8 +386,13 @@ protected DataFileReader read(Path filename) throws IOException { } protected void checkSchemaFile(final Schema schema) throws IOException { - final File schemaFile = new File(schema.getName() + ".avsc"); + String schemaFileName = schema.getName() + ".avsc"; + verifySchemaFileName(schemaFileName); + assertEquals(schema, new Schema.Parser().parse(new File(schemaFileName))); + } + + protected void verifySchemaFileName(String expectedFileName) { + final File schemaFile = new File(expectedFileName); assertTrue(schemaFile.exists()); - assertEquals(schema, new Schema.Parser().parse(schemaFile)); } }