Search in sources :

Example 71 with TeiidException

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

the class TestQueryRewriter method testRewriteConvertThrowsEvaluationError.

@Test
public void testRewriteConvertThrowsEvaluationError() {
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    // $NON-NLS-1$
    Criteria origCrit = parseCriteria("convert('x', integer) = 0", metadata);
    // rewrite
    try {
        QueryRewriter.rewriteCriteria(origCrit, null, metadata);
        // $NON-NLS-1$
        fail("Expected QueryValidatorException due to invalid string");
    } catch (TeiidException e) {
        // $NON-NLS-1$
        assertEquals("TEIID30328 Unable to evaluate convert('x', integer): TEIID30384 Error while evaluating function convert", e.getMessage());
    }
}
Also used : QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) TeiidException(org.teiid.core.TeiidException) Test(org.junit.Test)

Example 72 with TeiidException

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

the class TestValidator method helpFailProcedure.

private void helpFailProcedure(String procedure, String userUpdateStr, Table.TriggerEvent procedureType) {
    QueryMetadataInterface metadata = RealMetadataFactory.exampleUpdateProc(procedureType, procedure);
    try {
        validateProcedure(userUpdateStr, metadata);
        fail("Expected failures for " + procedure);
    } catch (QueryValidatorException e) {
    } catch (TeiidException e) {
        throw new RuntimeException(e);
    }
}
Also used : TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) QueryValidatorException(org.teiid.api.exception.query.QueryValidatorException) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) TeiidException(org.teiid.core.TeiidException)

Example 73 with TeiidException

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

the class TestDeepGroupCollectorVisitor method helpTestVisitor.

public void helpTestVisitor(String sql, String[] expectedGroups) {
    LanguageObject obj = null;
    try {
        obj = QueryParser.getQueryParser().parseCommand(sql);
    } catch (TeiidException e) {
        throw new RuntimeException(e);
    }
    Collection actualGroups = GroupCollectorVisitor.getGroupsIgnoreInlineViews(obj, false);
    // $NON-NLS-1$
    assertEquals("Did not get expected number of groups", expectedGroups.length, actualGroups.size());
    Iterator iter = actualGroups.iterator();
    for (int i = 0; iter.hasNext(); i++) {
        GroupSymbol group = (GroupSymbol) iter.next();
        assertTrue(// $NON-NLS-1$ //$NON-NLS-2$
        "Expected group did not match, expected=" + expectedGroups[i] + ", actual=" + group, group.getName().equalsIgnoreCase(expectedGroups[i]));
    }
}
Also used : Iterator(java.util.Iterator) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) Collection(java.util.Collection) LanguageObject(org.teiid.query.sql.LanguageObject) TeiidException(org.teiid.core.TeiidException)

Example 74 with TeiidException

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

the class IndexMetadataRepository method loadAll.

// there are multiple threads trying to load this, since the initial index lading is not
// optimized for multi-thread loading this locking to sync will work
private synchronized void loadAll(Collection<Datatype> systemDatatypes, Map<String, ? extends VDBResource> resources) throws IOException {
    if (this.loaded) {
        return;
    }
    ArrayList<Index> tmp = new ArrayList<Index>();
    for (VDBResource f : resources.values()) {
        if (f.getName().endsWith(VDBResources.INDEX_EXT)) {
            Index index = new Index(f);
            index.setDoCache(true);
            tmp.add(index);
        }
    }
    for (Index index : tmp) {
        try {
            IEntryResult[] results = SimpleIndexUtil.queryIndex(new Index[] { index }, new char[0], true, true, false);
            recordFactory.getMetadataRecord(results);
        } catch (TeiidException e) {
            throw new TeiidRuntimeException(RuntimeMetadataPlugin.Event.TEIID80000, e);
        }
    }
    // force close, since we cached the index files
    for (Index index : tmp) {
        index.close();
    }
    Map<String, AbstractMetadataRecord> uuidToRecord = getByType(MetadataConstants.RECORD_TYPE.DATATYPE);
    if (systemDatatypes != null) {
        for (Datatype datatype : systemDatatypes) {
            uuidToRecord.put(datatype.getUUID(), datatype);
        }
    }
    this.loaded = true;
    // associate the annotation/extension metadata
    for (Map<String, AbstractMetadataRecord> map : allRecords.values()) {
        for (AbstractMetadataRecord metadataRecord : map.values()) {
            String uuid = metadataRecord.getUUID();
            metadataRecord.setAnnotation(this.annotationCache.get(uuid));
            metadataRecord.setProperties(this.extensionCache.get(uuid));
        }
    }
}
Also used : IEntryResult(org.teiid.core.index.IEntryResult) ArrayList(java.util.ArrayList) Index(org.teiid.internal.core.index.Index) TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) TeiidException(org.teiid.core.TeiidException)

Example 75 with TeiidException

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

the class ODataSQLBuilder method updateStreamProperty.

public Update updateStreamProperty(EdmProperty edmProperty, final InputStream content) throws TeiidException {
    Update update = new Update();
    update.setGroup(this.context.getGroupSymbol());
    Column column = this.context.getColumnByName(edmProperty.getName());
    ElementSymbol symbol = new ElementSymbol(column.getName(), this.context.getGroupSymbol());
    update.addChange(symbol, new Reference(0));
    Class<?> lobType = DataTypeManager.getDataTypeClass(column.getRuntimeType());
    int sqlType = JDBCSQLTypeInfo.getSQLType(column.getRuntimeType());
    if (content == null) {
        this.params.add(new SQLParameter(null, sqlType));
    } else {
        Object value = null;
        InputStreamFactory isf = new InputStreamFactory() {

            @Override
            public InputStream getInputStream() throws IOException {
                return content;
            }
        };
        if (lobType.isAssignableFrom(SQLXML.class)) {
            value = new SQLXMLImpl(isf);
        } else if (lobType.isAssignableFrom(ClobType.class)) {
            value = new ClobImpl(isf, -1);
        } else if (lobType.isAssignableFrom(BlobType.class)) {
            value = new BlobImpl(isf);
        } else {
            throw new TeiidException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16031, column.getName()));
        }
        this.params.add(new SQLParameter(value, sqlType));
    }
    update.setCriteria(this.context.getCriteria());
    return update;
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) SQLXMLImpl(org.teiid.core.types.SQLXMLImpl) Reference(org.teiid.query.sql.symbol.Reference) SQLParameter(org.teiid.odata.api.SQLParameter) InputStreamFactory(org.teiid.core.types.InputStreamFactory) SubqueryHint(org.teiid.query.sql.lang.ExistsCriteria.SubqueryHint) TeiidException(org.teiid.core.TeiidException) ClobType(org.teiid.core.types.ClobType) Column(org.teiid.metadata.Column) ClobImpl(org.teiid.core.types.ClobImpl) BlobImpl(org.teiid.core.types.BlobImpl)

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