Search in sources :

Example 1 with TableMeta

use of com.alibaba.datax.plugin.writer.adswriter.odps.TableMeta 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;
}
Also used : FieldSchema(com.alibaba.datax.plugin.writer.adswriter.odps.FieldSchema) ArrayList(java.util.ArrayList) ColumnInfo(com.alibaba.datax.plugin.writer.adswriter.ads.ColumnInfo) TableMeta(com.alibaba.datax.plugin.writer.adswriter.odps.TableMeta)

Aggregations

ColumnInfo (com.alibaba.datax.plugin.writer.adswriter.ads.ColumnInfo)1 FieldSchema (com.alibaba.datax.plugin.writer.adswriter.odps.FieldSchema)1 TableMeta (com.alibaba.datax.plugin.writer.adswriter.odps.TableMeta)1 ArrayList (java.util.ArrayList)1