use of com.qlangtech.tis.sql.parser.SqlTaskNode in project tis by qlangtech.
the class TestSupplyGoodsParse method testTopologyParse.
public void testTopologyParse() throws Exception {
// this.parseSqlTaskNode()
List<SqlTaskNode> processNodes = this.parseTopologySqlTaskNodes(topologyName);
assertTrue(processNodes.size() > 0);
assertEquals(4, processNodes.size());
SqlTaskNodeMeta.SqlDataFlowTopology topology = SqlTaskNodeMeta.getSqlDataFlowTopology(topologyName);
TableTupleCreator tableTupleCreator = topology.parseFinalSqlTaskNode();
ColRef.ListMap cols = tableTupleCreator.getColsRefs().getColRefMap();
assertTrue(cols.size() > 0);
assertEquals("parse from suppyGoods cols size", 58, cols.size());
assertNotNull("tableTupleCreator", tableTupleCreator);
}
use of com.qlangtech.tis.sql.parser.SqlTaskNode in project tis by qlangtech.
the class TestTableDependencyVisitor method testDependencies.
public void testDependencies() throws Exception {
List<SqlTaskNode> taskNodes = SqlTaskNodeMeta.getSqlDataFlowTopology("totalpay").parseTaskNodes();
String order_customers = "order_customers";
Optional<SqlTaskNode> taskNode = taskNodes.stream().filter((r) -> order_customers.equals(r.getExportName())).findFirst();
Assert.assertTrue(order_customers + " shall be exist", taskNode.isPresent());
TableDependencyVisitor dependenciesVisitor = TableDependencyVisitor.create();
Query query = SqlTaskNode.parseQuery(taskNode.get().getContent());
dependenciesVisitor.process(query, null);
// for (String dependency : dependenciesVisitor.getTabDependencies()) {
// System.out.println(dependency);
// }
// Assert.assertTrue(dependenciesVisitor.getTabDependencies().size() > 0);
Assert.assertEquals(1, dependenciesVisitor.getTabDependencies().size());
Assert.assertTrue(dependenciesVisitor.getTabDependencies().contains("instance"));
}
use of com.qlangtech.tis.sql.parser.SqlTaskNode in project tis by qlangtech.
the class TabCriteriaEntityRecognizeVisitor method visit.
@Override
public void visit(TableTupleCreator tableTuple) {
TabCriteria tableCriteria = tabCriteria;
// join 部分逻辑处理
if (!tableCriteria.isPrimary()) {
JoinOn joinOn = tableCriteria.getJoinOn();
ComparisonExpression compare = null;
LogicalBinaryExpression logic = null;
if (joinOn.getExpression() instanceof ComparisonExpression) {
// (tp.totalpay_id = o.totalpay_id)
compare = (ComparisonExpression) joinOn.getExpression();
} else if (joinOn.getExpression() instanceof LogicalBinaryExpression) {
// ((tp.card_id = cc.id) AND (tp.entity_id = cc.entity_id))
logic = (LogicalBinaryExpression) joinOn.getExpression();
}
}
if (this.subQuery != null) {
// 是像 totalpay/order_customers.txt 文件中那样有内嵌子查询的
SqlTaskNode subqueryTaskNode = new SqlTaskNode(EntityName.parse(tableCriteria.getName()), NodeType.JOINER_SQL, this.dumpNodsContext);
// Map<ColName, ValueOperator> columnTracer = Maps.newHashMap();
// Rewriter rewriter = Rewriter.create(columnTracer);
subqueryTaskNode.setContent(SqlFormatter.formatSql(this.subQuery.getQuery().getQueryBody(), Optional.empty()));
TableDependencyVisitor dependenciesVisitor = TableDependencyVisitor.create();
Query query = SqlTaskNode.parseQuery(subqueryTaskNode.getContent());
dependenciesVisitor.process(query, null);
dependenciesVisitor.getTabDependencies().stream().forEach((table) -> {
// ;
//
// List<TableTupleCreator> tables = SqlTaskNode.dumpNodes.get(table);
// if (tables.size() != 1) {
// throw new IllegalStateException("table:" + table + " relevant tab has more than 1 match");
// }
// tables.get(0).getEntityName();
EntityName firstMatch = dumpNodsContext.accurateMatch(table);
subqueryTaskNode.addRequired(firstMatch, new SqlTaskNode(firstMatch, NodeType.DUMP, this.dumpNodsContext));
});
final TableTupleCreator tupleCreator = subqueryTaskNode.parse(true);
tableTuple.setColsRefs(tupleCreator.getColsRefs());
tableTuple.setRealEntityName(tupleCreator.getEntityName());
// tableTuple.setEntityRef(new EntitiyRef(tableCriteria.getName(),
// subqueryTaskNode));
} else {
// tableTuple.setEntityRef(new EntitiyRef(tableCriteria.getName()));
// List<TableTupleCreator> tabs = null;
EntityName ename = this.dumpNodsContext.nullableMatch(tableCriteria.getName());
if (ename != null) {
tableTuple.setNodetype(NodeType.DUMP);
tableTuple.setRealEntityName(ename);
} else {
tableTuple.setRealEntityName(EntityName.parse(tableCriteria.getName()));
}
// if ((tabs = SqlTaskNode.dumpNodes.get(tableCriteria.getName())) != null) {
// tableTuple.setNodetype(NodeType.DUMP);
//
// if (tabs.size() != 1) {
// throw new IllegalStateException(
// "tabname:" + tableCriteria.getName() + " relevant tab size shall be 1 but " + tabs.size());
// } else {
// tableTuple.setRealEntityName(tabs.get(0).getEntityName());
// }
// } else {
// tableTuple.setRealEntityName(EntityName.parse(tableCriteria.getName()));
// }
}
}
Aggregations