Search in sources :

Example 1 with ProjectedColumn

use of org.teiid.query.sql.lang.TableFunctionReference.ProjectedColumn in project teiid by teiid.

the class SQLStringVisitor method visit.

@Override
public void visit(ArrayTable obj) {
    addHintComment(obj);
    // $NON-NLS-1$
    append("ARRAYTABLE(");
    visitNode(obj.getArrayValue());
    append(SPACE);
    append(NonReserved.COLUMNS);
    for (Iterator<ProjectedColumn> cols = obj.getColumns().iterator(); cols.hasNext(); ) {
        ProjectedColumn col = cols.next();
        append(SPACE);
        outputDisplayName(col.getName());
        append(SPACE);
        append(col.getType());
        if (cols.hasNext()) {
            // $NON-NLS-1$
            append(",");
        }
    }
    // $NON-NLS-1$
    append(")");
    append(SPACE);
    append(AS);
    append(SPACE);
    outputDisplayName(obj.getName());
}
Also used : ProjectedColumn(org.teiid.query.sql.lang.TableFunctionReference.ProjectedColumn)

Example 2 with ProjectedColumn

use of org.teiid.query.sql.lang.TableFunctionReference.ProjectedColumn 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)

Aggregations

ProjectedColumn (org.teiid.query.sql.lang.TableFunctionReference.ProjectedColumn)2 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 TeiidProcessingException (org.teiid.core.TeiidProcessingException)1 TransformationException (org.teiid.core.types.TransformationException)1 LanguageObject (org.teiid.query.sql.LanguageObject)1