Package org.teiid.query.sql.lang

Examples of org.teiid.query.sql.lang.Criteria


        PlanNode limitNode = NodeEditor.findNodePreOrder(accessNode, NodeConstants.Types.TUPLE_LIMIT, NodeConstants.Types.SOURCE);
        if (limitNode != null && FrameUtil.isOrderedLimit(limitNode)) {
          return false;
        }
       
        Criteria crit = (Criteria) parentNode.getProperty(NodeConstants.Info.SELECT_CRITERIA);
       
        if(!CriteriaCapabilityValidatorVisitor.canPushLanguageObject(crit, modelID, metadata, capFinder, record) ) {
            return false;                       
        }
       
View Full Code Here


    // HELPERS
    // =====================================================================
   
    private static Criteria helpGetCriteria(String critString, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException, TeiidProcessingException{

        Criteria result = QueryParser.getQueryParser().parseCriteria(critString);
        QueryResolver.resolveCriteria(result, metadata);
        result = QueryRewriter.rewriteCriteria(result, null, new CommandContext(), metadata);

        return result;
    }
View Full Code Here

       
        return joinNode;
    }
   
    void helpTestEstimateCost(String critString, float childCost, float expectedResult, QueryMetadataInterface metadata) throws Exception {
        Criteria crit = helpGetCriteria(critString, metadata);
        PlanNode select = RelationalPlanner.createSelectNode(crit, false);
       
        float resultCost = NewCalculateCostUtil.recursiveEstimateCostOfCriteria(childCost, select, crit, metadata);
        assertEquals((int)expectedResult, (int)resultCost);
    }
View Full Code Here

  @Test public void testNegatedSetCriteria() throws Exception {
    DependentAccessNode dan = new DependentAccessNode(0);
    SetCriteria sc = new SetCriteria(new ElementSymbol("e1"), Arrays.asList(new Constant(1), new Constant(2))); //$NON-NLS-1$
    DependentCriteriaProcessor dcp = new DependentCriteriaProcessor(1, -1, dan, sc);
    Criteria result = dcp.prepareCriteria();
    assertEquals(new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.EQ, new Constant(1)), result); //$NON-NLS-1$
    assertTrue(dcp.hasNextCommand());
  }
View Full Code Here

    for (Reference reference : references) {
      cc.getVariableContext().setGlobalValue(reference.getContextSymbol(), 1);
    }
    SetCriteria sc = new SetCriteria(new ElementSymbol("e1"), references); //$NON-NLS-1$
    DependentCriteriaProcessor dcp = new DependentCriteriaProcessor(1, -1, dan, sc);
    Criteria result = dcp.prepareCriteria();
    assertEquals(new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.EQ, new Constant(1)), result); //$NON-NLS-1$
    assertFalse(dcp.hasNextCommand());
  }
View Full Code Here

        return result;
    }
   
  static void filterOptionalCriteria(List<Criteria> crits) {
    for (Iterator<Criteria> iter = crits.iterator(); iter.hasNext();) {
      Criteria crit = iter.next();
      if (crit instanceof CompareCriteria) {
        CompareCriteria cc = (CompareCriteria) crit;
        if (cc.isOptional()) {
          iter.remove();
        }
View Full Code Here

           
            if (critNode.hasBooleanProperty(NodeConstants.Info.IS_HAVING) || critNode.getGroups().size() != 0) {
                continue;
            }
           
            Criteria crit = (Criteria)critNode.getProperty(NodeConstants.Info.SELECT_CRITERIA);
            //if not evaluatable, just move on to the next criteria
            if (!EvaluatableVisitor.isFullyEvaluatable(crit, true)) {
                continue;
            }
            //if evaluatable
View Full Code Here

                            continue;
                        }
                       
                        if (sources.contains(accessNode1)) {
                            if (sources.contains(accessNode2) && sources.size() == 2) {
                                Criteria crit = (Criteria)critNode.getProperty(NodeConstants.Info.SELECT_CRITERIA);
                if (RuleRaiseAccess.isSupportedJoinCriteria(sjc, crit, modelId, metadata, capFinder, null)) {
                                  joinCriteriaNodes.add(critNode);
                                  joinCriteria.add(crit);
                                }
                            } else if (!accessNodes.containsAll(sources)) {
View Full Code Here

  public GroupSymbol exampleGroupSymbol(int number) {
    return new GroupSymbol("group." + number); //$NON-NLS-1$
  }
 
  public void helpTestReplacer(String critString, String expectedCrit, int numContexts) throws QueryParserException {
        Criteria crit = QueryParser.getQueryParser().parseCriteria(critString);
       
    Collection contexts = ContextReplacerVisitor.replaceContextFunctions(crit);
    assertTrue("Actual crit " +  crit + " didn't meet expected crit " + expectedCrit, expectedCrit.equalsIgnoreCase(crit.toString())); //$NON-NLS-1$ //$NON-NLS-2$
        assertTrue("Should've gotten " + numContexts + " but got " + contexts.size(), contexts.size() == numContexts); //$NON-NLS-1$ //$NON-NLS-2$
  }
View Full Code Here

                /* special handling is needed to determine criteria placement.
                 *
                 * if the join is a left outer join, criteria from the right side will be added to the on clause
                 */
                Criteria savedCriteria = null;
                buildQuery(accessRoot, left, query, metadata, capFinder);
                if (joinType == JoinType.JOIN_LEFT_OUTER) {
                    savedCriteria = query.getCriteria();
                    query.setCriteria(null);
                }
                buildQuery(accessRoot, right, query, metadata, capFinder);
                if (joinType == JoinType.JOIN_LEFT_OUTER) {
                    moveWhereClauseIntoOnClause(query, crits);
                    query.setCriteria(savedCriteria);
                }
               
                // Get last two clauses added to the FROM and combine them into a JoinPredicate
                From from = query.getFrom();
                List clauses = from.getClauses();
                int lastClause = clauses.size()-1;
                FromClause clause1 = (FromClause) clauses.get(lastClause-1);
                FromClause clause2 = (FromClause) clauses.get(lastClause);
                
                //correct the criteria or the join type if necessary
                if (joinType != JoinType.JOIN_CROSS && crits.isEmpty()) {
                    crits.add(QueryRewriter.TRUE_CRITERIA);
                } else if (joinType == JoinType.JOIN_CROSS && !crits.isEmpty()) {
                    joinType = JoinType.JOIN_INNER;
                }
               
                JoinPredicate jp = new JoinPredicate(clause1, clause2, joinType, crits);
               
                // Replace last two clauses with new predicate
                clauses.remove(lastClause);
                clauses.set(lastClause-1, jp);
                return;
            }
            case NodeConstants.Types.SOURCE:
            {
              if (Boolean.TRUE.equals(node.getProperty(NodeConstants.Info.INLINE_VIEW))) {
                    PlanNode child = node.getFirstChild();
                    QueryCommand newQuery = createQuery(metadata, capFinder, accessRoot, child);
                   
                    //ensure that the group is consistent
                    GroupSymbol symbol = node.getGroups().iterator().next();
                    SubqueryFromClause sfc = new SubqueryFromClause(symbol, newQuery);
                    query.getFrom().addClause(sfc);
                    return;
                }
                query.getFrom().addGroup(node.getGroups().iterator().next());
                break;
            }
      }
           
        for (PlanNode childNode : node.getChildren()) {
            buildQuery(accessRoot, childNode, query, metadata, capFinder);             
        }
           
        switch(node.getType()) {
            case NodeConstants.Types.SELECT:
            {
                Criteria crit = (Criteria) node.getProperty(NodeConstants.Info.SELECT_CRITERIA);      
                prepareSubqueries(node.getSubqueryContainers());
                if(!node.hasBooleanProperty(NodeConstants.Info.IS_HAVING)) {
                    query.setCriteria( CompoundCriteria.combineCriteria(query.getCriteria(), crit) );
                } else {
                    query.setHaving( CompoundCriteria.combineCriteria(query.getHaving(), crit) );                   
View Full Code Here

TOP

Related Classes of org.teiid.query.sql.lang.Criteria

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.