Examples of AggregateSymbol


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

    int equals = 0;
    UnitTestUtil.helpTestEquivalence(equals, test, test);
  }

  public void testEquivalence(){
    AggregateSymbol test1 = new AggregateSymbol("x", NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
    AggregateSymbol test2 = new AggregateSymbol("x", NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
    int equals = 0;
    UnitTestUtil.helpTestEquivalence(equals, test1, test2);
  }
View Full Code Here

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

    int equals = 0;
    UnitTestUtil.helpTestEquivalence(equals, test1, test2);
  }
   
    public void testEquivalenceCountStar(){
        AggregateSymbol test1 = new AggregateSymbol("x", NonReserved.COUNT, false, null); //$NON-NLS-1$
        AggregateSymbol test2 = new AggregateSymbol("x", NonReserved.COUNT, false, null); //$NON-NLS-1$
        int equals = 0;
        UnitTestUtil.helpTestEquivalence(equals, test1, test2);
    }
View Full Code Here

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

        int equals = 0;
        UnitTestUtil.helpTestEquivalence(equals, test1, test2);
    }

  public void testEquivalenceCaseInsens(){
    AggregateSymbol test1 = new AggregateSymbol("x", NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
    AggregateSymbol test2 = new AggregateSymbol("X", NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
    int equals = 0;
    UnitTestUtil.helpTestEquivalence(equals, test1, test2);
  }
View Full Code Here

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

    int equals = 0;
    UnitTestUtil.helpTestEquivalence(equals, test1, test2);
  }
   
    public void testNonEquivalenceUsingDiffElements(){
        AggregateSymbol test1 = new AggregateSymbol("x", NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
        AggregateSymbol test2 = new AggregateSymbol("X", NonReserved.COUNT, true, sampleElement2()); //$NON-NLS-1$
        int equals = -1;
        UnitTestUtil.helpTestEquivalence(equals, test1, test2);
    }
View Full Code Here

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

        int equals = -1;
        UnitTestUtil.helpTestEquivalence(equals, test1, test2);
    }
 
  public void testNonEquivalence(){
    AggregateSymbol test1 = new AggregateSymbol("x", NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
    AggregateSymbol test2 = new AggregateSymbol("y", NonReserved.COUNT, true, sampleElement2()); //$NON-NLS-1$
    int equals = -1;
    UnitTestUtil.helpTestEquivalence(equals, test1, test2);
  }
View Full Code Here

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

    int equals = -1;
    UnitTestUtil.helpTestEquivalence(equals, test1, test2);
  }
   
    public void testNonEquivalence1(){
        AggregateSymbol test1 = new AggregateSymbol("x", NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
        AggregateSymbol test2 = new AggregateSymbol("x", NonReserved.COUNT, true, sampleElement2()); //$NON-NLS-1$
        int equals = -1;
        UnitTestUtil.helpTestEquivalence(equals, test1, test2);
    }
View Full Code Here

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

        int equals = -1;
        UnitTestUtil.helpTestEquivalence(equals, test1, test2);
    }
   
    public void testNonEquivalence2(){
        AggregateSymbol test1 = new AggregateSymbol("x", NonReserved.MAX, true, sampleElement()); //$NON-NLS-1$
        AggregateSymbol test2 = new AggregateSymbol("x", NonReserved.COUNT, true, sampleElement2()); //$NON-NLS-1$
        int equals = -1;
        UnitTestUtil.helpTestEquivalence(equals, test1, test2);
    }
View Full Code Here

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

     * we simulate that situation here using the same aggregate twice in
     * a function.
     */
    @Test public void testRecursionDetection() {
      ElementSymbol e1 = new ElementSymbol("e1"); //$NON-NLS-1$
      AggregateSymbol a1 = new AggregateSymbol("x", NonReserved.SUM, false, e1); //$NON-NLS-1$
      Function f = new Function(SourceSystemFunctions.ADD_OP, new Expression[] {a1, a1});
      HashMap<AggregateSymbol, AggregateSymbol> map = new HashMap<AggregateSymbol, AggregateSymbol>();
      map.put(a1, new AggregateSymbol("x", NonReserved.SUM, false, a1)); //$NON-NLS-1$
      ExpressionMappingVisitor.mapExpressions(f, map);
        assertEquals("(SUM(SUM(e1)) + SUM(SUM(e1)))", f.toString()); //$NON-NLS-1$
    }
View Full Code Here

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

        for(int i=0; i<getElements().size(); i++) {
            SingleElementSymbol symbol = (SingleElementSymbol)getElements().get(i);
            Class<?> outputType = symbol.getType();
            Class<?> inputType = symbol.getType();
            if(symbol instanceof AggregateSymbol) {
                AggregateSymbol aggSymbol = (AggregateSymbol) symbol;
               
                if(aggSymbol.getExpression() == null) {
                    functions[i] = new Count();
                } else {
                  Expression ex = aggSymbol.getExpression();
                  inputType = ex.getType();
                  int index = collectExpression(ex);
                  Type function = aggSymbol.getAggregateFunction();
                  switch (function) {
                  case COUNT:
                    functions[i] = new Count();
                    break;
                  case SUM:
                    functions[i] = new Sum();
                    break;
                  case AVG:
                    functions[i] = new Avg();
                    break;
                  case MIN:
                    functions[i] = new Min();
                    break;
                  case MAX:
                    functions[i] = new Max();
                    break;
                  case XMLAGG:
                    functions[i] = new XMLAgg(context);
                    break;
                  case ARRAY_AGG:
                    functions[i] = new ArrayAgg(context);
                    break;                   
                  case TEXTAGG:
                     functions[i] = new TextAgg(context, (TextLine)ex);
                    break;                   
                  default:
                    functions[i] = new StatsFunction(function);
                 
                  }

                    if(aggSymbol.isDistinct() && !function.equals(NonReserved.MIN) && !function.equals(NonReserved.MAX)) {
                        SortingFilter filter = new SortingFilter(functions[i], getBufferManager(), getConnectionID(), true);
                        ElementSymbol element = new ElementSymbol("val"); //$NON-NLS-1$
                        element.setType(inputType);
                        filter.setElements(Arrays.asList(element));
                        functions[i] = filter;
                    } else if (aggSymbol.getOrderBy() != null) { //handle the xmlagg case
                    int[] orderIndecies = new int[aggSymbol.getOrderBy().getOrderByItems().size()];
                    List<OrderByItem> orderByItems = new ArrayList<OrderByItem>(orderIndecies.length);
                    List<ElementSymbol> schema = new ArrayList<ElementSymbol>(orderIndecies.length + 1);
                    ElementSymbol element = new ElementSymbol("val"); //$NON-NLS-1$
                        element.setType(inputType);
                        schema.add(element);
                    for (ListIterator<OrderByItem> iterator = aggSymbol.getOrderBy().getOrderByItems().listIterator(); iterator.hasNext();) {
                      OrderByItem item = iterator.next();
                      orderIndecies[iterator.previousIndex()] = collectExpression(item.getSymbol());
                      element = new ElementSymbol(String.valueOf(iterator.previousIndex()));
                            element.setType(inputType);
                      schema.add(element);
View Full Code Here

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
TOP
Copyright © 2018 www.massapi.com. 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.