use of org.apache.calcite.avatica.AvaticaResultSet in project calcite-avatica by apache.
the class ArrayFactoryImpl method create.
@Override
public ResultSet create(AvaticaType elementType, Iterable<Object> elements) {
// The ColumnMetaData for offset "1" in the ResultSet for an Array.
ScalarType arrayOffsetType = ColumnMetaData.scalar(Types.INTEGER, "INTEGER", Rep.PRIMITIVE_INT);
// Two columns (types) in the ResultSet we will create
List<ColumnMetaData> types = Arrays.asList(ColumnMetaData.dummy(arrayOffsetType, false), ColumnMetaData.dummy(elementType, true));
List<List<Object>> rows = createResultSetRowsForArrayData(elements);
// `(List<Object>) rows` is a compile error.
@SuppressWarnings({ "unchecked", "rawtypes" }) List<Object> untypedRows = (List<Object>) ((List) rows);
try (ListIteratorCursor cursor = new ListIteratorCursor(rows.iterator())) {
final String sql = "MOCKED";
QueryState state = new QueryState(sql);
Meta.Signature signature = new Meta.Signature(types, sql, Collections.<AvaticaParameter>emptyList(), Collections.<String, Object>emptyMap(), Meta.CursorFactory.LIST, Meta.StatementType.SELECT);
AvaticaResultSetMetaData resultSetMetaData = new AvaticaResultSetMetaData(null, sql, signature);
Meta.Frame frame = new Meta.Frame(0, true, untypedRows);
AvaticaResultSet resultSet = new AvaticaResultSet(null, state, signature, resultSetMetaData, timeZone, frame);
resultSet.execute2(cursor, types);
return resultSet;
}
}
Aggregations