Search in sources :

Example 11 with Reference

use of org.teiid.query.sql.symbol.Reference in project teiid by teiid.

the class TestProcessor method setParameterValues.

public static void setParameterValues(List<?> values, Command command, CommandContext context) {
    VariableContext vc = new VariableContext();
    Iterator<?> valIter = values.iterator();
    for (Reference ref : ReferenceCollectorVisitor.getReferences(command)) {
        if (!ref.isPositional()) {
            continue;
        }
        // $NON-NLS-1$
        vc.setGlobalValue(ref.getContextSymbol(), valIter.next());
    }
    context.setVariableContext(vc);
}
Also used : Reference(org.teiid.query.sql.symbol.Reference) VariableContext(org.teiid.query.sql.util.VariableContext)

Example 12 with Reference

use of org.teiid.query.sql.symbol.Reference in project teiid by teiid.

the class TestResolver method testUpdateSetClauseReferenceType.

@Test
public void testUpdateSetClauseReferenceType() {
    // $NON-NLS-1$
    String sql = "UPDATE pm1.g1 SET pm1.g1.e1 = 1, pm1.g1.e2 = ?;";
    Update update = (Update) helpResolve(sql, RealMetadataFactory.example1Cached());
    Expression ref = update.getChangeList().getClauses().get(1).getValue();
    assertTrue(ref instanceof Reference);
    assertNotNull(ref.getType());
}
Also used : Expression(org.teiid.query.sql.symbol.Expression) Reference(org.teiid.query.sql.symbol.Reference) Test(org.junit.Test)

Example 13 with Reference

use of org.teiid.query.sql.symbol.Reference in project teiid by teiid.

the class TestFunctionResolving method testResolveConvertReference.

@Test
public void testResolveConvertReference() throws Exception {
    // $NON-NLS-1$
    Function function = new Function("convert", new Expression[] { new Reference(0), new Constant(DataTypeManager.DefaultDataTypes.BOOLEAN) });
    ResolverVisitor.resolveLanguageObject(function, RealMetadataFactory.example1Cached());
    assertEquals(DataTypeManager.DefaultDataClasses.BOOLEAN, function.getType());
    assertEquals(DataTypeManager.DefaultDataClasses.BOOLEAN, function.getArgs()[0].getType());
}
Also used : Function(org.teiid.query.sql.symbol.Function) Reference(org.teiid.query.sql.symbol.Reference) Constant(org.teiid.query.sql.symbol.Constant) Test(org.junit.Test)

Example 14 with Reference

use of org.teiid.query.sql.symbol.Reference in project teiid by teiid.

the class TestLimitParsing method testLimitWithReferences3.

@Test
public void testLimitWithReferences3() {
    Query query = new Query();
    Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
    // $NON-NLS-1$
    From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a"))));
    query.setSelect(select);
    query.setFrom(from);
    query.setLimit(new Limit(new Reference(0), new Reference(1)));
    // $NON-NLS-1$ //$NON-NLS-2$
    helpTest("Select * from a limit ?,?", "SELECT * FROM a LIMIT ?, ?", query);
}
Also used : MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) Query(org.teiid.query.sql.lang.Query) SetQuery(org.teiid.query.sql.lang.SetQuery) UnaryFromClause(org.teiid.query.sql.lang.UnaryFromClause) Reference(org.teiid.query.sql.symbol.Reference) Select(org.teiid.query.sql.lang.Select) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) From(org.teiid.query.sql.lang.From) Limit(org.teiid.query.sql.lang.Limit) Test(org.junit.Test)

Example 15 with Reference

use of org.teiid.query.sql.symbol.Reference in project teiid by teiid.

the class TestLimitParsing method testLimitWithReferences2.

@Test
public void testLimitWithReferences2() {
    Query query = new Query();
    Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
    // $NON-NLS-1$
    From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a"))));
    query.setSelect(select);
    query.setFrom(from);
    query.setLimit(new Limit(new Constant(new Integer(50)), new Reference(0)));
    // $NON-NLS-1$ //$NON-NLS-2$
    helpTest("Select * from a limit 50,?", "SELECT * FROM a LIMIT 50, ?", query);
}
Also used : MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) Query(org.teiid.query.sql.lang.Query) SetQuery(org.teiid.query.sql.lang.SetQuery) UnaryFromClause(org.teiid.query.sql.lang.UnaryFromClause) Constant(org.teiid.query.sql.symbol.Constant) Reference(org.teiid.query.sql.symbol.Reference) Select(org.teiid.query.sql.lang.Select) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) From(org.teiid.query.sql.lang.From) Limit(org.teiid.query.sql.lang.Limit) Test(org.junit.Test)

Aggregations

Reference (org.teiid.query.sql.symbol.Reference)42 Test (org.junit.Test)15 Constant (org.teiid.query.sql.symbol.Constant)14 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)14 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)12 Expression (org.teiid.query.sql.symbol.Expression)11 Limit (org.teiid.query.sql.lang.Limit)7 Query (org.teiid.query.sql.lang.Query)7 MultipleElementSymbol (org.teiid.query.sql.symbol.MultipleElementSymbol)7 ArrayList (java.util.ArrayList)6 Criteria (org.teiid.query.sql.lang.Criteria)6 LinkedList (java.util.LinkedList)5 From (org.teiid.query.sql.lang.From)5 Select (org.teiid.query.sql.lang.Select)5 SetQuery (org.teiid.query.sql.lang.SetQuery)5 StoredProcedure (org.teiid.query.sql.lang.StoredProcedure)5 UnaryFromClause (org.teiid.query.sql.lang.UnaryFromClause)5 Column (org.teiid.metadata.Column)4 Command (org.teiid.query.sql.lang.Command)4 SPParameter (org.teiid.query.sql.lang.SPParameter)4