Search in sources :

Example 46 with Expression

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

the class CoherenceVisitor method visit.

public void visit(Like obj) {
    // $NON-NLS-1$
    LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Parsing LIKE criteria.");
    // Convert LIKE to Equals, where any "%" symbol is replaced with "*".
    try {
        Comparison.Operator op = Operator.EQ;
        Expression lhs = ((Like) obj).getLeftExpression();
        Expression rhs = ((Like) obj).getRightExpression();
        String lhsString = getExpressionString(lhs);
        String rhsString = getExpressionString(rhs);
        // rhsString = rhsString.replace("%", "*"); //$NON-NLS-1$ //$NON-NLS-2$
        filter = CoherenceFilterUtil.createFilter(lhsString + " LIKE \'" + rhsString + "\'");
    } catch (TranslatorException t) {
        exception = t;
    }
}
Also used : Like(org.teiid.language.Like) Comparison(org.teiid.language.Comparison) Expression(org.teiid.language.Expression) TranslatorException(org.teiid.translator.TranslatorException) Operator(org.teiid.language.Comparison.Operator)

Example 47 with Expression

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

the class CoherenceVisitor method visit.

public void visit(In obj) {
    // $NON-NLS-1$
    LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Parsing IN criteria.");
    // isNegated = ((In) criteria).isNegated();
    try {
        Expression lhs = ((In) obj).getLeftExpression();
        String lhsString = getExpressionString(lhs);
        List<Expression> rhsList = ((In) obj).getRightExpressions();
        Class type = null;
        List parms = new ArrayList(rhsList.size());
        Iterator iter = rhsList.iterator();
        while (iter.hasNext()) {
            Expression expr = (Expression) iter.next();
            type = addParmFromExpression(expr, parms);
        }
        addInCriteria(lhsString, parms, type);
    // filter = CoherenceFilterUtil.createInFilter(lhsString, parms, type);
    } catch (TranslatorException t) {
        exception = t;
    }
}
Also used : Expression(org.teiid.language.Expression) In(org.teiid.language.In) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) TranslatorException(org.teiid.translator.TranslatorException)

Example 48 with Expression

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

the class TickerCollectorVisitor method visit.

public void visit(Comparison obj) {
    Expression expr = obj.getRightExpression();
    addTickerFromExpression(expr);
}
Also used : Expression(org.teiid.language.Expression)

Example 49 with Expression

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

the class YahooExecution method getNeededColumns.

/**
 * @param select
 * @return
 * @throws TranslatorException
 */
static int[] getNeededColumns(List<DerivedColumn> select) throws TranslatorException {
    int[] cols = new int[select.size()];
    Iterator<DerivedColumn> iter = select.iterator();
    for (int i = 0; iter.hasNext(); i++) {
        DerivedColumn symbol = iter.next();
        Expression expr = symbol.getExpression();
        if (expr instanceof ColumnReference) {
            Column element = ((ColumnReference) expr).getMetadataObject();
            cols[i] = element.getPosition();
        } else {
            // $NON-NLS-1$
            throw new TranslatorException(YahooPlugin.Util.getString("YahooExecution.Invalid_select_symbol", expr));
        }
    }
    return cols;
}
Also used : Expression(org.teiid.language.Expression) Column(org.teiid.metadata.Column) DerivedColumn(org.teiid.language.DerivedColumn) TranslatorException(org.teiid.translator.TranslatorException) DerivedColumn(org.teiid.language.DerivedColumn) ColumnReference(org.teiid.language.ColumnReference)

Example 50 with Expression

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

the class TestInsertImpl method testExpressionsInInsert.

public void testExpressionsInInsert() throws Exception {
    // $NON-NLS-1$
    Insert insert = example2("a.b");
    assertNotNull(insert.getColumns());
    assertEquals(1, insert.getColumns().size());
    for (Iterator i = insert.getColumns().iterator(); i.hasNext(); ) {
        assertTrue(i.next() instanceof ColumnReference);
    }
    assertNotNull(insert.getValueSource());
    assertEquals(1, ((ExpressionValueSource) insert.getValueSource()).getValues().size());
    for (Iterator i = ((ExpressionValueSource) insert.getValueSource()).getValues().iterator(); i.hasNext(); ) {
        assertTrue(i.next() instanceof Expression);
    }
}
Also used : Expression(org.teiid.language.Expression) Iterator(java.util.Iterator) Insert(org.teiid.language.Insert) ColumnReference(org.teiid.language.ColumnReference) ExpressionValueSource(org.teiid.language.ExpressionValueSource)

Aggregations

Expression (org.teiid.language.Expression)61 ArrayList (java.util.ArrayList)18 ExpressionValueSource (org.teiid.language.ExpressionValueSource)18 Literal (org.teiid.language.Literal)17 TranslatorException (org.teiid.translator.TranslatorException)16 ColumnReference (org.teiid.language.ColumnReference)14 Function (org.teiid.language.Function)13 Column (org.teiid.metadata.Column)12 Insert (org.teiid.language.Insert)11 List (java.util.List)10 Table (org.teiid.metadata.Table)9 BigInteger (java.math.BigInteger)7 Test (org.junit.Test)7 Parameter (org.teiid.language.Parameter)7 Iterator (java.util.Iterator)5 Comparison (org.teiid.language.Comparison)5 Connection (java.sql.Connection)4 PreparedStatement (java.sql.PreparedStatement)4 FakeExecutionContextImpl (org.teiid.dqp.internal.datamgr.FakeExecutionContextImpl)4 NamedTable (org.teiid.language.NamedTable)4