Package org.teiid.query.sql.symbol

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


       
        Function func = new Function("concat", new Expression[] { es1, new Constant("abc")}); //$NON-NLS-1$ //$NON-NLS-2$
        FunctionDescriptor fd = FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("concat", new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING }); //$NON-NLS-1$
        func.setFunctionDescriptor(fd);
        func.setType(DataTypeManager.DefaultDataClasses.STRING);
        ExpressionSymbol expr = new ExpressionSymbol("expr", func); //$NON-NLS-1$
        List projectElements = new ArrayList();
        projectElements.add(expr);
       
        List[] data = new List[] {
            Arrays.asList(new Object[] { "1" })//$NON-NLS-1$
View Full Code Here


       
        Function func = new Function("convert", new Expression[] { es1, new Constant("integer")}); //$NON-NLS-1$ //$NON-NLS-2$
        FunctionDescriptor fd = FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("convert", new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING }); //$NON-NLS-1$
        func.setFunctionDescriptor(fd);
        func.setType(DataTypeManager.DefaultDataClasses.INTEGER);
        ExpressionSymbol expr = new ExpressionSymbol("expr", func); //$NON-NLS-1$
        List projectElements = new ArrayList();
        projectElements.add(expr);
       
        List[] data = new List[] {
            Arrays.asList(new Object[] { "1" })//$NON-NLS-1$
View Full Code Here

        Function func = new Function("lookup", new Expression[] { new Constant("pm1.g1"), new Constant("e2"), new Constant("e1"), es1 }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        FunctionDescriptor desc = FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, String.class } ); //$NON-NLS-1$
        func.setFunctionDescriptor(desc);
        func.setType(DataTypeManager.DefaultDataClasses.STRING);
       
        ExpressionSymbol expr = new ExpressionSymbol("expr", func); //$NON-NLS-1$
        List projectElements = new ArrayList();
        projectElements.add(expr);
       
        List[] data = new List[] {
            Arrays.asList(new Object[] { "1" })//$NON-NLS-1$
View Full Code Here

        for (Expression expression : expressions) {
            if (expression instanceof SingleElementSymbol) {
                result.add((SingleElementSymbol)expression);
                continue;
            }
            ExpressionSymbol expressionSymbol = uniqueExpressions.get(expression);
            if (expressionSymbol == null) {
                expressionSymbol = new ExpressionSymbol("$" + EXPRESSION_INDEX.getAndIncrement(), expression); //$NON-NLS-1$
                expressionSymbol.setDerivedExpression(true);
                uniqueExpressions.put(expression, expressionSymbol);
            }
            result.add(expressionSymbol);
        }
        return result;
View Full Code Here

     * be called supports expression in group by.  Thus the example below
     * is not supported.
     */
    public void testSupportsFunctionInGroupBy() throws Exception {
        Function f = new Function("concat", new Expression[] { new Constant("a"), new Constant("b") }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        ExpressionSymbol expr = new ExpressionSymbol("e", f); //$NON-NLS-1$
        List cols = new ArrayList();
        cols.add(expr);
        helpTestSupportsAggregates(false, false, cols);
    }
View Full Code Here

          if (pushdown) {
            projectedViewSymbols.add(agg);
          } else {
            if (agg.getAggregateFunction() == Type.COUNT) {
              if (agg.getExpression() == null) {
              projectedViewSymbols.add(new ExpressionSymbol("stagedAgg", new Constant(1))); //$NON-NLS-1$
              } else {
                SearchedCaseExpression count = new SearchedCaseExpression(Arrays.asList(new IsNullCriteria(agg.getExpression())), Arrays.asList(new Constant(Integer.valueOf(0))));
                count.setElseExpression(new Constant(Integer.valueOf(1)));
                count.setType(DataTypeManager.DefaultDataClasses.INTEGER);
              projectedViewSymbols.add(new ExpressionSymbol("stagedAgg", count)); //$NON-NLS-1$
              }
            } else { //min, max, sum
              Expression ex = agg.getExpression();
              ex = ResolverUtil.convertExpression(ex, DataTypeManager.getDataTypeName(agg.getType()), metadata);
              projectedViewSymbols.add(new ExpressionSymbol("stagedAgg", ex)); //$NON-NLS-1$
            }
          }
    }

        if (pushdown) {
View Full Code Here

    if (!CapabilitiesUtil.useAnsiJoin(RuleRaiseAccess.getModelIDFromAccess(accessRoot, metadata), metadata, capFinder)) {
      simplifyFromClause(query);
        }
    if (columns.isEmpty()) {
          if (CapabilitiesUtil.supports(Capability.QUERY_SELECT_EXPRESSION, RuleRaiseAccess.getModelIDFromAccess(accessRoot, metadata), metadata, capFinder)) {
            select.addSymbol(new ExpressionSymbol("dummy", new Constant(1))); //$NON-NLS-1$
          } else {
            //TODO: need to ensure the type is consistent 
            //- should be rare as the source would typically support select expression if it supports union
            select.addSymbol(selectOutputElement(query.getFrom().getGroups(), metadata));
          }
View Full Code Here

                       
                        ss = ((AliasSymbol)ss).getSymbol();
                    }
                   
                    if (ss instanceof ExpressionSymbol && !(ss instanceof AggregateSymbol)) {
                        ExpressionSymbol exprSymbol = (ExpressionSymbol)ss;
                       
                        if (!exprSymbol.isDerivedExpression()) {
                            createdSymbols.add(ss);
                        }
                    }
                    AggregateSymbolCollectorVisitor.getAggregates(ss, requiredSymbols, requiredSymbols);                       
                }
        break;
            }
      case NodeConstants.Types.SELECT:
        Criteria selectCriteria = (Criteria) node.getProperty(NodeConstants.Info.SELECT_CRITERIA);
                AggregateSymbolCollectorVisitor.getAggregates(selectCriteria, requiredSymbols, requiredSymbols);
        break;
      case NodeConstants.Types.JOIN:
        List<Criteria> crits = (List) node.getProperty(NodeConstants.Info.JOIN_CRITERIA);
        if(crits != null) {
          for (Criteria joinCriteria : crits) {
            AggregateSymbolCollectorVisitor.getAggregates(joinCriteria, requiredSymbols, requiredSymbols);
          }
        }
        break;
      case NodeConstants.Types.GROUP:
        List<SingleElementSymbol> groupCols = (List<SingleElementSymbol>) node.getProperty(NodeConstants.Info.GROUP_COLS);
        if(groupCols != null) {
            for (SingleElementSymbol expression : groupCols) {
                        if(expression instanceof ElementSymbol || expression instanceof AggregateSymbol) {
                            requiredSymbols.add(expression);
                        } else {   
                            ExpressionSymbol exprSymbol = (ExpressionSymbol) expression;
                            Expression expr = exprSymbol.getExpression();
                            AggregateSymbolCollectorVisitor.getAggregates(expr, requiredSymbols, requiredSymbols);
                            createdSymbols.add(exprSymbol);
                        }
                    }
        }
View Full Code Here

        String sqlBefore = "SELECT CASE 'x' WHEN 'Old Inventory System' THEN NULL WHEN 'New Inventory System' THEN NULL END"; //$NON-NLS-1$
        String sqlAfter = "SELECT null"; //$NON-NLS-1$

        Command cmd = helpTestRewriteCommand( sqlBefore, sqlAfter );
       
        ExpressionSymbol es = (ExpressionSymbol)cmd.getProjectedSymbols().get(0);
        assertEquals( DataTypeManager.DefaultDataClasses.STRING, es.getType() );
    }
View Full Code Here

      if(ss instanceof AliasSymbol) {
                ss = ((AliasSymbol)ss).getSymbol();
            }
           
            if (ss instanceof ExpressionSymbol && !(ss instanceof AggregateSymbol)) {
                ExpressionSymbol exprSymbol = (ExpressionSymbol)ss;
               
                if (!exprSymbol.isDerivedExpression()) {
                    return root; //TODO: insert a new project node to handle this case
                }
            }
      if (!childOutputCols.contains(ss)) {
        return root;
View Full Code Here

TOP

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

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.