本文整理汇总了Java中org.apache.sqoop.util.SqlTypeMap类的典型用法代码示例。如果您正苦于以下问题:Java SqlTypeMap类的具体用法?Java SqlTypeMap怎么用?Java SqlTypeMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SqlTypeMap类属于org.apache.sqoop.util包,在下文中一共展示了SqlTypeMap类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDifferentTableNames
import org.apache.sqoop.util.SqlTypeMap; //导入依赖的package包/类
public void testDifferentTableNames() throws Exception {
Configuration conf = new Configuration();
SqoopOptions options = new SqoopOptions();
TableDefWriter writer = new TableDefWriter(options, null,
"inputTable", "outputTable", conf, false);
Map<String, Integer> colTypes = new SqlTypeMap<String, Integer>();
writer.setColumnTypes(colTypes);
String createTable = writer.getCreateTableStmt();
String loadData = writer.getLoadDataStmt();
LOG.debug("Create table stmt: " + createTable);
LOG.debug("Load data stmt: " + loadData);
// Assert that the statements generated have the form we expect.
assertTrue(createTable.indexOf(
"CREATE TABLE IF NOT EXISTS `outputTable`") != -1);
assertTrue(loadData.indexOf("INTO TABLE `outputTable`") != -1);
assertTrue(loadData.indexOf("/inputTable'") != -1);
}
示例2: testPartitions
import org.apache.sqoop.util.SqlTypeMap; //导入依赖的package包/类
public void testPartitions() throws Exception {
String[] args = {
"--hive-partition-key", "ds",
"--hive-partition-value", "20110413",
};
Configuration conf = new Configuration();
SqoopOptions options =
new ImportTool().parseArguments(args, null, null, false);
TableDefWriter writer = new TableDefWriter(options,
null, "inputTable", "outputTable", conf, false);
Map<String, Integer> colTypes = new SqlTypeMap<String, Integer>();
writer.setColumnTypes(colTypes);
String createTable = writer.getCreateTableStmt();
String loadData = writer.getLoadDataStmt();
assertNotNull(createTable);
assertNotNull(loadData);
assertEquals("CREATE TABLE IF NOT EXISTS `outputTable` ( ) "
+ "PARTITIONED BY (ds STRING) "
+ "ROW FORMAT DELIMITED FIELDS TERMINATED BY '\\054' "
+ "LINES TERMINATED BY '\\012' STORED AS TEXTFILE", createTable);
assertTrue(loadData.endsWith(" PARTITION (ds='20110413')"));
}
示例3: testUserMapping
import org.apache.sqoop.util.SqlTypeMap; //导入依赖的package包/类
public void testUserMapping() throws Exception {
String[] args = {
"--map-column-hive", "id=STRING,value=INTEGER",
};
Configuration conf = new Configuration();
SqoopOptions options =
new ImportTool().parseArguments(args, null, null, false);
TableDefWriter writer = new TableDefWriter(options,
null, HsqldbTestServer.getTableName(), "outputTable", conf, false);
Map<String, Integer> colTypes = new SqlTypeMap<String, Integer>();
colTypes.put("id", Types.INTEGER);
colTypes.put("value", Types.VARCHAR);
writer.setColumnTypes(colTypes);
String createTable = writer.getCreateTableStmt();
assertNotNull(createTable);
assertTrue(createTable.contains("`id` STRING"));
assertTrue(createTable.contains("`value` INTEGER"));
assertFalse(createTable.contains("`id` INTEGER"));
assertFalse(createTable.contains("`value` STRING"));
}
示例4: testUserMappingFailWhenCantBeApplied
import org.apache.sqoop.util.SqlTypeMap; //导入依赖的package包/类
public void testUserMappingFailWhenCantBeApplied() throws Exception {
String[] args = {
"--map-column-hive", "id=STRING,value=INTEGER",
};
Configuration conf = new Configuration();
SqoopOptions options =
new ImportTool().parseArguments(args, null, null, false);
TableDefWriter writer = new TableDefWriter(options,
null, HsqldbTestServer.getTableName(), "outputTable", conf, false);
Map<String, Integer> colTypes = new SqlTypeMap<String, Integer>();
colTypes.put("id", Types.INTEGER);
writer.setColumnTypes(colTypes);
try {
String createTable = writer.getCreateTableStmt();
fail("Expected failure on non applied mapping.");
} catch(IllegalArgumentException iae) {
// Expected, ok
}
}
示例5: testHiveDatabase
import org.apache.sqoop.util.SqlTypeMap; //导入依赖的package包/类
public void testHiveDatabase() throws Exception {
String[] args = {
"--hive-database", "db",
};
Configuration conf = new Configuration();
SqoopOptions options =
new ImportTool().parseArguments(args, null, null, false);
TableDefWriter writer = new TableDefWriter(options,
null, HsqldbTestServer.getTableName(), "outputTable", conf, false);
Map<String, Integer> colTypes = new SqlTypeMap<String, Integer>();
writer.setColumnTypes(colTypes);
String createTable = writer.getCreateTableStmt();
assertNotNull(createTable);
assertTrue(createTable.contains("`db`.`outputTable`"));
String loadStmt = writer.getLoadDataStmt();
assertNotNull(loadStmt);
assertTrue(createTable.contains("`db`.`outputTable`"));
}
示例6: getColumnTypesForRawQuery
import org.apache.sqoop.util.SqlTypeMap; //导入依赖的package包/类
/**
* Get column types for a query statement that we do not modify further.
*/
protected Map<String, Integer> getColumnTypesForRawQuery(String stmt) {
Map<String, List<Integer>> colInfo = getColumnInfoForRawQuery(stmt);
if (colInfo == null) {
return null;
}
Map<String, Integer> colTypes = new SqlTypeMap<String, Integer>();
for (String s : colInfo.keySet()) {
List<Integer> info = colInfo.get(s);
colTypes.put(s, info.get(0));
}
return colTypes;
}
示例7: getColumnTypesForProcedure
import org.apache.sqoop.util.SqlTypeMap; //导入依赖的package包/类
@Override
public Map<String, Integer> getColumnTypesForProcedure(String procedureName) {
Map<String, List<Integer>> colInfo =
getColumnInfoForProcedure(procedureName);
if (colInfo == null) {
return null;
}
Map<String, Integer> colTypes = new SqlTypeMap<String, Integer>();
for (String s : colInfo.keySet()) {
List<Integer> info = colInfo.get(s);
colTypes.put(s, info.get(0));
}
return colTypes;
}
示例8: getColumnTypes
import org.apache.sqoop.util.SqlTypeMap; //导入依赖的package包/类
@Override
public Map<String, Integer> getColumnTypes(String tableName) {
String[] colNames = options.getColumns();
Map<String, Integer> map = new SqlTypeMap<String, Integer>();
for (String c: colNames) {
map.put(c, Integer.valueOf(Types.VARCHAR));
}
return map;
}
示例9: testDifferentTargetDirs
import org.apache.sqoop.util.SqlTypeMap; //导入依赖的package包/类
public void testDifferentTargetDirs() throws Exception {
String targetDir = "targetDir";
String inputTable = "inputTable";
String outputTable = "outputTable";
Configuration conf = new Configuration();
SqoopOptions options = new SqoopOptions();
// Specify a different target dir from input table name
options.setTargetDir(targetDir);
TableDefWriter writer = new TableDefWriter(options, null,
inputTable, outputTable, conf, false);
Map<String, Integer> colTypes = new SqlTypeMap<String, Integer>();
writer.setColumnTypes(colTypes);
String createTable = writer.getCreateTableStmt();
String loadData = writer.getLoadDataStmt();
LOG.debug("Create table stmt: " + createTable);
LOG.debug("Load data stmt: " + loadData);
// Assert that the statements generated have the form we expect.
assertTrue(createTable.indexOf(
"CREATE TABLE IF NOT EXISTS `" + outputTable + "`") != -1);
assertTrue(loadData.indexOf("INTO TABLE `" + outputTable + "`") != -1);
assertTrue(loadData.indexOf("/" + targetDir + "'") != -1);
}
示例10: testLzoSplitting
import org.apache.sqoop.util.SqlTypeMap; //导入依赖的package包/类
public void testLzoSplitting() throws Exception {
String[] args = {
"--compress",
"--compression-codec", "lzop",
};
Configuration conf = new Configuration();
SqoopOptions options =
new ImportTool().parseArguments(args, null, null, false);
TableDefWriter writer = new TableDefWriter(options,
null, "inputTable", "outputTable", conf, false);
Map<String, Integer> colTypes = new SqlTypeMap<String, Integer>();
writer.setColumnTypes(colTypes);
String createTable = writer.getCreateTableStmt();
String loadData = writer.getLoadDataStmt();
assertNotNull(createTable);
assertNotNull(loadData);
assertEquals("CREATE TABLE IF NOT EXISTS `outputTable` ( ) "
+ "ROW FORMAT DELIMITED FIELDS TERMINATED BY '\\054' "
+ "LINES TERMINATED BY '\\012' STORED AS "
+ "INPUTFORMAT 'com.hadoop.mapred.DeprecatedLzoTextInputFormat' "
+ "OUTPUTFORMAT "
+ "'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'",
createTable);
}