Search in sources :

Example 1 with Operator

use of org.teiid.language.Comparison.Operator in project teiid by teiid.

the class LanguageBridgeFactory method translate.

org.teiid.language.Comparison translate(DependentSetCriteria criteria) {
    Operator operator = Operator.EQ;
    org.teiid.language.Expression arg = null;
    final TupleBuffer tb = criteria.getDependentValueSource().getTupleBuffer();
    if (criteria.getValueExpression() instanceof Array) {
        Array array = (Array) criteria.getValueExpression();
        List<org.teiid.language.Expression> params = new ArrayList<org.teiid.language.Expression>();
        Class<?> baseType = null;
        for (Expression ex : array.getExpressions()) {
            if (baseType == null) {
                baseType = ex.getType();
            } else if (!baseType.equals(ex.getType())) {
                baseType = DataTypeManager.DefaultDataClasses.OBJECT;
            }
            params.add(createParameter(criteria, tb, ex));
        }
        arg = new org.teiid.language.Array(baseType, params);
    } else {
        Expression ex = criteria.getValueExpression();
        arg = createParameter(criteria, tb, ex);
    }
    if (this.dependentSets == null) {
        this.dependentSets = new HashMap<String, List<? extends List<?>>>();
    }
    this.dependentSets.put(criteria.getContextSymbol(), new TupleBufferList(tb));
    Comparison result = new org.teiid.language.Comparison(translate(criteria.getExpression()), arg, operator);
    return result;
}
Also used : Operator(org.teiid.language.Comparison.Operator) TupleBuffer(org.teiid.common.buffer.TupleBuffer) org.teiid.language(org.teiid.language) Array(org.teiid.query.sql.symbol.Array) SearchedCaseExpression(org.teiid.query.sql.symbol.SearchedCaseExpression) Expression(org.teiid.query.sql.symbol.Expression)

Example 2 with Operator

use of org.teiid.language.Comparison.Operator in project teiid by teiid.

the class LanguageBridgeFactory method translate.

SubqueryComparison translate(SubqueryCompareCriteria criteria) {
    Quantifier quantifier = Quantifier.ALL;
    switch(criteria.getPredicateQuantifier()) {
        case SubqueryCompareCriteria.ALL:
            quantifier = Quantifier.ALL;
            break;
        case SubqueryCompareCriteria.ANY:
            quantifier = Quantifier.SOME;
            break;
        case SubqueryCompareCriteria.SOME:
            quantifier = Quantifier.SOME;
            break;
    }
    Operator operator = Operator.EQ;
    switch(criteria.getOperator()) {
        case SubqueryCompareCriteria.EQ:
            operator = Operator.EQ;
            break;
        case SubqueryCompareCriteria.NE:
            operator = Operator.NE;
            break;
        case SubqueryCompareCriteria.LT:
            operator = Operator.LT;
            break;
        case SubqueryCompareCriteria.LE:
            operator = Operator.LE;
            break;
        case SubqueryCompareCriteria.GT:
            operator = Operator.GT;
            break;
        case SubqueryCompareCriteria.GE:
            operator = Operator.GE;
            break;
    }
    return new SubqueryComparison(translate(criteria.getLeftExpression()), operator, quantifier, translate(criteria.getCommand()));
}
Also used : Operator(org.teiid.language.Comparison.Operator) Quantifier(org.teiid.language.SubqueryComparison.Quantifier)

Aggregations

Operator (org.teiid.language.Comparison.Operator)2 TupleBuffer (org.teiid.common.buffer.TupleBuffer)1 org.teiid.language (org.teiid.language)1 Quantifier (org.teiid.language.SubqueryComparison.Quantifier)1 Array (org.teiid.query.sql.symbol.Array)1 Expression (org.teiid.query.sql.symbol.Expression)1 SearchedCaseExpression (org.teiid.query.sql.symbol.SearchedCaseExpression)1