Package org.teiid.query.sql.lang

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


        Select s2 = new Select();
        s2.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
        From f2 = new From();
        f2.addGroup(new GroupSymbol("m.g2"));        //$NON-NLS-1$
        ExistsCriteria existsCrit = new ExistsCriteria(q1);
        existsCrit.getSubqueryHint().setMergeJoin(semiJoin);
        Query q2 = new Query();
        q2.setSelect(s2);
        q2.setFrom(f2);
        q2.setCriteria(existsCrit);
    return q2;
View Full Code Here


      }
      result.query = query;
      result.additionalCritieria = (Criteria)new CompareCriteria(scc.getLeftExpression(), scc.getOperator(), rightExpr).clone();
    }
    if (crit instanceof ExistsCriteria) {
      ExistsCriteria exists = (ExistsCriteria)crit;
      if (exists.getSubqueryHint().isNoUnnest()) {
        return result;
      }
      if (!(exists.getCommand() instanceof Query)) {
        return result;
      }
      result.type = crit.getClass();
      result.not = exists.isNegated();
      //the correlations can only be in where (if no group by or aggregates) or having
      result.query = (Query)exists.getCommand();
      result.mergeJoin = exists.getSubqueryHint().isMergeJoin();
      if (!UNNEST && !result.mergeJoin) {
        return result;
      }
    }
    return result;
View Full Code Here

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

    public static ExistsCriteria helpExample(boolean negated) {
        ExistsCriteria crit = new ExistsCriteria(TestQueryImpl.helpExample(true));
        crit.setNegated(negated);
        return crit;
    }
View Full Code Here

                throw new QueryPlannerException(QueryPlugin.Util.getString("XMLQueryPlanner.cannot_plan", rsInfo.getCriteria())); //$NON-NLS-1$
            }
           
            Query subQuery = QueryUtil.wrapQuery(new SubqueryFromClause(inlineViewName, command), inlineViewName);

            currentQuery.setCriteria(Criteria.combineCriteria(currentQuery.getCriteria(), new ExistsCriteria(subQuery)));
           
            currentQuery = subQuery;
        }
       
        Criteria userCrit = (Criteria)rsInfo.getCriteria().clone();
View Full Code Here

    } else if(criteria instanceof HasCriteria) {
            criteria = rewriteCriteria((HasCriteria)criteria);
    } else if(criteria instanceof TranslateCriteria) {
            criteria = rewriteCriteria((TranslateCriteria)criteria);
    } else if (criteria instanceof ExistsCriteria) {
      ExistsCriteria exists = (ExistsCriteria)criteria;
      if (exists.shouldEvaluate() && processing) {
            return getCriteria(evaluator.evaluate(exists, null));
          }
        rewriteSubqueryContainer((SubqueryContainer)criteria, true);
      if (!RelationalNodeUtil.shouldExecute(exists.getCommand(), false, true)) {
              return exists.isNegated()?TRUE_CRITERIA:FALSE_CRITERIA;
            }
        if (exists.getCommand().getProcessorPlan() == null) {
          if (exists.getCommand() instanceof Query) {
          Query query = (Query)exists.getCommand();
          if ((query.getLimit() == null || query.getOrderBy() == null) && query.getSelect().getProjectedSymbols().size() > 1) {
            query.getSelect().clearSymbols();
            query.getSelect().addSymbol(new ExpressionSymbol("x", new Constant(1))); //$NON-NLS-1$
          }
        }
View Full Code Here

    @Test public void testSetCriteria6() throws Exception {
        helpTestSetCriteria(null, false, false);
    }
   
    @Test public void testExistsCriteria() throws Exception {
        ExistsCriteria crit = new ExistsCriteria(new Query());
        ArrayList values = new ArrayList();
        values.add("a"); //$NON-NLS-1$
        values.add("b"); //$NON-NLS-1$
        values.add("c"); //$NON-NLS-1$
        helpTestCompareSubqueryCriteria(crit, true, values);
View Full Code Here

        values.add("c"); //$NON-NLS-1$
        helpTestCompareSubqueryCriteria(crit, true, values);
    }

    @Test public void testExistsCriteria2() throws Exception {
        ExistsCriteria crit = new ExistsCriteria(new Query());
        helpTestCompareSubqueryCriteria(crit, false, Collections.emptyList());
    }
View Full Code Here

    /**
     * If rows are returned but they contain null, the result should
     * still be true.
     */
    @Test public void testExistsCriteria3() throws Exception {
        ExistsCriteria crit = new ExistsCriteria(new Query());
        ArrayList values = new ArrayList();
        values.add(null);
        values.add(null);
        values.add(null);
        helpTestCompareSubqueryCriteria(crit, true, values);
View Full Code Here

        f1.addGroup(new GroupSymbol("m.g1"));        //$NON-NLS-1$
        Query q1 = new Query();
        q1.setSelect(s1);
        q1.setFrom(f1);

        ExistsCriteria ec = new ExistsCriteria(q1);

        helpTest(ec, "EXISTS (SELECT e1 FROM m.g1)");             //$NON-NLS-1$
    }
View Full Code Here

        s2.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
        s2.addSymbol(new ExpressionSymbol("blargh", new ScalarSubquery(q1))); //$NON-NLS-1$
        From f2 = new From();
        f2.addGroup(new GroupSymbol("m.g2"));        //$NON-NLS-1$
        Criteria left = new SubqueryCompareCriteria(new ElementSymbol("e3"), q1, SubqueryCompareCriteria.GE, SubqueryCompareCriteria.ANY); //$NON-NLS-1$
        Criteria right = new ExistsCriteria(q1);
        Criteria outer = new CompoundCriteria(CompoundCriteria.AND, left, right);
        Query q2 = new Query();
        q2.setSelect(s2);
        q2.setFrom(f2);
        q2.setCriteria(outer);
View Full Code Here

TOP

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

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.