Search in sources :

Example 61 with QueryResolverException

use of org.teiid.api.exception.query.QueryResolverException in project teiid by teiid.

the class TestFunctionResolving method testImportedPushdown.

@Test
public void testImportedPushdown() throws Exception {
    RealMetadataFactory.example1Cached();
    QueryMetadataInterface tm = RealMetadataFactory.fromDDL("x", new DDLHolder("y", "create foreign function func(x object) returns object;"), new DDLHolder("z", "create foreign function func(x object) returns object;"));
    String sql = "func('a')";
    Function func = (Function) QueryParser.getQueryParser().parseExpression(sql);
    try {
        ResolverVisitor.resolveLanguageObject(func, tm);
        fail("should be ambiguous");
    } catch (QueryResolverException e) {
    }
    tm = RealMetadataFactory.fromDDL("x", new DDLHolder("y", "create foreign function func(x object) returns object options (\"teiid_rel:system-name\" 'f');"), new DDLHolder("z", "create foreign function func(x object) returns object options (\"teiid_rel:system-name\" 'f');"));
    func = (Function) QueryParser.getQueryParser().parseExpression(sql);
    ResolverVisitor.resolveLanguageObject(func, tm);
    tm = RealMetadataFactory.fromDDL("x", new DDLHolder("y", "create foreign function func() returns object options (\"teiid_rel:system-name\" 'f');"), new DDLHolder("z", "create foreign function func() returns object options (\"teiid_rel:system-name\" 'f');"));
    func = (Function) QueryParser.getQueryParser().parseExpression("func()");
    ResolverVisitor.resolveLanguageObject(func, tm);
}
Also used : Function(org.teiid.query.sql.symbol.Function) DDLHolder(org.teiid.query.unittest.RealMetadataFactory.DDLHolder) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) QueryResolverException(org.teiid.api.exception.query.QueryResolverException) Test(org.junit.Test)

Example 62 with QueryResolverException

use of org.teiid.api.exception.query.QueryResolverException 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());
    }
}
Also used : Function(org.teiid.query.sql.symbol.Function) Constant(org.teiid.query.sql.symbol.Constant) QueryResolverException(org.teiid.api.exception.query.QueryResolverException) Test(org.junit.Test)

Aggregations

QueryResolverException (org.teiid.api.exception.query.QueryResolverException)62 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)13 TempMetadataID (org.teiid.query.metadata.TempMetadataID)11 ExceptionExpression (org.teiid.query.sql.proc.ExceptionExpression)11 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)10 TeiidComponentException (org.teiid.core.TeiidComponentException)10 Expression (org.teiid.query.sql.symbol.Expression)10 QueryMetadataException (org.teiid.api.exception.query.QueryMetadataException)8 CreateProcedureCommand (org.teiid.query.sql.proc.CreateProcedureCommand)7 Command (org.teiid.query.sql.lang.Command)6 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)6 QueryParserException (org.teiid.api.exception.query.QueryParserException)5 TempMetadataStore (org.teiid.query.metadata.TempMetadataStore)5 LanguageObject (org.teiid.query.sql.LanguageObject)5 List (java.util.List)4 UnresolvedSymbolDescription (org.teiid.api.exception.query.UnresolvedSymbolDescription)4 TempMetadataAdapter (org.teiid.query.metadata.TempMetadataAdapter)4 StoredProcedure (org.teiid.query.sql.lang.StoredProcedure)4 HashSet (java.util.HashSet)3