本文整理汇总了Java中com.taobao.tddl.optimizer.core.ast.query.TableNode.join方法的典型用法代码示例。如果您正苦于以下问题:Java TableNode.join方法的具体用法?Java TableNode.join怎么用?Java TableNode.join使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.taobao.tddl.optimizer.core.ast.query.TableNode
的用法示例。
在下文中一共展示了TableNode.join方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TableNode
import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void test_join条件下推_子表_case4_下推IDNAME() {
TableNode table1 = new TableNode("TABLE1");
TableNode table2 = new TableNode("TABLE2");
table1.alias("A");
table2.alias("B");
JoinNode join = table1.join(table2);
join.setJoinStrategy(JoinStrategy.INDEX_NEST_LOOP);
join.orderBy("A.ID");
join.orderBy("A.NAME");
join.build();
OrderByPusher.optimize(join);
Assert.assertEquals(2, table1.getOrderBys().size());
Assert.assertEquals("TABLE1.ID", table1.getOrderBys().get(0).getColumn().toString());
Assert.assertEquals("TABLE1.NAME", table1.getOrderBys().get(1).getColumn().toString());
}
示例2: TableNode
import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void test_join条件下推_子表_case1_下推NAME() {
TableNode table1 = new TableNode("TABLE1");
TableNode table2 = new TableNode("TABLE2");
table1.alias("A");
table1.orderBy("ID");
table2.alias("B");
JoinNode join = table1.join(table2);
join.setJoinStrategy(JoinStrategy.INDEX_NEST_LOOP);
join.orderBy("A.ID");
join.orderBy("A.NAME");
join.build();
OrderByPusher.optimize(join);
Assert.assertEquals(2, table1.getOrderBys().size());
Assert.assertEquals("TABLE1.ID", table1.getOrderBys().get(0).getColumn().toString());
Assert.assertEquals("TABLE1.NAME", table1.getOrderBys().get(1).getColumn().toString());
}
示例3: TableNode
import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void test_where条件下推_多级join() {
TableNode table1 = new TableNode("TABLE1");
TableNode table2 = new TableNode("TABLE2");
TableNode table3 = new TableNode("TABLE3");
JoinNode join = table1.join(table2);
join.select("TABLE1.ID AS ID , TABLE1.NAME AS NAME");
join.query("TABLE1.ID>5 AND TABLE2.ID<10 AND TABLE1.NAME = TABLE2.NAME");
join.build();
JoinNode nextJoin = join.join(table3);
nextJoin.query("TABLE1.NAME = 6 AND TABLE1.ID = TABLE3.ID");
nextJoin.build();
FilterPusher.optimize(nextJoin);
Assert.assertEquals("(TABLE1.NAME = 6 AND TABLE1.ID > 5)", ((JoinNode) nextJoin.getLeftNode()).getLeftNode()
.getWhereFilter()
.toString());
Assert.assertEquals("(TABLE2.ID < 10 AND TABLE2.NAME = 6)", ((JoinNode) nextJoin.getLeftNode()).getRightNode()
.getWhereFilter()
.toString());
Assert.assertEquals("TABLE1.ID = TABLE3.ID", nextJoin.getJoinFilter().get(0).toString());
}
示例4: TableNode
import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void test_两表Join_主键_存在二级索引条件() {
TableNode table = new TableNode("TABLE1");
JoinNode join = table.join("TABLE2", "ID", "ID");
join.query("TABLE2.NAME = 1");
IQueryTree qc = (IQueryTree) optimizer.optimizeAndAssignment(join, null, extraCmd);
Assert.assertTrue(qc instanceof IMerge);
Assert.assertTrue(((IMerge) qc).getSubNodes().get(0) instanceof IJoin);
IJoin subJoin = (IJoin) ((IMerge) qc).getSubNodes().get(0);
Assert.assertTrue(subJoin.getRightNode() instanceof IJoin);
Assert.assertEquals(JoinStrategy.NEST_LOOP_JOIN, subJoin.getJoinStrategy());
}
示例5: TableNode
import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void test_三表Join_主键索引_存在主键索引条件() {
TableNode table = new TableNode("TABLE1");
JoinNode join = table.join("TABLE2", "TABLE1.ID", "TABLE2.ID");
join = join.join("TABLE3", "TABLE1.ID", "TABLE3.ID");
join.query("TABLE3.ID IN (1,2)");
IQueryTree qc = (IQueryTree) optimizer.optimizeAndAssignment(join, null, extraCmd);
Assert.assertTrue(qc instanceof IMerge);
Assert.assertTrue(((IMerge) qc).getSubNode().get(0) instanceof IJoin);
IJoin subJoin = (IJoin) ((IMerge) qc).getSubNode().get(0);
Assert.assertTrue(subJoin.getLeftNode() instanceof IJoin);
Assert.assertEquals(JoinStrategy.INDEX_NEST_LOOP, subJoin.getJoinStrategy());
}
示例6: TableNode
import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void test_where中无匹配条件不下推() {
TableNode table1 = new TableNode("TABLE1");
TableNode table2 = new TableNode("TABLE2");
JoinNode join = table1.join(table2);
join.query("(TABLE1.ID>5 OR TABLE2.ID<10) AND TABLE1.NAME = TABLE2.NAME");
join.build();
FilterPreProcessor.optimize(join, true, null);
FilterPusher.optimize(join);
Assert.assertEquals(null, join.getLeftNode().getWhereFilter());
Assert.assertEquals(null, join.getRightNode().getWhereFilter());
Assert.assertTrue(join.getJoinFilter().isEmpty());
}
示例7: TableNode
import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void test_Join左是子查询_右是TableNode_转化为最左树() {
TableNode table1 = new TableNode("TABLE1");
QueryNode query = new QueryNode(table1);
query.build();
TableNode table2 = new TableNode("TABLE2");
JoinNode join = table1.join(table2, "NAME", "NAME");
join.setJoinStrategy(JoinStrategy.INDEX_NEST_LOOP);
join.query("TABLE1.NAME = 1 AND TABLE1.ID > 3 AND TABLE1.SCHOOL = 1");// 原本条件应该是加在join下的,这里省区推导的过程
join.select("(TABLE2.ID + TABLE2.NAME) AS NEWNAME"); // 设置为函数
join.orderBy("TABLE1.SCHOOL", false);// 增加一个隐藏列
join.groupBy("NEWNAME");
join.build();
QueryTreeNode qn = FilterPusher.optimize(join);// 先把条件推导子节点上,构建子节点join
build(table1);
build(table2);
qn = qn.convertToJoinIfNeed();
Assert.assertTrue(qn instanceof JoinNode);
Assert.assertEquals("TABLE2$_NAME.ID = TABLE2.ID", ((JoinNode) qn).getJoinFilter().get(0).toString());
Assert.assertTrue(((JoinNode) qn).getLeftNode() instanceof JoinNode);
Assert.assertEquals("TABLE1.NAME = TABLE2$_NAME.NAME",
((JoinNode) ((JoinNode) qn).getLeftNode()).getJoinFilter().get(0).toString());
Assert.assertTrue(((JoinNode) ((JoinNode) qn).getLeftNode()).getLeftNode() instanceof JoinNode);
JoinNode jn = (JoinNode) ((JoinNode) ((JoinNode) qn).getLeftNode()).getLeftNode();
Assert.assertEquals("TABLE1._NAME.NAME = 1", jn.getLeftNode().getKeyFilter().toString());
Assert.assertEquals("TABLE1._NAME.ID > 3", jn.getLeftNode().getResultFilter().toString());
Assert.assertEquals("TABLE1.SCHOOL = 1", jn.getRightNode().getResultFilter().toString());
Assert.assertEquals("TABLE1._NAME.ID = TABLE1.ID", jn.getJoinFilter().get(0).toString());
}