Search in sources :

Example 61 with Criteria

use of org.teiid.query.sql.lang.Criteria in project teiid by teiid.

the class TestCalculateCostUtil method helpGetCriteria.

// =====================================================================
// 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, new CommandContext(), metadata);
    return result;
}
Also used : CommandContext(org.teiid.query.util.CommandContext) Criteria(org.teiid.query.sql.lang.Criteria)

Example 62 with Criteria

use of org.teiid.query.sql.lang.Criteria in project teiid by teiid.

the class TestJoinOptimization method helpTestNullDependentVisitor.

/**
 * Assumes that pm1.g1 is the only inner group
 */
private void helpTestNullDependentVisitor(String critSQL, boolean dependent) throws QueryParserException, QueryResolverException, QueryMetadataException, TeiidComponentException {
    List<GroupSymbol> innerGroups = new ArrayList<GroupSymbol>();
    // $NON-NLS-1$
    innerGroups.add(new GroupSymbol("pm1.g1"));
    Criteria crit = QueryParser.getQueryParser().parseCriteria(critSQL);
    QueryResolver.resolveCriteria(crit, RealMetadataFactory.example1Cached());
    assertEquals(dependent, JoinUtil.isNullDependent(RealMetadataFactory.example1Cached(), innerGroups, crit));
}
Also used : GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) ArrayList(java.util.ArrayList) Criteria(org.teiid.query.sql.lang.Criteria) SupportedJoinCriteria(org.teiid.translator.ExecutionFactory.SupportedJoinCriteria)

Example 63 with Criteria

use of org.teiid.query.sql.lang.Criteria in project teiid by teiid.

the class TestCriteriaCapabilityValidatorVisitor method helpTestVisitor.

public void helpTestVisitor(String sql, Object modelID, TransformationMetadata metadata, CapabilitiesFinder capFinder, boolean isValid, boolean expectException) throws Exception {
    try {
        Criteria criteria = QueryParser.getQueryParser().parseCriteria(sql);
        QueryResolver.resolveCriteria(criteria, metadata);
        // $NON-NLS-1$
        assertEquals("Got incorrect isValid flag", isValid, CriteriaCapabilityValidatorVisitor.canPushLanguageObject(criteria, modelID, metadata, capFinder, null));
    } catch (QueryMetadataException e) {
        if (!expectException) {
            throw new RuntimeException(e);
        }
    }
}
Also used : Criteria(org.teiid.query.sql.lang.Criteria) QueryMetadataException(org.teiid.api.exception.query.QueryMetadataException)

Example 64 with Criteria

use of org.teiid.query.sql.lang.Criteria in project teiid by teiid.

the class TestDependentCriteriaProcessor method testEvaluatedSetCriteria.

@Test
public void testEvaluatedSetCriteria() throws Exception {
    DependentAccessNode dan = new DependentAccessNode(0);
    CommandContext cc = new CommandContext();
    dan.setContext(cc);
    List<Reference> references = Arrays.asList(new Reference(1), new Reference(2));
    for (Reference reference : references) {
        cc.getVariableContext().setGlobalValue(reference.getContextSymbol(), 1);
    }
    // $NON-NLS-1$
    SetCriteria sc = new SetCriteria(new ElementSymbol("e1"), references);
    sc.setAllConstants(true);
    DependentCriteriaProcessor dcp = new DependentCriteriaProcessor(1, -1, dan, sc);
    Criteria result = dcp.prepareCriteria();
    // $NON-NLS-1$
    assertEquals(new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.EQ, new Constant(1)), result);
    assertFalse(dcp.hasNextCommand());
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) CommandContext(org.teiid.query.util.CommandContext) Reference(org.teiid.query.sql.symbol.Reference) Constant(org.teiid.query.sql.symbol.Constant) SetCriteria(org.teiid.query.sql.lang.SetCriteria) CompareCriteria(org.teiid.query.sql.lang.CompareCriteria) SetCriteria(org.teiid.query.sql.lang.SetCriteria) Criteria(org.teiid.query.sql.lang.Criteria) CompareCriteria(org.teiid.query.sql.lang.CompareCriteria) Test(org.junit.Test)

Example 65 with Criteria

use of org.teiid.query.sql.lang.Criteria in project teiid by teiid.

the class TestWhileStatement method sample1.

// ################################## TEST HELPERS ################################
public static final WhileStatement sample1() {
    Block block = TestBlock.sample1();
    Criteria criteria = TestSetCriteria.sample1();
    return new WhileStatement(criteria, block);
}
Also used : TestSetCriteria(org.teiid.query.sql.lang.TestSetCriteria) Criteria(org.teiid.query.sql.lang.Criteria)

Aggregations

Criteria (org.teiid.query.sql.lang.Criteria)67 CompareCriteria (org.teiid.query.sql.lang.CompareCriteria)40 PlanNode (org.teiid.query.optimizer.relational.plantree.PlanNode)35 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)22 Expression (org.teiid.query.sql.symbol.Expression)22 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)22 CompoundCriteria (org.teiid.query.sql.lang.CompoundCriteria)19 ArrayList (java.util.ArrayList)16 List (java.util.List)15 DependentSetCriteria (org.teiid.query.sql.lang.DependentSetCriteria)13 IsNullCriteria (org.teiid.query.sql.lang.IsNullCriteria)12 Constant (org.teiid.query.sql.symbol.Constant)11 SymbolMap (org.teiid.query.sql.util.SymbolMap)11 JoinType (org.teiid.query.sql.lang.JoinType)10 SetCriteria (org.teiid.query.sql.lang.SetCriteria)10 LinkedList (java.util.LinkedList)7 Reference (org.teiid.query.sql.symbol.Reference)6 LinkedHashSet (java.util.LinkedHashSet)5 LanguageObject (org.teiid.query.sql.LanguageObject)5 Collection (java.util.Collection)4