Search in sources :

Example 21 with TeiidException

use of org.teiid.core.TeiidException in project teiid by teiid.

the class TestQueryRewriter method helpTestRewriteCriteria.

private Criteria helpTestRewriteCriteria(String original, Criteria expectedCrit, QueryMetadataInterface metadata) {
    Criteria origCrit = parseCriteria(original, metadata);
    Criteria actual = null;
    // rewrite
    try {
        ArrayList<Boolean> booleanVals = new ArrayList<Boolean>(tuples.size());
        for (List<?> tuple : tuples) {
            booleanVals.add(new Evaluator(elements, null, null).evaluate(origCrit, tuple));
        }
        actual = QueryRewriter.rewriteCriteria(origCrit, null, metadata);
        // $NON-NLS-1$
        assertEquals("Did not rewrite correctly: ", expectedCrit, actual);
        for (int i = 0; i < tuples.size(); i++) {
            assertEquals(tuples.get(i).toString(), booleanVals.get(i), new Evaluator(elements, null, null).evaluate(actual, tuples.get(i)));
        }
    } catch (TeiidException e) {
        throw new RuntimeException(e);
    }
    return actual;
}
Also used : TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) ArrayList(java.util.ArrayList) Evaluator(org.teiid.query.eval.Evaluator) TeiidException(org.teiid.core.TeiidException)

Example 22 with TeiidException

use of org.teiid.core.TeiidException in project teiid by teiid.

the class TestQueryRewriter method testRewriteCrit_invalidParseDate.

@Ignore(value = "Should be moved to the validator")
@Test
public void testRewriteCrit_invalidParseDate() {
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    // $NON-NLS-1$
    Criteria origCrit = parseCriteria("PARSEDATE(pm3.g1.e1, '''') = {d'2003-05-01'}", metadata);
    try {
        QueryRewriter.rewriteCriteria(origCrit, null, null);
        // $NON-NLS-1$
        fail("Expected failure");
    } catch (TeiidException e) {
        // $NON-NLS-1$
        assertEquals("Error Code:ERR.015.001.0003 Message:Error simplifying criteria: PARSEDATE(pm3.g1.e1, '''') = {d'2003-05-01'}", e.getMessage());
    }
}
Also used : QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) TeiidException(org.teiid.core.TeiidException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 23 with TeiidException

use of org.teiid.core.TeiidException in project teiid by teiid.

the class DataTierManagerImpl method getColumns.

private List<ElementSymbol> getColumns(TransformationMetadata tm, String name) {
    GroupSymbol gs = new GroupSymbol(name);
    try {
        ResolverUtil.resolveGroup(gs, tm);
        List<ElementSymbol> columns = ResolverUtil.resolveElementsInGroup(gs, tm);
        return columns;
    } catch (TeiidException e) {
        throw new TeiidRuntimeException(e);
    }
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) TeiidException(org.teiid.core.TeiidException)

Example 24 with TeiidException

use of org.teiid.core.TeiidException in project teiid by teiid.

the class CachedFinder method findCapabilities.

/**
 * Find capabilities used the cache if possible, otherwise do the lookup.
 */
public SourceCapabilities findCapabilities(String modelName) throws TeiidComponentException {
    SourceCapabilities caps = userCache.get(modelName);
    if (caps != null) {
        return caps;
    }
    ModelMetaData model = vdb.getModel(modelName);
    List<String> sourceNames = model.getSourceNames();
    if (sourceNames.isEmpty()) {
        throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30499, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30499, modelName));
    }
    TeiidException cause = null;
    for (String sourceName : sourceNames) {
        // TOOD: in multi-source mode it may be necessary to compute minimal capabilities across the sources
        ConnectorManager mgr = this.connectorRepo.getConnectorManager(sourceName);
        if (mgr == null) {
            throw new TeiidComponentException(QueryPlugin.Event.TEIID30497, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30497, sourceName, modelName, sourceName));
        }
        try {
            caps = mgr.getCapabilities();
            break;
        } catch (TeiidException e) {
            cause = e;
            // $NON-NLS-1$
            LogManager.logDetail(LogConstants.CTX_DQP, e, "Could not obtain capabilities for" + sourceName);
        }
    }
    if (caps == null) {
        InvalidCaps ic = new InvalidCaps();
        ic.setSourceProperty(Capability.INVALID_EXCEPTION, cause);
        caps = ic;
    }
    userCache.put(modelName, caps);
    return caps;
}
Also used : TeiidComponentException(org.teiid.core.TeiidComponentException) SourceCapabilities(org.teiid.query.optimizer.capabilities.SourceCapabilities) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) ConnectorManager(org.teiid.dqp.internal.datamgr.ConnectorManager) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData) TeiidException(org.teiid.core.TeiidException)

Example 25 with TeiidException

use of org.teiid.core.TeiidException in project teiid by teiid.

the class TestProcessor method sampleDataBQT1.

private void sampleDataBQT1(FakeDataManager dataMgr) {
    QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
    try {
        // Group bqt1.smalla
        List[] tuples = new List[20];
        for (int i = 0; i < tuples.length; i++) {
            tuples[i] = new ArrayList(17);
            tuples[i].add(new Integer(i));
            for (int j = 0; j < 16; j++) {
                tuples[i].add(null);
            }
        }
        // $NON-NLS-1$
        dataMgr.registerTuples(metadata, "bqt1.smalla", tuples);
        // Group bqt2.mediumb
        tuples = new List[20];
        for (int i = 0; i < tuples.length; i++) {
            tuples[i] = new ArrayList(17);
            tuples[i].add(new Integer(i));
            for (int j = 0; j < 16; j++) {
                tuples[i].add(null);
            }
        }
        // $NON-NLS-1$
        dataMgr.registerTuples(metadata, "bqt2.mediumb", tuples);
    } catch (TeiidException e) {
        throw new RuntimeException(e);
    }
}
Also used : BigInteger(java.math.BigInteger) TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) TeiidException(org.teiid.core.TeiidException)

Aggregations

TeiidException (org.teiid.core.TeiidException)85 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)26 ArrayList (java.util.ArrayList)14 Test (org.junit.Test)13 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)10 SQLException (java.sql.SQLException)9 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)8 BigInteger (java.math.BigInteger)6 Column (org.teiid.metadata.Column)6 Command (org.teiid.query.sql.lang.Command)6 TranslatorException (org.teiid.translator.TranslatorException)6 IOException (java.io.IOException)5 TeiidProcessingException (org.teiid.core.TeiidProcessingException)5 List (java.util.List)4 EdmEntityType (org.apache.olingo.commons.api.edm.EdmEntityType)4 ODataApplicationException (org.apache.olingo.server.api.ODataApplicationException)4 TeiidComponentException (org.teiid.core.TeiidComponentException)4 UpdateResponse (org.teiid.odata.api.UpdateResponse)4 Update (org.teiid.query.sql.lang.Update)4 SocketTimeoutException (java.net.SocketTimeoutException)3