final String TABLE_NAME = "GenerateOnly";
setCurTableName(TABLE_NAME);
setNumCols(1);
// Figure out where our target generated .q file is going to be.
SqoopOptions options = getSqoopOptions(getArgv(false, null),
new ImportTool());
Path ddlFile = new Path(new Path(options.getCodeOutputDir()),
TABLE_NAME + ".q");
FileSystem fs = FileSystem.getLocal(new Configuration());
// If it's already there, remove it before running the test to ensure
// that it's the current test that generated the file.
if (fs.exists(ddlFile)) {
if (!fs.delete(ddlFile, false)) {
LOG.warn("Could not delete previous ddl file: " + ddlFile);
}
}
// Run a basic import, but specify that we're just generating definitions.
String [] types = { "INTEGER" };
String [] vals = { "42" };
runImportTest(TABLE_NAME, types, vals, null, getCodeGenArgs(),
new CodeGenTool());
// Test that the generated definition file exists.
assertTrue("Couldn't find expected ddl file", fs.exists(ddlFile));
Path hiveImportPath = new Path(new Path(options.getWarehouseDir()),
TABLE_NAME);
assertFalse("Import actually happened!", fs.exists(hiveImportPath));
}