use of org.teiid.query.sql.lang.Query in project teiid by teiid.
the class TestAccessNode method testOpen_Defect16059_2.
@Test
public void testOpen_Defect16059_2() throws Exception {
// $NON-NLS-1$
Query query = (Query) TestResolver.helpResolve("SELECT e1, e2 FROM pm1.g1 WHERE e2 = 5 AND ? IS NOT NULL", RealMetadataFactory.example1Cached());
IsNullCriteria nullCrit = (IsNullCriteria) ((CompoundCriteria) query.getCriteria()).getCriteria(1);
nullCrit.setExpression(new Constant(null));
helpTestOpen(query, null, false);
}
use of org.teiid.query.sql.lang.Query in project teiid by teiid.
the class TestStaticSymbolMappingVisitor method testVisitSubquerySetCriteria.
public void testVisitSubquerySetCriteria() {
SubquerySetCriteria ssc = new SubquerySetCriteria();
// $NON-NLS-1$
ssc.setExpression(new Function("length", new Expression[] { exampleElement(true, 0) }));
ssc.setCommand(new Query());
helpTest(ssc, getSymbolMap());
}
use of org.teiid.query.sql.lang.Query in project teiid by teiid.
the class TestCorrelatedReferenceCollectorVisitor method testDeepNesting.
@Test
public void testDeepNesting() throws Exception {
String sql = "select * from bqt1.smalla where exists (select intnum from bqt1.smalla x where smalla.intnum = x.intnum and exists (select intnum from bqt1.smalla where exists (select intnum from bqt1.smalla x where smalla.intnum = x.intnum)))";
Command command = TestResolver.helpResolve(sql, RealMetadataFactory.exampleBQTCached());
command = QueryRewriter.rewrite(command, RealMetadataFactory.exampleBQTCached(), null);
command = ((ExistsCriteria) ((Query) command).getCriteria()).getCommand();
LinkedList<Reference> correlatedReferences = new LinkedList<Reference>();
GroupSymbol gs = new GroupSymbol("bqt1.smalla");
ResolverUtil.resolveGroup(gs, RealMetadataFactory.exampleBQTCached());
CorrelatedReferenceCollectorVisitor.collectReferences(command, Arrays.asList(gs), correlatedReferences, RealMetadataFactory.exampleBQTCached());
assertEquals(1, correlatedReferences.size());
}
use of org.teiid.query.sql.lang.Query in project teiid by teiid.
the class TestSubqueryFromClause method example2.
public static SubqueryFromClause example2() {
Query query = new Query();
Select select = new Select();
// $NON-NLS-1$
select.addSymbol(new ElementSymbol("c"));
// $NON-NLS-1$
select.addSymbol(new ElementSymbol("d"));
query.setSelect(select);
From from = new From();
// $NON-NLS-1$
from.addGroup(new GroupSymbol("m.g2"));
query.setFrom(from);
CompareCriteria crit = new CompareCriteria();
// $NON-NLS-1$
crit.setLeftExpression(new ElementSymbol("c"));
crit.setRightExpression(new Constant(new Integer(10)));
crit.setOperator(CompareCriteria.EQ);
query.setCriteria(crit);
// $NON-NLS-1$
return new SubqueryFromClause("temp", query);
}
use of org.teiid.query.sql.lang.Query in project teiid by teiid.
the class TestSubqueryFromClause method example3.
public static SubqueryFromClause example3() {
Query query = new Query();
Select select = new Select();
// $NON-NLS-1$
select.addSymbol(new ElementSymbol("a"));
// $NON-NLS-1$
select.addSymbol(new ElementSymbol("b"));
query.setSelect(select);
From from = new From();
// $NON-NLS-1$
from.addGroup(new GroupSymbol("m.g"));
query.setFrom(from);
CompareCriteria crit = new CompareCriteria();
// $NON-NLS-1$
crit.setLeftExpression(new ElementSymbol("a"));
crit.setRightExpression(new Constant(new Integer(5)));
crit.setOperator(CompareCriteria.EQ);
query.setCriteria(crit);
// $NON-NLS-1$
return new SubqueryFromClause("temp2", query);
}
Aggregations