Search in sources :

Example 56 with QueryResolverException

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

the class TestDQPCore method testPlanningException.

/**
 * Tests whether an exception result is sent when an exception occurs
 * @since 4.3
 */
@Test
public void testPlanningException() throws Exception {
    // $NON-NLS-1$
    String sql = "SELECT IntKey FROM BQT1.BadIdea ";
    RequestMessage reqMsg = exampleRequestMessage(sql);
    Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
    try {
        message.get(5000, TimeUnit.MILLISECONDS);
    } catch (ExecutionException e) {
        assertTrue(e.getCause() instanceof QueryResolverException);
    }
}
Also used : ResultsMessage(org.teiid.client.ResultsMessage) RequestMessage(org.teiid.client.RequestMessage) ExecutionException(java.util.concurrent.ExecutionException) QueryResolverException(org.teiid.api.exception.query.QueryResolverException) Test(org.junit.Test)

Example 57 with QueryResolverException

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

the class TestCallableStatement method testMissingInput.

@Test
public void testMissingInput() throws Exception {
    // $NON-NLS-1$
    String sql = "{? = call pm4.spTest9()}";
    try {
        TestPreparedStatement.helpTestProcessing(sql, Collections.EMPTY_LIST, null, new HardcodedDataManager(), RealMetadataFactory.exampleBQTCached(), true, RealMetadataFactory.exampleBQTVDB());
        fail();
    } catch (QueryResolverException e) {
        // $NON-NLS-1$
        assertEquals("TEIID30089 Required parameter 'pm4.spTest9.inkey' has no value was set or is an invalid parameter.", e.getMessage());
    }
}
Also used : HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) QueryResolverException(org.teiid.api.exception.query.QueryResolverException) Test(org.junit.Test)

Example 58 with QueryResolverException

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

the class TestTempTables method testForeignTemp.

@Test
public void testForeignTemp() throws Exception {
    HardcodedDataManager hdm = new HardcodedDataManager(metadata);
    BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
    SessionAwareCache<CachedResults> cache = new SessionAwareCache<CachedResults>("resultset", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.RESULTSET, 0);
    cache.setTupleBufferCache(bm);
    dataManager = new TempTableDataManager(hdm, bm, cache);
    // $NON-NLS-1$
    execute("create foreign temporary table x (e1 string options (nameinsource 'a'), e2 integer, e3 string, primary key (e1)) options (cardinality 1000, updatable true, \"other\" 'prop') on pm1", new List[] { Arrays.asList(0) });
    TempMetadataID id = this.tempStore.getMetadataStore().getData().get("x");
    // ensure that we're using the actual metadata
    assertNotNull(id);
    assertNotNull(this.metadata.getPrimaryKey(id));
    assertEquals(1000, this.metadata.getCardinality(id), 0);
    assertEquals("pm1", this.metadata.getName(this.metadata.getModelID(id)));
    assertEquals("prop", this.metadata.getExtensionProperty(id, "other", false));
    hdm.addData("SELECT x.a, x.e2, x.e3 FROM x", new List[] { Arrays.asList(1, 2, "3") });
    // $NON-NLS-1$
    execute("select * from x", new List[] { Arrays.asList(1, 2, "3") });
    hdm.addData("SELECT g_0.e2 AS c_0, g_0.e3 AS c_1, g_0.a AS c_2 FROM x AS g_0 ORDER BY c_1, c_0", new List[] { Arrays.asList(2, "3", "1") });
    hdm.addData("SELECT g_0.e3, g_0.e2 FROM x AS g_0", new List[] { Arrays.asList("3", 2) });
    hdm.addData("DELETE FROM x WHERE x.a = '1'", new List[] { Arrays.asList(1) });
    // ensure compensation behaves as if physical - not temp
    // $NON-NLS-1$
    execute("delete from x where e2 = (select max(e2) from x as z where e3 = x.e3)", new List[] { Arrays.asList(1) }, TestOptimizer.getGenericFinder());
    hdm.addData("SELECT g_0.e1 FROM g1 AS g_0, x AS g_1 WHERE g_1.a = g_0.e1", new List[] { Arrays.asList(1) });
    // ensure pushdown support
    // $NON-NLS-1$
    execute("select g1.e1 from pm1.g1 g1, x where x.e1 = g1.e1", new List[] { Arrays.asList(1) }, TestOptimizer.getGenericFinder());
    try {
        // $NON-NLS-1$
        execute("create local temporary table x (e1 string)", new List[] { Arrays.asList(0) });
        fail();
    } catch (QueryResolverException e) {
    }
    // ensure that drop works
    execute("drop table x", new List[] { Arrays.asList(0) });
    try {
        execute("drop table x", new List[] { Arrays.asList(0) });
        fail();
    } catch (QueryResolverException e) {
    }
}
Also used : SessionAwareCache(org.teiid.dqp.internal.process.SessionAwareCache) TempTableDataManager(org.teiid.query.tempdata.TempTableDataManager) TempMetadataID(org.teiid.query.metadata.TempMetadataID) BufferManager(org.teiid.common.buffer.BufferManager) CachedResults(org.teiid.dqp.internal.process.CachedResults) QueryResolverException(org.teiid.api.exception.query.QueryResolverException) Test(org.junit.Test)

Example 59 with QueryResolverException

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

the class TestResolver method helpResolveException.

static void helpResolveException(String sql, QueryMetadataInterface queryMetadata, String expectedExceptionMessage) {
    // parse
    Command command = helpParse(sql);
    // resolve
    try {
        QueryResolver.resolveCommand(command, queryMetadata);
        // $NON-NLS-1$
        fail("Expected exception for resolving " + sql);
    } catch (QueryResolverException e) {
        if (expectedExceptionMessage != null) {
            assertEquals(expectedExceptionMessage, e.getMessage());
        }
    } catch (TeiidComponentException e) {
        throw new RuntimeException(e);
    }
}
Also used : CreateProcedureCommand(org.teiid.query.sql.proc.CreateProcedureCommand) TeiidComponentException(org.teiid.core.TeiidComponentException) QueryResolverException(org.teiid.api.exception.query.QueryResolverException)

Example 60 with QueryResolverException

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

the class TestFunctionResolving method testResolveAmbiguousFunction.

@Test
public void testResolveAmbiguousFunction() throws Exception {
    // $NON-NLS-1$
    Function function = new Function("LCASE", new Expression[] { new Reference(0) });
    try {
        ResolverVisitor.resolveLanguageObject(function, RealMetadataFactory.example1Cached());
        // $NON-NLS-1$
        fail("excpetion expected");
    } catch (QueryResolverException err) {
        // $NON-NLS-1$
        assertEquals("TEIID30069 The function 'LCASE(?)' has more than one possible signature.", err.getMessage());
    }
}
Also used : Function(org.teiid.query.sql.symbol.Function) Reference(org.teiid.query.sql.symbol.Reference) 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