Search in sources :

Example 21 with TransformationException

use of org.teiid.core.types.TransformationException in project teiid by teiid.

the class ArrayTableNode method nextBatchDirect.

@Override
protected TupleBatch nextBatchDirect() throws BlockedException, TeiidComponentException, TeiidProcessingException {
    Object array = getEvaluator(Collections.emptyMap()).evaluate(table.getArrayValue(), null);
    if (array != null) {
        ArrayList<Object> tuple = new ArrayList<Object>(projectionIndexes.length);
        for (int output : projectionIndexes) {
            ProjectedColumn col = table.getColumns().get(output);
            try {
                Object val = FunctionMethods.array_get(array, output + 1);
                tuple.add(DataTypeManager.transformValue(val, table.getColumns().get(output).getSymbol().getType()));
            } catch (TransformationException e) {
                throw new TeiidProcessingException(QueryPlugin.Event.TEIID30190, e, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30190, col.getName()));
            } catch (SQLException e) {
                throw new TeiidProcessingException(QueryPlugin.Event.TEIID30188, e);
            }
        }
        addBatchRow(tuple);
    }
    terminateBatches();
    return pullBatch();
}
Also used : TransformationException(org.teiid.core.types.TransformationException) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) LanguageObject(org.teiid.query.sql.LanguageObject) ProjectedColumn(org.teiid.query.sql.lang.TableFunctionReference.ProjectedColumn) TeiidProcessingException(org.teiid.core.TeiidProcessingException)

Example 22 with TransformationException

use of org.teiid.core.types.TransformationException in project teiid by teiid.

the class StringToSQLXMLTransform method isXml.

public static Type isXml(Reader reader) throws TransformationException {
    Type type = Type.ELEMENT;
    XMLInputFactory inputFactory = XMLType.getXmlInputFactory();
    try {
        XMLStreamReader xmlReader = inputFactory.createXMLStreamReader(reader);
        int event = xmlReader.getEventType();
        if (event == XMLEvent.START_DOCUMENT && xmlReader.getLocation().getColumnNumber() != 1) {
            type = Type.DOCUMENT;
        }
        while (xmlReader.hasNext()) {
            xmlReader.next();
        }
    } catch (Exception e) {
        throw new TransformationException(CorePlugin.Event.TEIID10070, e, CorePlugin.Util.gs(CorePlugin.Event.TEIID10070));
    } finally {
        try {
            reader.close();
        } catch (IOException e) {
        }
    }
    return type;
}
Also used : Type(org.teiid.core.types.XMLType.Type) XMLType(org.teiid.core.types.XMLType) TransformationException(org.teiid.core.types.TransformationException) XMLStreamReader(javax.xml.stream.XMLStreamReader) IOException(java.io.IOException) XMLInputFactory(javax.xml.stream.XMLInputFactory) IOException(java.io.IOException) TransformationException(org.teiid.core.types.TransformationException)

Aggregations

TransformationException (org.teiid.core.types.TransformationException)22 IOException (java.io.IOException)6 SQLException (java.sql.SQLException)6 Timestamp (java.sql.Timestamp)4 ArrayList (java.util.ArrayList)4 XMLType (org.teiid.core.types.XMLType)4 TranslatorException (org.teiid.translator.TranslatorException)4 InputStream (java.io.InputStream)3 Blob (java.sql.Blob)3 Date (java.sql.Date)3 FunctionExecutionException (org.teiid.api.exception.query.FunctionExecutionException)3 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)3 BinaryType (org.teiid.core.types.BinaryType)3 Transform (org.teiid.core.types.Transform)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 BigInteger (java.math.BigInteger)2 SQLXML (java.sql.SQLXML)2 BlobImpl (org.teiid.core.types.BlobImpl)2 BlobType (org.teiid.core.types.BlobType)2 ClobImpl (org.teiid.core.types.ClobImpl)2