本文整理匯總了Java中com.taobao.tddl.optimizer.core.ast.query.JoinNode.query方法的典型用法代碼示例。如果您正苦於以下問題:Java JoinNode.query方法的具體用法?Java JoinNode.query怎麽用?Java JoinNode.query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.taobao.tddl.optimizer.core.ast.query.JoinNode
的用法示例。
在下文中一共展示了JoinNode.query方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: TableNode
import com.taobao.tddl.optimizer.core.ast.query.JoinNode; //導入方法依賴的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());
}
示例2: TableNode
import com.taobao.tddl.optimizer.core.ast.query.JoinNode; //導入方法依賴的package包/類
@Test
public void test_等於IN組合子查詢_複雜條件_外部是個join節點() {
TableNode table1 = new TableNode("TABLE1");
TableNode table2 = new TableNode("TABLE2");
JoinNode join = table1.join(table2, "ID", "ID");
join.query("TABLE1.ID = (SELECT ID FROM TABLE3 WHERE NAME = 'HELLO' AND SCHOOL = 'HELLO' ) AND TABLE1.NAME = 3 AND TABLE1.SCHOOL IN (SELECT SCHOOL FROM TABLE4)");
join.build();
QueryTreeNode qn = SubQueryPreProcessor.optimize(join);
Assert.assertTrue(qn instanceof JoinNode);
Assert.assertTrue(((JoinNode) qn).getLeftNode() instanceof JoinNode);
Assert.assertTrue(((JoinNode) ((JoinNode) qn).getLeftNode()).getLeftNode() instanceof JoinNode);
Assert.assertEquals(null, join.getWhereFilter());
}
示例3: TableNode
import com.taobao.tddl.optimizer.core.ast.query.JoinNode; //導入方法依賴的package包/類
@Test
public void test_兩表Join_二級索引_存在二級索引條件() {
TableNode table = new TableNode("TABLE1");
JoinNode join = table.join("TABLE2", "NAME", "NAME");
join.query("TABLE2.NAME = 1");
IQueryTree qc = (IQueryTree) optimizer.optimizeAndAssignment(join, null, extraCmd);
Assert.assertTrue(qc instanceof IJoin);
Assert.assertTrue(((IJoin) qc).getLeftNode() instanceof IJoin);
Assert.assertTrue(((IJoin) qc).getRightNode() instanceof IMerge);
Assert.assertEquals(JoinStrategy.INDEX_NEST_LOOP, ((IJoin) qc).getJoinStrategy());
IJoin subJoin = (IJoin) ((IJoin) qc).getLeftNode();
Assert.assertTrue(((IJoin) subJoin).getLeftNode() instanceof IMerge);
Assert.assertTrue(((IJoin) subJoin).getRightNode() instanceof IMerge);
Assert.assertEquals(JoinStrategy.INDEX_NEST_LOOP, subJoin.getJoinStrategy());
}
示例4: TableNode
import com.taobao.tddl.optimizer.core.ast.query.JoinNode; //導入方法依賴的package包/類
@Test
public void test_兩表Join_主鍵索引_存在主鍵索引條件() {
TableNode table = new TableNode("TABLE1");
JoinNode join = table.join("TABLE2", "ID", "ID");
join.query("TABLE2.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.assertEquals(JoinStrategy.INDEX_NEST_LOOP, subJoin.getJoinStrategy());
}