Examples of AggregateSymbol


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

    public TestAggregateImpl(String name) {
        super(name);
    }

    public static AggregateFunction example(String name, String functionName, boolean distinct, int value) throws Exception {
        AggregateSymbol symbol = new AggregateSymbol(name,
                                                     functionName,
                                                     distinct,
                                                      new Constant(new Integer(value)));
        return TstLanguageBridgeFactory.factory.translate(symbol);
       
View Full Code Here

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

    ElementSymbol col1 = new ElementSymbol("col1"); //$NON-NLS-1$
    col1.setType(Integer.class);
    ElementSymbol col2 = new ElementSymbol("col2"); //$NON-NLS-1$
    col2.setType(Integer.class);
    outputElements.add(col1);
    outputElements.add(new AggregateSymbol("countAll", "COUNT", false, null)); //$NON-NLS-1$ //$NON-NLS-2$
    outputElements.add(new AggregateSymbol("count", "COUNT", false, col2)); //$NON-NLS-1$ //$NON-NLS-2$
    outputElements.add(new AggregateSymbol("countDist", "COUNT", true, col2)); //$NON-NLS-1$ //$NON-NLS-2$
    outputElements.add(new AggregateSymbol("sum", "SUM", false, col2)); //$NON-NLS-1$ //$NON-NLS-2$
    outputElements.add(new AggregateSymbol("sumDist", "SUM", true, col2)); //$NON-NLS-1$ //$NON-NLS-2$
    outputElements.add(new AggregateSymbol("avg", "AVG", false, col2)); //$NON-NLS-1$ //$NON-NLS-2$
    outputElements.add(new AggregateSymbol("avgDist", "AVG", true, col2)); //$NON-NLS-1$ //$NON-NLS-2$
    outputElements.add(new AggregateSymbol("min", "MIN", false, col2)); //$NON-NLS-1$ //$NON-NLS-2$
    outputElements.add(new AggregateSymbol("minDist", "MIN", true, col2)); //$NON-NLS-1$ //$NON-NLS-2$
    outputElements.add(new AggregateSymbol("max", "MAX", false, col2)); //$NON-NLS-1$ //$NON-NLS-2$
    outputElements.add(new AggregateSymbol("maxDist", "MAX", true, col2)); //$NON-NLS-1$ //$NON-NLS-2$
    node.setElements(outputElements);
   
    List groupingElements = new ArrayList();
    groupingElements.add(col1);
    node.setGroupingElements(groupingElements);   
View Full Code Here

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

        bigDecimal.setType(DataTypeManager.DefaultDataClasses.BIG_DECIMAL);       

        // Set up
        GroupingNode node = new GroupingNode(1);       
        List outputElements = new ArrayList();
        outputElements.add(new AggregateSymbol("bigSum", "SUM", false, bigDecimal)); //$NON-NLS-1$ //$NON-NLS-2$
        outputElements.add(new AggregateSymbol("bigAvg", "AVG", false, bigDecimal)); //$NON-NLS-1$ //$NON-NLS-2$
        node.setElements(outputElements);
       
        // Set grouping elements to null
        node.setGroupingElements(null);        
        CommandContext context = new CommandContext("pid", "test", null, null, 1);               //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

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

        // Set up
        GroupingNode node = new GroupingNode(1);       
        List outputElements = new ArrayList();
        outputElements.add(col1);
        outputElements.add(new AggregateSymbol("bigSum", "SUM", false, bigDecimal)); //$NON-NLS-1$ //$NON-NLS-2$
        outputElements.add(new AggregateSymbol("bigAvg", "AVG", false, bigDecimal)); //$NON-NLS-1$ //$NON-NLS-2$
        node.setElements(outputElements);
       
        // Set grouping elements to null
        List groupingElements = new ArrayList();
        groupingElements.add(col1);
View Full Code Here

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

        FunctionDescriptor desc = FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, Integer.class } ); //$NON-NLS-1$
        func.setFunctionDescriptor(desc);
        func.setType(DataTypeManager.DefaultDataClasses.INTEGER);
       
        outputElements.add(col1);
        outputElements.add(new AggregateSymbol("count", "COUNT", false, func)); //$NON-NLS-1$ //$NON-NLS-2$
        outputElements.add(new AggregateSymbol("sum", "SUM", false, func)); //$NON-NLS-1$ //$NON-NLS-2$
        outputElements.add(new AggregateSymbol("sumDist", "SUM", true, func)); //$NON-NLS-1$ //$NON-NLS-2$
        node.setElements(outputElements);
       
        List groupingElements = new ArrayList();
        groupingElements.add(col1);
        node.setGroupingElements(groupingElements);  
View Full Code Here

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

        bigDecimal.setType(DataTypeManager.DefaultDataClasses.BIG_DECIMAL);       

        // Set up
        GroupingNode node = new GroupingNode(1);       
        List outputElements = new ArrayList();
        outputElements.add(new AggregateSymbol("bigSum", "SUM", false, bigDecimal)); //$NON-NLS-1$ //$NON-NLS-2$
        outputElements.add(new AggregateSymbol("bigAvg", "AVG", false, bigDecimal)); //$NON-NLS-1$ //$NON-NLS-2$
        node.setElements(outputElements);
       
        // Set grouping elements to null
        if (groupBy) {
            List groupingElements = new ArrayList();
View Full Code Here

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

        ElementSymbol col1 = new ElementSymbol("col1"); //$NON-NLS-1$
        col1.setType(Integer.class);
        ElementSymbol col2 = new ElementSymbol("col2"); //$NON-NLS-1$
        col2.setType(Integer.class);
        outputElements.add(col1);
        outputElements.add(new AggregateSymbol("countDist", "COUNT", true, col2)); //$NON-NLS-1$ //$NON-NLS-2$
        node.setElements(outputElements);
       
        List groupingElements = new ArrayList();
        groupingElements.add(col1);
        node.setGroupingElements(groupingElements);
View Full Code Here

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

             
                // More than 1 access node - replace with a union
              if (RelationalNodeUtil.isUpdate(accessNode.getCommand())) {
                update = true;
                GroupingNode groupNode = new GroupingNode(getID());                   
                AggregateSymbol sumCount = new AggregateSymbol("SumCount", NonReserved.SUM, false, (Expression)accessNode.getElements().get(0)); //$NON-NLS-1$             
                List<Expression> outputElements = new ArrayList<Expression>(1);               
                outputElements.add(sumCount);
                groupNode.setElements(outputElements);
                groupNode.addChild(unionNode);
               
                ProjectNode projectNode = new ProjectNode(getID());
               
                Expression intSum = ResolverUtil.getConversion(sumCount, DataTypeManager.getDataTypeName(sumCount.getType()), DataTypeManager.DefaultDataTypes.INTEGER, false, metadata.getFunctionLibrary());
               
                Expression rowCount = new ExpressionSymbol("RowCount", intSum); //$NON-NLS-1$               
                outputElements = new ArrayList<Expression>(1);               
                outputElements.add(rowCount);                
                projectNode.setElements(outputElements);
View Full Code Here

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

    } else if (rightExpr instanceof Constant) {
      if (((Constant)rightExpr).isNull()) {
        return false;
      }
    } else if (rightExpr instanceof AggregateSymbol) {
      AggregateSymbol as = (AggregateSymbol)rightExpr;
      if (as.getAggregateFunction() != Type.COUNT) {
        return false;
      }
    } else {
      return false;
    }
View Full Code Here

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

        q.getSelect().clearSymbols();
        AggregateSymbol.Type type = Type.MAX;
        if (criteria.getOperator() == CompareCriteria.GT || criteria.getOperator() == CompareCriteria.GE) {
          type = Type.MIN;
        }
        q.getSelect().addSymbol(new AggregateSymbol(ses.getName(), type.name(), false, expr));
        cc.setRightExpression(new ScalarSubquery(q));
      cc.setOperator(criteria.getOperator());
        return rewriteCriteria(cc);
      }
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.