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;
}
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));
}
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);
}
}
}
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());
}
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);
}
Aggregations