use of org.teiid.query.sql.symbol.Function in project teiid by teiid.
the class TestFunctionResolving method testResolveBadConvert.
@Test
public void testResolveBadConvert() throws Exception {
// $NON-NLS-1$
Function function = new Function("convert", new Expression[] { new Constant(new Character('a')), new Constant(DataTypeManager.DefaultDataTypes.DATE) });
try {
ResolverVisitor.resolveLanguageObject(function, RealMetadataFactory.example1Cached());
// $NON-NLS-1$
fail("excpetion expected");
} catch (QueryResolverException err) {
// $NON-NLS-1$
assertEquals("TEIID30071 The conversion from char to date is not allowed.", err.getMessage());
}
}
use of org.teiid.query.sql.symbol.Function in project teiid by teiid.
the class TestStaticSymbolMappingVisitor method testExecParamFunction.
public void testExecParamFunction() {
StoredProcedure exec = new StoredProcedure();
// $NON-NLS-1$
exec.setProcedureName("pm1.proc1");
// $NON-NLS-1$
exec.setProcedureID("proc");
// $NON-NLS-1$
Function f = new Function("length", new Expression[] { exampleElement(true, 1) });
SPParameter param1 = new SPParameter(1, f);
exec.setParameter(param1);
// Run symbol mapper
StaticSymbolMappingVisitor visitor = new StaticSymbolMappingVisitor(getSymbolMap());
DeepPreOrderNavigator.doVisit(exec, visitor);
// Check that element got switched
Function afterFunc = (Function) param1.getExpression();
// $NON-NLS-1$
assertEquals("Stored proc param did not get mapped correctly: ", exampleElement(false, 1), afterFunc.getArg(0));
}
use of org.teiid.query.sql.symbol.Function in project teiid by teiid.
the class TestStaticSymbolMappingVisitor method testExecParamNestedFunction.
public void testExecParamNestedFunction() {
StoredProcedure exec = new StoredProcedure();
// $NON-NLS-1$
exec.setProcedureName("pm1.proc1");
// $NON-NLS-1$
exec.setProcedureID("proc");
// $NON-NLS-1$
Function f = new Function("length", new Expression[] { exampleElement(true, 1) });
// $NON-NLS-1$
Function f2 = new Function("+", new Expression[] { f, new Constant(new Integer(1)) });
SPParameter param1 = new SPParameter(1, f2);
exec.setParameter(param1);
// Run symbol mapper
StaticSymbolMappingVisitor visitor = new StaticSymbolMappingVisitor(getSymbolMap());
DeepPreOrderNavigator.doVisit(exec, visitor);
// Check that element got switched
Function afterFunc = (Function) param1.getExpression();
Function innerFunc = (Function) afterFunc.getArgs()[0];
// $NON-NLS-1$
assertEquals("Stored proc param did not get mapped correctly: ", exampleElement(false, 1), innerFunc.getArg(0));
}
use of org.teiid.query.sql.symbol.Function in project teiid by teiid.
the class TestStaticSymbolMappingVisitor method testVisitSubquerySetCriteria.
public void testVisitSubquerySetCriteria() {
SubquerySetCriteria ssc = new SubquerySetCriteria();
// $NON-NLS-1$
ssc.setExpression(new Function("length", new Expression[] { exampleElement(true, 0) }));
ssc.setCommand(new Query());
helpTest(ssc, getSymbolMap());
}
use of org.teiid.query.sql.symbol.Function in project teiid by teiid.
the class TestFunction method testFunction3.
public void testFunction3() {
// $NON-NLS-1$ //$NON-NLS-2$
Function f1 = new Function("f1", new Expression[] { new Constant("xyz") });
// $NON-NLS-1$ //$NON-NLS-2$
Function f2 = new Function("f2", new Expression[] { new Constant("xyz") });
UnitTestUtil.helpTestEquivalence(1, f1, f2);
}
Aggregations