use of org.teiid.query.sql.symbol.Function in project teiid by teiid.
the class TestProjectNode method testProjectExpressionFunctionFails.
@Test
public void testProjectExpressionFunctionFails() throws Exception {
// $NON-NLS-1$
ElementSymbol es1 = new ElementSymbol("e1");
es1.setType(DataTypeManager.DefaultDataClasses.STRING);
List elements = new ArrayList();
elements.add(es1);
// $NON-NLS-1$ //$NON-NLS-2$
Function func = new Function("convert", new Expression[] { es1, new Constant("integer") });
// $NON-NLS-1$
FunctionDescriptor fd = RealMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("convert", new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING });
func.setFunctionDescriptor(fd);
func.setType(DataTypeManager.DefaultDataClasses.INTEGER);
// $NON-NLS-1$
ExpressionSymbol expr = new ExpressionSymbol("expr", func);
List projectElements = new ArrayList();
projectElements.add(expr);
List[] data = new List[] { // $NON-NLS-1$
Arrays.asList(new Object[] { "1" }), // $NON-NLS-1$
Arrays.asList(new Object[] { "2x" }) };
// $NON-NLS-1$
String expectedMessage = "TEIID30328 UNABLE TO EVALUATE CONVERT(E1, INTEGER): TEIID30384 ERROR WHILE EVALUATING FUNCTION CONVERT";
helpTestProjectFails(projectElements, data, elements, expectedMessage);
}
use of org.teiid.query.sql.symbol.Function in project teiid by teiid.
the class TestOptionsAndHints method testDepOptions2.
@Test
public void testDepOptions2() {
// $NON-NLS-1$
GroupSymbol a = new GroupSymbol("a");
// $NON-NLS-1$
GroupSymbol b = new GroupSymbol("b");
// $NON-NLS-1$
ElementSymbol x = new ElementSymbol("a.x", true);
// $NON-NLS-1$
ElementSymbol y = new ElementSymbol("b.y", true);
// $NON-NLS-1$
Criteria criteria = new CompareCriteria(x, CompareCriteria.EQ, new Function("func", new Expression[] { y }));
JoinPredicate predicate = new JoinPredicate(new UnaryFromClause(a), new UnaryFromClause(b), JoinType.JOIN_INNER, Arrays.asList(new Object[] { criteria }));
From from = new From(Arrays.asList(predicate));
predicate.getLeftClause().setMakeNotDep(true);
predicate.getRightClause().setMakeDep(true);
Select select = new Select(Arrays.asList(x, y));
Query query = new Query(select, from, null, null, null, null, null);
// $NON-NLS-1$
TestParser.helpTest(// $NON-NLS-1$
"Select a.x, b.y From a MAKENOTDEP INNER JOIN b MAKEDEP ON a.x = func(b.y)", // $NON-NLS-1$
"SELECT a.x, b.y FROM /*+ MAKENOTDEP */ a INNER JOIN /*+ MAKEDEP */ b ON a.x = func(b.y)", query);
}
use of org.teiid.query.sql.symbol.Function in project teiid by teiid.
the class TestCapabilitiesUtil method testSupportsFunctionInGroupBy.
/**
* Supports functions in group by is misleading. It should actually
* be called supports expression in group by. Thus the example below
* is not supported.
*/
@Test
public void testSupportsFunctionInGroupBy() throws Exception {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Function f = new Function("concat", new Expression[] { new Constant("a"), new Constant("b") });
// $NON-NLS-1$
ExpressionSymbol expr = new ExpressionSymbol("e", f);
List cols = new ArrayList();
cols.add(expr);
helpTestSupportsAggregates(false, false, cols);
}
use of org.teiid.query.sql.symbol.Function in project teiid by teiid.
the class TestCapabilitiesUtil method testSupportsScalar3.
// Test where capabilities doesn't support function
@Test
public void testSupportsScalar3() throws Exception {
BasicSourceCapabilities caps = new BasicSourceCapabilities();
// $NON-NLS-1$
caps.setFunctionSupport("now", false);
// $NON-NLS-1$
Function func = new Function("NOW", new Expression[] {});
helpTestSupportsScalar(caps, func, false);
}
use of org.teiid.query.sql.symbol.Function in project teiid by teiid.
the class TestCapabilitiesUtil method testSupportsScalar4.
// Test where capabilities do support function
@Test
public void testSupportsScalar4() throws Exception {
BasicSourceCapabilities caps = new BasicSourceCapabilities();
// $NON-NLS-1$
caps.setFunctionSupport("now", true);
// $NON-NLS-1$
Function func = new Function("NOW", new Expression[] {});
helpTestSupportsScalar(caps, func, true);
}
Aggregations