Search in sources :

Example 1 with TableAliasInfo

use of org.apache.hadoop.hive.ql.hooks.LineageInfo.TableAliasInfo in project hive by apache.

the class ExprProcFactory method findSourceColumn.

private static boolean findSourceColumn(LineageCtx lctx, Predicate cond, String tabAlias, String alias) {
    for (Map.Entry<String, TableScanOperator> topOpMap : lctx.getParseCtx().getTopOps().entrySet()) {
        TableScanOperator tableScanOp = topOpMap.getValue();
        Table tbl = tableScanOp.getConf().getTableMetadata();
        if (tbl.getTableName().equals(tabAlias) || tabAlias.equals(tableScanOp.getConf().getAlias())) {
            for (FieldSchema column : tbl.getCols()) {
                if (column.getName().equals(alias)) {
                    TableAliasInfo table = new TableAliasInfo();
                    table.setTable(tbl.getTTable());
                    table.setAlias(tabAlias);
                    BaseColumnInfo colInfo = new BaseColumnInfo();
                    colInfo.setColumn(column);
                    colInfo.setTabAlias(table);
                    cond.getBaseCols().add(colInfo);
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : TableScanOperator(org.apache.hadoop.hive.ql.exec.TableScanOperator) Table(org.apache.hadoop.hive.ql.metadata.Table) FieldSchema(org.apache.hadoop.hive.metastore.api.FieldSchema) TableAliasInfo(org.apache.hadoop.hive.ql.hooks.LineageInfo.TableAliasInfo) BaseColumnInfo(org.apache.hadoop.hive.ql.hooks.LineageInfo.BaseColumnInfo) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)1 TableScanOperator (org.apache.hadoop.hive.ql.exec.TableScanOperator)1 BaseColumnInfo (org.apache.hadoop.hive.ql.hooks.LineageInfo.BaseColumnInfo)1 TableAliasInfo (org.apache.hadoop.hive.ql.hooks.LineageInfo.TableAliasInfo)1 Table (org.apache.hadoop.hive.ql.metadata.Table)1