mirror of
https://github.com/apache/sqoop.git
synced 2025-05-03 03:59:18 +08:00
A test is implemented for setting Avro schema file name.
This commit is contained in:
parent
83d40868c8
commit
43aedab8d4
@ -38,6 +38,7 @@
|
|||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.fs.Path;
|
import org.apache.hadoop.fs.Path;
|
||||||
|
|
||||||
|
import org.apache.sqoop.testutil.ArgumentArrayBuilder;
|
||||||
import org.apache.sqoop.testutil.AvroTestUtils;
|
import org.apache.sqoop.testutil.AvroTestUtils;
|
||||||
import org.apache.sqoop.testutil.CommonArgs;
|
import org.apache.sqoop.testutil.CommonArgs;
|
||||||
import org.apache.sqoop.testutil.HsqldbTestServer;
|
import org.apache.sqoop.testutil.HsqldbTestServer;
|
||||||
@ -94,6 +95,25 @@ public void testAvroImport() throws IOException {
|
|||||||
avroImportTestHelper(null, null);
|
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
|
@Test
|
||||||
public void testDeflateCompressedAvroImport() throws IOException {
|
public void testDeflateCompressedAvroImport() throws IOException {
|
||||||
this.setCurTableName("Deflate_Compressed_Avro_Import_Test_1");
|
this.setCurTableName("Deflate_Compressed_Avro_Import_Test_1");
|
||||||
@ -366,8 +386,13 @@ protected DataFileReader<GenericRecord> read(Path filename) throws IOException {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void checkSchemaFile(final Schema schema) 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());
|
assertTrue(schemaFile.exists());
|
||||||
assertEquals(schema, new Schema.Parser().parse(schemaFile));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user