Search in sources :

Example 1 with SubqueryIn

use of org.teiid.language.SubqueryIn in project teiid by teiid.

the class PhoenixExecutionFactory method translate.

/**
 * Adding a specific workaround for just Pheonix and BigDecimal.
 */
@Override
public List<?> translate(LanguageObject obj, ExecutionContext context) {
    if (obj instanceof SubqueryIn) {
        SubqueryIn in = (SubqueryIn) obj;
        return Arrays.asList(new SubqueryComparison(in.getLeftExpression(), in.isNegated() ? Operator.NE : Operator.EQ, in.isNegated() ? Quantifier.ALL : Quantifier.SOME, in.getSubquery()));
    }
    if (!(obj instanceof Literal)) {
        return super.translate(obj, context);
    }
    Literal l = (Literal) obj;
    if (l.isBindEligible() || l.getType() != TypeFacility.RUNTIME_TYPES.BIG_DECIMAL) {
        return super.translate(obj, context);
    }
    BigDecimal bd = ((BigDecimal) l.getValue());
    if (bd.scale() == 0) {
        l.setValue(bd.setScale(1));
    }
    return null;
}
Also used : Literal(org.teiid.language.Literal) SubqueryIn(org.teiid.language.SubqueryIn) SubqueryComparison(org.teiid.language.SubqueryComparison) BigDecimal(java.math.BigDecimal)

Aggregations

BigDecimal (java.math.BigDecimal)1 Literal (org.teiid.language.Literal)1 SubqueryComparison (org.teiid.language.SubqueryComparison)1 SubqueryIn (org.teiid.language.SubqueryIn)1