Search in sources :

Example 1 with SubqueryHint

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);
}
Also used : Array(org.teiid.query.sql.symbol.Array) AggregateSymbol(org.teiid.query.sql.symbol.AggregateSymbol) ScalarSubquery(org.teiid.query.sql.symbol.ScalarSubquery) Expression(org.teiid.query.sql.symbol.Expression) SubqueryHint(org.teiid.query.sql.lang.ExistsCriteria.SubqueryHint)

Example 2 with SubqueryHint

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;
}
Also used : SubqueryHint(org.teiid.query.sql.lang.ExistsCriteria.SubqueryHint) SubqueryHint(org.teiid.query.sql.lang.ExistsCriteria.SubqueryHint)

Example 3 with SubqueryHint

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)");
}
Also used : SubqueryHint(org.teiid.query.sql.lang.ExistsCriteria.SubqueryHint) Test(org.junit.Test)

Aggregations

SubqueryHint (org.teiid.query.sql.lang.ExistsCriteria.SubqueryHint)3 Test (org.junit.Test)1 AggregateSymbol (org.teiid.query.sql.symbol.AggregateSymbol)1 Array (org.teiid.query.sql.symbol.Array)1 Expression (org.teiid.query.sql.symbol.Expression)1 ScalarSubquery (org.teiid.query.sql.symbol.ScalarSubquery)1