Example #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()); // 并行
 }
Example #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()); // 下推成功
  }