Package org.teiid.query.sql.symbol

Examples of org.teiid.query.sql.symbol.AggregateSymbol


        From from = new From();
        from.addGroup(g);

        Select select = new Select();
        select.addSymbol(new AliasSymbol("c"//$NON-NLS-1$
            new AggregateSymbol("c", "COUNT", false, new ElementSymbol("a", false)))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
       
               
        Query query = new Query();
        query.setSelect(select);
        query.setFrom(from);
View Full Code Here


   
    GroupBy groupBy = new GroupBy();
    groupBy.addSymbol(new ElementSymbol("a")); //$NON-NLS-1$
   
    Criteria having = new CompareCriteria(
      new AggregateSymbol("count", "COUNT", false, new ElementSymbol("b", false)), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      CompareCriteria.GT,
      new Constant(new Integer(0)) );
       
    Query query = new Query();
    query.setSelect(select);
View Full Code Here

    groupBy.addSymbol(new ElementSymbol("b")); //$NON-NLS-1$
   
    CompoundCriteria having = new CompoundCriteria();
    having.setOperator(CompoundCriteria.AND);
    having.addCriteria(new CompareCriteria(
      new AggregateSymbol("count", "COUNT", false, new ElementSymbol("b", false)), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      CompareCriteria.GT,
      new Constant(new Integer(0)) ));
    having.addCriteria(new CompareCriteria(
      new Function("+", new Expression[] { new ElementSymbol("b", false), new Constant(new Integer(5)) }), //$NON-NLS-1$ //$NON-NLS-2$
      CompareCriteria.GT,
View Full Code Here

        GroupSymbol g = new GroupSymbol("m.g"); //$NON-NLS-1$
        From from = new From();
        from.addGroup(g);

        Select select = new Select();
        AggregateSymbol agg1 = new AggregateSymbol("count", "COUNT", false, new ElementSymbol("a", false)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        AggregateSymbol agg2 = new AggregateSymbol("sum", "SUM", false, new ElementSymbol("a", false)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        Function f = new Function("*", new Expression[] { agg1, agg2 }); //$NON-NLS-1$
        ExpressionSymbol expr = new ExpressionSymbol("expr", f); //$NON-NLS-1$
        AliasSymbol alias = new AliasSymbol("c", expr); //$NON-NLS-1$
        select.addSymbol(alias);       
               
View Full Code Here

      helpTestExpression("xmlforest(xmlnamespaces(no default, 'http://foo' as x), a as \"table\")", "XMLFOREST(XMLNAMESPACES(NO DEFAULT, 'http://foo' AS x), a AS \"table\")", f);
    }
   
    @Test public void testXmlAggWithOrderBy() throws Exception {
        String sql = "SELECT xmlAgg(1 order by e2)"; //$NON-NLS-1$
        AggregateSymbol as = new AggregateSymbol("foo", Reserved.XMLAGG, false, new Constant(1));
        as.setOrderBy(new OrderBy(Arrays.asList(new ElementSymbol("e2"))));
        Query query = new Query();
        query.setSelect(new Select(Arrays.asList(as)));
        helpTest(sql, "SELECT XMLAGG(1 ORDER BY e2)", query);
    }
View Full Code Here

        TextLine tf = new TextLine();
        tf.setExpressions(expressions);
        tf.setDelimiter(new Character(','));
        tf.setIncludeHeader(true);
       
        AggregateSymbol as = new AggregateSymbol("foo", NonReserved.TEXTAGG, false, tf);
        as.setOrderBy(new OrderBy(Arrays.asList(new ElementSymbol("e2"))));
       
        Query query = new Query();
        query.setSelect(new Select(Arrays.asList(as)));
       
        String sql = "SELECT TextAgg(FOR e1 as col1, e2 as col2 delimiter ',' header order by e2)"; //$NON-NLS-1$
View Full Code Here

        helpTest(sql, "SELECT TEXTAGG(FOR e1 AS col1, e2 AS col2 DELIMITER ',' HEADER ORDER BY e2)", query);
    }   
   
    @Test public void testArrayAggWithOrderBy() throws Exception {
        String sql = "SELECT array_agg(1 order by e2)"; //$NON-NLS-1$
        AggregateSymbol as = new AggregateSymbol("foo", Reserved.ARRAY_AGG, false, new Constant(1));
        as.setOrderBy(new OrderBy(Arrays.asList(new ElementSymbol("e2"))));
        Query query = new Query();
        query.setSelect(new Select(Arrays.asList(as)));
        helpTest(sql, "SELECT ARRAY_AGG(1 ORDER BY e2)", query);
    }
View Full Code Here

        helpTest(sql, "SELECT ARRAY_AGG(1 ORDER BY e2)", query);
    }
   
    @Test public void testArrayAggWithIndexing() throws Exception {
        String sql = "SELECT (array_agg(1))[1]"; //$NON-NLS-1$
        AggregateSymbol as = new AggregateSymbol("foo", Reserved.ARRAY_AGG, false, new Constant(1));
        ExpressionSymbol expr = new ExpressionSymbol("expr", new Function("array_get", new Expression[] {as, new Constant(1)}));
        Query query = new Query();
        query.setSelect(new Select(Arrays.asList(expr)));
        helpTest(sql, "SELECT array_get(ARRAY_AGG(1), 1)", query);
    }
View Full Code Here

   
    helpTest(update, "UPDATE m.g1 SET e1 = 'abc' WHERE e2 = 'abc'"); //$NON-NLS-1$
  }
 
  public void testAggregateSymbol1() {
    AggregateSymbol agg = new AggregateSymbol("abc", NonReserved.COUNT, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
    helpTest(agg, "COUNT('abc')"); //$NON-NLS-1$
  }
View Full Code Here

    AggregateSymbol agg = new AggregateSymbol("abc", NonReserved.COUNT, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
    helpTest(agg, "COUNT('abc')"); //$NON-NLS-1$
  }
 
  public void testAggregateSymbol2() {
    AggregateSymbol agg = new AggregateSymbol("abc", NonReserved.COUNT, true, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
    helpTest(agg, "COUNT(DISTINCT 'abc')"); //$NON-NLS-1$
  }
View Full Code Here

TOP

Related Classes of org.teiid.query.sql.symbol.AggregateSymbol

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.