Search in sources :

Example 1 with IAliasTable

use of com.qlangtech.tis.sql.parser.IAliasTable in project plugins by qlangtech.

the class HiveTask method executeSql.

@Override
protected void executeSql(String taskname, String sql) {
    this.validateDependenciesNode(taskname);
    final Connection conn = this.getTaskContext().getObj();
    final EntityName newCreateTab = EntityName.parse(this.nodeMeta.getExportName());
    // final String newCreatePt = primaryTable.getTabPartition();
    this.getContent();
    List<String> allpts = null;
    try {
        logger.info("\n execute hive task:{} \n{}", taskname, sql);
        HiveDBUtils.execute(conn, sql, joinTaskStatus);
        // 将当前的join task的partition设置到当前上下文中
        TabPartitions dumpPartition = this.getDumpPartition();
        dumpPartition.putPt(newCreateTab, this.rewriteSql.primaryTable);
        allpts = HiveRemoveHistoryDataTask.getHistoryPts(conn, newCreateTab);
    } catch (Exception e) {
        // TODO 一旦有异常要将整个链路执行都停下来
        throw new RuntimeException("taskname:" + taskname, e);
    }
    IAliasTable child = null;
    // 校验最新的Partition 是否已经生成
    if (!allpts.contains(this.rewriteSql.primaryTable.getPt())) {
        StringBuffer errInfo = new StringBuffer();
        errInfo.append("\ntable:" + newCreateTab + "," + IDumpTable.PARTITION_PT + ":" + this.rewriteSql.primaryTable + " is not exist in exist partition set [" + Joiner.on(",").join(allpts) + "]");
        child = this.rewriteSql.primaryTable.getChild();
        if (child != null && !child.isSubQueryTable()) {
            try {
                allpts = HiveRemoveHistoryDataTask.getHistoryPts(conn, child.getTable());
            } catch (Exception e) {
                throw new RuntimeException(child.getTable().getFullName(), e);
            }
            errInfo.append("\n\t child table:").append(child.getTable()).append(",").append(IDumpTable.PARTITION_PT).append(":").append(this.rewriteSql.primaryTable).append(" is not exist in exist partition set [").append(Joiner.on(",").join(allpts)).append("]");
        }
        throw new IllegalStateException(errInfo.toString());
    }
}
Also used : EntityName(com.qlangtech.tis.sql.parser.tuple.creator.EntityName) Connection(java.sql.Connection) IAliasTable(com.qlangtech.tis.sql.parser.IAliasTable) TabPartitions(com.qlangtech.tis.sql.parser.TabPartitions)

Aggregations

IAliasTable (com.qlangtech.tis.sql.parser.IAliasTable)1 TabPartitions (com.qlangtech.tis.sql.parser.TabPartitions)1 EntityName (com.qlangtech.tis.sql.parser.tuple.creator.EntityName)1 Connection (java.sql.Connection)1