Package org.teiid.query.sql.symbol

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


  /**
   * Deep copy of object
   * @return Deep copy of object
   */
  public Object clone() {
      Expression copy = null;
      if(getExpression() != null) {
          copy = (Expression) getExpression().clone();
      }
        IsNullCriteria criteriaCopy = new IsNullCriteria(copy);
        criteriaCopy.setNegated(isNegated());
View Full Code Here


        Constant const1 = new Constant("a"); //$NON-NLS-1$
        Constant const2 = new Constant("b"); //$NON-NLS-1$
        ArrayList thens = new ArrayList();
        thens.add(const1);
        thens.add(const2);
        Expression elseExpression = new Constant("c"); //$NON-NLS-1$
        SearchedCaseExpression expr = new SearchedCaseExpression(whens, thens);
        expr.setElseExpression(elseExpression);
        expr.setType(DataTypeManager.DefaultDataClasses.STRING);
       
        SearchedCaseExpression clone = (SearchedCaseExpression)expr.clone();
View Full Code Here

                                                                QueryMetadataException,
                                                                TeiidComponentException {
        List<GroupSymbol> innerGroups = new ArrayList<GroupSymbol>();
        innerGroups.add(new GroupSymbol("pm1.g1")); //$NON-NLS-1$
       
        Expression expr = QueryParser.getQueryParser().parseExpression(expressionSQL);
       
        ResolverVisitor.resolveLanguageObject(expr, FakeMetadataFactory.example1Cached());
       
        assertEquals(dependent, JoinUtil.isNullDependent(FakeMetadataFactory.example1Cached(), innerGroups, expr));
    }
View Full Code Here

            case Statement.TYPE_DECLARE:
            case Statement.TYPE_ASSIGNMENT:
        ExpressionStatement exprStmt = (ExpressionStatement) statement;
        // replace variables to references, these references are later
        // replaced in the processor with variable values
        Expression expr = exprStmt.getExpression();
        if (expr != null) {
          expr = rewriteExpressionDirect(expr);
                  exprStmt.setExpression(expr);
        }
        return exprStmt;
View Full Code Here

      if (!AggregateSymbol.areAggregatesCardinalityDependent(aggs)) {
        return false;
      }
    } else if (query.getSelect().isDistinct()) {
      for (SingleElementSymbol projectSymbol : query.getSelect().getProjectedSymbols()) {
        Expression ex = SymbolMap.getExpression(projectSymbol);
              if (FunctionCollectorVisitor.isNonDeterministic(ex)) {
                return true;
              }
               if (!ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(ex).isEmpty()) {
                 return true;
View Full Code Here

        if (having != null) {
            aggs.addAll(AggregateSymbolCollectorVisitor.getAggregates(having, true));
        }
        for (AggregateSymbol aggregateSymbol : aggs) {
            if (aggregateSymbol.getExpression() != null) {
                Expression expr = aggregateSymbol.getExpression();
                newSelectColumns.add(SymbolMap.getExpression(expr));
            }
        }
        Select innerSelect = new Select();
        int index = 0;
View Full Code Here

          unrelatedItems.add(orderBy.getOrderByItems().get(i));
          isUnrelated = (querySymbol instanceof ExpressionSymbol);
          } else {
            querySymbol = (SingleElementSymbol)projectedSymbols.get(index);
          }
          Expression expr = SymbolMap.getExpression(querySymbol);
          if (!previousExpressions.add(expr) || (queryCommand instanceof Query && EvaluatableVisitor.willBecomeConstant(expr))) {
                orderBy.removeOrderByItem(i--);
          } else if (!isUnrelated) {
            orderBy.getOrderByItems().get(i).setSymbol((SingleElementSymbol)querySymbol.clone());
          } else {
View Full Code Here

        return rewriteCriteria(newCriteria);
    }

  private Criteria rewriteCriteria(CompareCriteria criteria) throws TeiidComponentException, TeiidProcessingException{
    Expression leftExpr = rewriteExpressionDirect(criteria.getLeftExpression());
    Expression rightExpr = rewriteExpressionDirect(criteria.getRightExpression());
    criteria.setLeftExpression(leftExpr);
    criteria.setRightExpression(rightExpr);

        if (isNull(leftExpr) || isNull(rightExpr)) {
            return UNKNOWN_CRITERIA;
View Full Code Here

        }
        CompareCriteria cc = new CompareCriteria();
        cc.setLeftExpression(criteria.getLeftExpression());
        Query q = createInlineViewQuery(new GroupSymbol("X"), criteria.getCommand(), metadata, criteria.getCommand().getProjectedSymbols()); //$NON-NLS-1$
        SingleElementSymbol ses = q.getProjectedSymbols().get(0);
        Expression expr = SymbolMap.getExpression(ses);
        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);
      }

        Expression leftExpr = rewriteExpressionDirect(criteria.getLeftExpression());
       
        if (isNull(leftExpr)) {
            return UNKNOWN_CRITERIA;
        }
       
View Full Code Here

        return criteria;
    }
   
    private Criteria simplifyWithInverse(CompareCriteria criteria) throws TeiidComponentException, TeiidProcessingException{
        Expression leftExpr = criteria.getLeftExpression();
       
        Function leftFunction = (Function) leftExpr;
        if(isSimpleMathematicalFunction(leftFunction)) {
            return simplifyMathematicalCriteria(criteria);
        }  
View Full Code Here

TOP

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

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.