use of org.teiid.query.sql.lang.ExistsCriteria.SubqueryHint in project teiid by teiid.
the class ODataSQLBuilder method buildAggregateQuery.
private void buildAggregateQuery(DocumentNode node, Query outerQuery, ExpandDocumentNode expandResource, OrderBy expandOrder, Query query, EdmNavigationProperty navigationProperty) throws TeiidException {
Select select = query.getSelect();
Array array = new Array(Object.class, new ArrayList<Expression>(select.getSymbols()));
select.getSymbols().clear();
AggregateSymbol symbol = new AggregateSymbol(AggregateSymbol.Type.ARRAY_AGG.name(), false, array);
select.addSymbol(symbol);
symbol.setOrderBy(expandOrder);
Criteria crit = node.buildJoinCriteria(expandResource, navigationProperty);
if (crit != null) {
query.setCriteria(Criteria.combineCriteria(crit, query.getCriteria()));
}
// else assertion error?
expandResource.setColumnIndex(outerQuery.getSelect().getCount() + 1);
ScalarSubquery agg = new ScalarSubquery(query);
SubqueryHint subqueryHint = new SubqueryHint();
subqueryHint.setMergeJoin(true);
agg.setSubqueryHint(subqueryHint);
outerQuery.getSelect().addSymbol(agg);
}
use of org.teiid.query.sql.lang.ExistsCriteria.SubqueryHint in project teiid by teiid.
the class SQLParserUtil method getSubqueryHint.
SubqueryHint getSubqueryHint(Token t) {
SubqueryHint hint = new SubqueryHint();
// $NON-NLS-1$
String[] parts = getComment(t).split("\\s");
for (int i = 0; i < parts.length; i++) {
if (parts[i].equalsIgnoreCase(SubqueryHint.MJ)) {
hint.setMergeJoin(true);
} else if (parts[i].equalsIgnoreCase(SubqueryHint.NOUNNEST)) {
hint.setNoUnnest(true);
} else if (parts[i].equalsIgnoreCase(SubqueryHint.DJ)) {
hint.setDepJoin();
}
}
return hint;
}
use of org.teiid.query.sql.lang.ExistsCriteria.SubqueryHint in project teiid by teiid.
the class TestSQLStringVisitor method testScalarSubqueryWithHint.
@Test
public void testScalarSubqueryWithHint() {
Select s1 = new Select();
// $NON-NLS-1$
s1.addSymbol(new ElementSymbol("e1"));
From f1 = new From();
// $NON-NLS-1$
f1.addGroup(new GroupSymbol("m.g1"));
Query q1 = new Query();
q1.setSelect(s1);
q1.setFrom(f1);
ScalarSubquery obj = new ScalarSubquery(q1);
SubqueryHint subqueryHint = new SubqueryHint();
subqueryHint.setMergeJoin(true);
obj.setSubqueryHint(subqueryHint);
// $NON-NLS-1$
helpTest(obj, " /*+ MJ */ (SELECT e1 FROM m.g1)");
}
Aggregations