本文整理汇总了Java中com.taobao.tddl.optimizer.core.ast.query.TableNode.limit方法的典型用法代码示例。如果您正苦于以下问题:Java TableNode.limit方法的具体用法?Java TableNode.limit怎么用?Java TableNode.limit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.taobao.tddl.optimizer.core.ast.query.TableNode
的用法示例。
在下文中一共展示了TableNode.limit方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TableNode
import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void test_单表查询_存在聚合函数_limit不下推() {
TableNode table = new TableNode("TABLE1");
table.limit(10, 20);
table.select("count(distinct id)");
QueryTreeNode qn = table;
IQueryTree qc = (IQueryTree) optimizer.optimizeAndAssignment(qn, null, extraCmd);
Assert.assertTrue(qc instanceof IMerge);
Assert.assertEquals(QUERY_CONCURRENCY.GROUP_CONCURRENT, ((IMerge) qc).getQueryConcurrency());// 并行
Assert.assertEquals(10L, qc.getLimitFrom());
Assert.assertEquals(20L, qc.getLimitTo());
IDataNodeExecutor dne = ((IMerge) qc).getSubNodes().get(0);
Assert.assertTrue(dne instanceof IQuery);
IQuery query = (IQuery) dne;
Assert.assertEquals(null, query.getLimitFrom());
Assert.assertEquals(null, query.getLimitTo());
}
示例2: TableNode
import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void test_order条件下推_子表_case3_不下推() {
TableNode table1 = new TableNode("TABLE1");
table1.alias("A");
table1.orderBy("ID");
table1.orderBy("NAME");
table1.limit(0, 10);
QueryNode query = new QueryNode(table1);
query.orderBy("A.NAME");
query.orderBy("A.SCHOOL");
query.build();
OrderByPusher.optimize(query);
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: testLimit
import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void testLimit() throws SqlParserException {
String sql = "SELECT * FROM TABLE1 LIMIT 1,10";
QueryTreeNode qn = query(sql);
qn.build();
TableNode table1 = new TableNode("TABLE1");
QueryTreeNode qnExpected = table1.limit(1, 10);
qnExpected.build();
assertEquals(qn, qnExpected);
}
示例4: testLimit
import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void testLimit() throws SqlParserException, QueryException {
String sql = "SELECT * FROM TABLE1 LIMIT 1,10";
QueryTreeNode qn = query(sql);
qn.build();
TableNode table1 = new TableNode("TABLE1");
QueryTreeNode qnExpected = table1.limit(1, 10);
qnExpected.build();
assertEquals(qn, qnExpected);
}
示例5: COUNT
import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void testWhere_字段多级子查询() throws QueryException, SqlParserException {
String subSql = "SELECT B.* FROM TABLE2 B WHERE B.ID=1 GROUP BY SCHOOL HAVING COUNT(*) > 1 ORDER BY ID DESC LIMIT 1";
String sql = "SELECT NAME FROM TABLE1 WHERE NAME=(SELECT C.NAME FROM (" + subSql + ") C )";
QueryTreeNode qn = query(sql);
qn.build();
TableNode table1 = new TableNode("TABLE1");
QueryTreeNode qnExpected = table1.select("NAME");
TableNode table2 = new TableNode("TABLE2");
table2.alias("C").setSubAlias("B").select("*").query("B.ID=1");
table2.groupBy("SCHOOL");
table2.having("COUNT(*) > 1");
table2.orderBy("ID", false);
table2.limit(0, 1);
table2.setSubQuery(true);
QueryNode subQuery = new QueryNode(table2);
subQuery.select("C.NAME");
IColumn column = ASTNodeFactory.getInstance().createColumn().setColumnName("NAME");
IBooleanFilter filter = ASTNodeFactory.getInstance()
.createBooleanFilter()
.setColumn(column)
.setValue(subQuery)
.setOperation(OPERATION.EQ);
table1.query(filter);
qnExpected.build();
assertEquals(qn, qnExpected);
}