Search in sources :

Example 1 with Pair

use of com.dtstack.taier.develop.sql.Pair in project Taier by DTStack.

the class AstNodeParser method getTableLineages.

/**
 * 对表级血缘进行组装
 *
 * @param sqlNode
 * @param lineageParser
 * @return
 */
private List<TableLineage> getTableLineages(com.dtstack.taier.develop.sql.node.Node sqlNode, LineageParser lineageParser) {
    List<TableLineage> resList = Lists.newArrayList();
    List<Pair<Identifier, Identifier>> pairs = lineageParser.parseTableLineage(sqlNode);
    if (CollectionUtils.isNotEmpty(pairs)) {
        for (Pair<Identifier, Identifier> pair : pairs) {
            Identifier key = pair.getKey();
            Identifier value = pair.getValue();
            TableLineage tableLineage = new TableLineage();
            tableLineage.setFromDb(value.getDb());
            tableLineage.setFromTable(value.getTable());
            tableLineage.setToDb(key.getDb());
            tableLineage.setToTable(key.getTable());
            resList.add(tableLineage);
        }
    }
    return resList;
}
Also used : Identifier(com.dtstack.taier.develop.sql.node.Identifier) TableLineage(com.dtstack.taier.develop.sql.TableLineage) Pair(com.dtstack.taier.develop.sql.Pair)

Example 2 with Pair

use of com.dtstack.taier.develop.sql.Pair in project Taier by DTStack.

the class AstNodeParser method getColumnLineages.

private List<ColumnLineage> getColumnLineages(com.dtstack.taier.develop.sql.node.Node sqlNode, LineageParser lineageParser) {
    List<ColumnLineage> resList = Lists.newArrayList();
    List<Pair<Identifier, Identifier>> pairs = lineageParser.parseColumnLineage(sqlNode);
    if (CollectionUtils.isNotEmpty(pairs)) {
        for (Pair<Identifier, Identifier> pair : pairs) {
            Identifier key = pair.getKey();
            Identifier value = pair.getValue();
            ColumnLineage columnLineage = new ColumnLineage();
            columnLineage.setFromDb(value.getDb().replace("`", ""));
            columnLineage.setFromTable(value.getTable().replace("`", ""));
            columnLineage.setFromColumn(value.getColumn().replace("`", ""));
            columnLineage.setToDb(key.getDb().replace("`", ""));
            columnLineage.setToTable(key.getTable().replace("`", ""));
            columnLineage.setToColumn(key.getColumn().replace("`", ""));
            resList.add(columnLineage);
        }
    }
    return resList;
}
Also used : ColumnLineage(com.dtstack.taier.develop.sql.ColumnLineage) Identifier(com.dtstack.taier.develop.sql.node.Identifier) Pair(com.dtstack.taier.develop.sql.Pair)

Aggregations

Pair (com.dtstack.taier.develop.sql.Pair)2 Identifier (com.dtstack.taier.develop.sql.node.Identifier)2 ColumnLineage (com.dtstack.taier.develop.sql.ColumnLineage)1 TableLineage (com.dtstack.taier.develop.sql.TableLineage)1