本文整理匯總了Java中com.taobao.tddl.optimizer.core.ast.query.JoinNode.orderBy方法的典型用法代碼示例。如果您正苦於以下問題:Java JoinNode.orderBy方法的具體用法?Java JoinNode.orderBy怎麽用?Java JoinNode.orderBy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.taobao.tddl.optimizer.core.ast.query.JoinNode
的用法示例。
在下文中一共展示了JoinNode.orderBy方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: TableNode
import com.taobao.tddl.optimizer.core.ast.query.JoinNode; //導入方法依賴的package包/類
@Test
public void test_join條件下推_子表_case3_不下推() {
TableNode table1 = new TableNode("TABLE1");
TableNode table2 = new TableNode("TABLE2");
table1.alias("A");
QueryNode query = new QueryNode(table1);
query.orderBy("ID");
query.orderBy("NAME");
query.limit(0, 10);
table2.alias("B");
JoinNode join = query.join(table2);
join.setJoinStrategy(JoinStrategy.INDEX_NEST_LOOP);
join.orderBy("A.NAME");
join.orderBy("A.SCHOOL");
join.build();
OrderByPusher.optimize(join);
Assert.assertEquals(2, query.getOrderBys().size());
Assert.assertEquals("A.ID", query.getOrderBys().get(0).getColumn().toString());
Assert.assertEquals("A.NAME", query.getOrderBys().get(1).getColumn().toString());
}
示例2: TableNode
import com.taobao.tddl.optimizer.core.ast.query.JoinNode; //導入方法依賴的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());
}
示例3: TableNode
import com.taobao.tddl.optimizer.core.ast.query.JoinNode; //導入方法依賴的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());
}