示例#1
0
 // @Test
 public void test_单表查询_函数下推() {
   TableNode table = new TableNode("TABLE1");
   table.select("ID");
   table.orderBy("COUNT(ID)");
   table.groupBy("NAME");
   table.having("COUNT(ID) > 1");
   table.query("ID = 1");
   IQueryTree qc = (IQueryTree) optimizer.optimizeAndAssignment(table, null, extraCmd);
   Assert.assertTrue(qc instanceof IQuery);
   Assert.assertEquals(QUERY_CONCURRENCY.SEQUENTIAL, ((IQuery) qc).getQueryConcurrency()); // 并行
 }
示例#2
0
  // @Test
  public void test_单表merge_函数下推() {
    TableNode table = new TableNode("TABLE1");
    table.select("MAX(ID) AS ID");
    table.orderBy("COUNT(ID)");
    table.groupBy("SUBSTRING(NAME,0,10)");
    table.having("COUNT(ID) > 1");
    IQueryTree qc = (IQueryTree) optimizer.optimizeAndAssignment(table, null, extraCmd);
    Assert.assertTrue(qc instanceof IMerge);
    Assert.assertEquals(QUERY_CONCURRENCY.CONCURRENT, ((IMerge) qc).getQueryConcurrency()); // 并行

    IDataNodeExecutor dne = ((IMerge) qc).getSubNodes().get(0);
    Assert.assertTrue(dne instanceof IQuery);
    IQuery query = (IQuery) dne;
    Assert.assertEquals("SUBSTRING(NAME, 0, 10)", query.getColumns().get(1).toString()); // 下推成功
    Assert.assertEquals("COUNT(ID)", query.getColumns().get(2).toString()); // 下推成功
  }
示例#3
0
  @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());
  }