use of com.alibaba.datax.plugin.writer.adswriter.odps.FieldSchema in project DataX by alibaba.
the class TableMetaHelper method createTempODPSTable.
/**
* Create temporary ODPS table.
*
* @param tableMeta table meta
* @param lifeCycle for temporary table
* @return ODPS temporary table meta
*/
public static TableMeta createTempODPSTable(TableInfo tableMeta, int lifeCycle) {
TableMeta tempTable = new TableMeta();
tempTable.setComment(tableMeta.getComments());
tempTable.setLifeCycle(lifeCycle);
String tableSchema = tableMeta.getTableSchema();
String tableName = tableMeta.getTableName();
tempTable.setTableName(generateTempTableName(tableSchema, tableName));
List<FieldSchema> tempColumns = new ArrayList<FieldSchema>();
List<ColumnInfo> columns = tableMeta.getColumns();
for (ColumnInfo column : columns) {
FieldSchema tempColumn = new FieldSchema();
tempColumn.setName(column.getName());
tempColumn.setType(toODPSDataType(column.getDataType()));
tempColumn.setComment(column.getComment());
tempColumns.add(tempColumn);
}
tempTable.setCols(tempColumns);
tempTable.setPartitionKeys(null);
return tempTable;
}
use of com.alibaba.datax.plugin.writer.adswriter.odps.FieldSchema in project DataX by alibaba.
the class AdsUtil method generateConf.
/*生成ODPSWriter Plugin所需要的配置文件
* */
public static Configuration generateConf(Configuration originalConfig, String odpsTableName, TableMeta tableMeta, TransferProjectConf transConf) {
Configuration newConfig = originalConfig.clone();
newConfig.set(Key.ODPSTABLENAME, odpsTableName);
newConfig.set(Key.ODPS_SERVER, transConf.getOdpsServer());
newConfig.set(Key.TUNNEL_SERVER, transConf.getOdpsTunnel());
newConfig.set(Key.ACCESS_ID, transConf.getAccessId());
newConfig.set(Key.ACCESS_KEY, transConf.getAccessKey());
newConfig.set(Key.PROJECT, transConf.getProject());
newConfig.set(Key.TRUNCATE, true);
newConfig.set(Key.PARTITION, null);
// newConfig.remove(Key.PARTITION);
List<FieldSchema> cols = tableMeta.getCols();
List<String> allColumns = new ArrayList<String>();
if (cols != null && !cols.isEmpty()) {
for (FieldSchema col : cols) {
allColumns.add(col.getName());
}
}
newConfig.set(Key.COLUMN, allColumns);
return newConfig;
}
Aggregations