use of org.teiid.query.sql.symbol.Function in project teiid by teiid.
the class TestFunctionResolving method testLookupTypeConversion.
/**
* e1 is of type string, so 1 should be converted to string
* @throws Exception
*/
@Test
public void testLookupTypeConversion() throws Exception {
// $NON-NLS-1$
String sql = "lookup('pm1.g1', 'e2', 'e1', 1)";
Function f = (Function) getExpression(sql);
assertEquals(DataTypeManager.DefaultDataClasses.STRING, f.getArg(3).getType());
}
use of org.teiid.query.sql.symbol.Function in project teiid by teiid.
the class TestFunctionResolving method testNumericConversion.
/**
* e1 is of type string, so 1 should be converted to string
* @throws Exception
*/
@Test
public void testNumericConversion() throws Exception {
// $NON-NLS-1$
String sql = "1.0/2";
Function f = (Function) getExpression(sql);
assertEquals(DataTypeManager.DefaultDataClasses.BIG_DECIMAL, f.getType());
}
use of org.teiid.query.sql.symbol.Function 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());
}
use of org.teiid.query.sql.symbol.Function in project teiid by teiid.
the class TestFunctionResolving method testUDFResolveOrder.
@Test
public void testUDFResolveOrder() throws Exception {
QueryMetadataInterface tm = RealMetadataFactory.fromDDL("create foreign function func(x object) returns object; " + " create foreign function func(x string) returns string;" + " create foreign function func1(x object) returns double;" + " create foreign function func1(x string[]) returns bigdecimal;", "x", "y");
String sql = "func('a')";
Function func = (Function) QueryParser.getQueryParser().parseExpression(sql);
ResolverVisitor.resolveLanguageObject(func, tm);
assertEquals(DataTypeManager.DefaultDataClasses.STRING, func.getArgs()[0].getType());
assertEquals(DataTypeManager.DefaultDataClasses.STRING, func.getType());
sql = "func1(('1',))";
func = (Function) QueryParser.getQueryParser().parseExpression(sql);
ResolverVisitor.resolveLanguageObject(func, tm);
}
use of org.teiid.query.sql.symbol.Function in project teiid by teiid.
the class TestFunctionResolving method helpResolveFunction.
private Function helpResolveFunction(String sql) throws QueryParserException, QueryResolverException, TeiidComponentException {
Function func = (Function) getExpression(sql);
assertEquals(DataTypeManager.DefaultDataClasses.STRING, func.getType());
return func;
}
Aggregations