use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestProcedureResolving method testOptionalParams.
@Test
public void testOptionalParams() throws Exception {
String ddl = "create foreign procedure proc (x integer, y string);\n";
TransformationMetadata tm = createMetadata(ddl);
// $NON-NLS-1$
String sql = "call proc (1)";
StoredProcedure sp = (StoredProcedure) TestResolver.helpResolve(sql, tm);
assertEquals(new Constant(null, DataTypeManager.DefaultDataClasses.STRING), sp.getParameter(2).getExpression());
// $NON-NLS-1$
sql = "call proc (1, 'a')";
sp = (StoredProcedure) TestResolver.helpResolve(sql, tm);
assertEquals(new Constant("a", DataTypeManager.DefaultDataClasses.STRING), sp.getParameter(2).getExpression());
}
use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestProcedureResolving method testVarArgs2.
@Test
public void testVarArgs2() throws Exception {
String ddl = "create foreign procedure proc (VARIADIC z object) returns (x string);\n";
TransformationMetadata tm = createMetadata(ddl);
// $NON-NLS-1$
String sql = "call proc ()";
StoredProcedure sp = (StoredProcedure) TestResolver.helpResolve(sql, tm);
assertEquals("EXEC proc()", sp.toString());
assertEquals(new Array(DataTypeManager.DefaultDataClasses.OBJECT, new ArrayList<Expression>(0)), sp.getParameter(1).getExpression());
// $NON-NLS-1$
sql = "call proc (1, (2, 3))";
sp = (StoredProcedure) TestResolver.helpResolve(sql, tm);
assertEquals("EXEC proc(1, (2, 3))", sp.toString());
ArrayList<Expression> expressions = new ArrayList<Expression>();
expressions.add(new Constant(1));
expressions.add(new Array(DataTypeManager.DefaultDataClasses.INTEGER, Arrays.asList((Expression) new Constant(2), new Constant(3))));
assertEquals(new Array(DataTypeManager.DefaultDataClasses.OBJECT, expressions), sp.getParameter(1).getExpression());
}
use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestResolver method testCriteria1.
@Test
public void testCriteria1() {
CompareCriteria expected = new CompareCriteria();
// $NON-NLS-1$
ElementSymbol es = new ElementSymbol("pm1.g1.e1");
// $NON-NLS-1$
GroupSymbol gs = new GroupSymbol("pm1.g1");
es.setGroupSymbol(gs);
expected.setLeftExpression(es);
expected.setOperator(CompareCriteria.EQ);
// $NON-NLS-1$
expected.setRightExpression(new Constant("abc"));
// $NON-NLS-1$
Criteria actual = helpResolveCriteria("pm1.g1.e1 = 'abc'");
// $NON-NLS-1$
assertEquals("Did not match expected criteria", expected, actual);
}
use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestResolver method testExecNamedParamsOptionalParamWithDefaults2.
/**
* try just a few named parameters, in no particular order
*/
@Test
public void testExecNamedParamsOptionalParamWithDefaults2() {
Object[] expectedParameterExpressions = helpGetStoredProcDefaultValues();
// override the proper default values in expected results
expectedParameterExpressions[3] = new Constant(Boolean.FALSE);
expectedParameterExpressions[9] = new Constant(new Integer(666));
// $NON-NLS-1$
helpResolveExec("EXEC pm1.sqDefaults(ininteger = 666, inboolean={b'false'})", expectedParameterExpressions);
}
use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestResolver method testStoredQueryParamOrdering_8211.
/**
* per defect 8211 - Input params do not have to be numbered sequentially in metadata. For example,
* the first input param can be #1 and the second input param can be #3. (This occurs in
* QueryBuilder's metadata where the return param happens to be created in between the two
* input params and is numbered #2, but is not loaded into QueryBuilder's runtime env).
* When the user's query is parsed and resolved, the placeholder
* input params are numbered #1 and #2. This test tests that this disparity in ordering should not
* be a problem as long as RELATIVE ordering is in synch.
*/
@Test
public void testStoredQueryParamOrdering_8211() {
// $NON-NLS-1$
StoredProcedure proc = (StoredProcedure) helpResolve("EXEC pm1.sq3a('abc', 123)");
// Check number of resolved parameters
Map<Integer, SPParameter> params = proc.getMapOfParameters();
// $NON-NLS-1$
assertEquals("Did not get expected parameter count", 3, params.size());
// Check resolved parameters
SPParameter param1 = params.get(1);
// $NON-NLS-1$ //$NON-NLS-2$
helpCheckParameter(param1, ParameterInfo.IN, 1, "pm1.sq3a.in", DataTypeManager.DefaultDataClasses.STRING, new Constant("abc"));
SPParameter param2 = params.get(2);
// $NON-NLS-1$
helpCheckParameter(param2, ParameterInfo.IN, 2, "pm1.sq3a.in2", DataTypeManager.DefaultDataClasses.INTEGER, new Constant(new Integer(123)));
}
Aggregations