use of org.apache.ignite.internal.processors.cache.QueryCursorImpl in project ignite by apache.
the class MultipleStatementsSqlQuerySelfTest method testQuery.
/**
* Test query without caches.
*/
@Test
public void testQuery() {
GridQueryProcessor qryProc = node.context().query();
SqlFieldsQuery qry = new SqlFieldsQuery("create table test(ID int primary key, NAME varchar(20)); " + "insert into test (ID, NAME) values (1, 'name_1');" + "insert into test (ID, NAME) values (2, 'name_2'), (3, 'name_3');" + "select * from test;").setSchema("PUBLIC");
List<FieldsQueryCursor<List<?>>> res = qryProc.querySqlFields(qry, true, false);
assert res.size() == 4 : "Unexpected cursors count: " + res.size();
assert !((QueryCursorImpl) res.get(0)).isQuery() : "Results of DDL statement is expected ";
List<List<?>> rows = res.get(1).getAll();
assert !((QueryCursorImpl) res.get(1)).isQuery() : "Results of DDL statement is expected ";
assert Long.valueOf(1).equals(rows.get(0).get(0)) : "1 row must be updated. [actual=" + rows.get(0).get(0) + ']';
rows = res.get(2).getAll();
assert !((QueryCursorImpl) res.get(2)).isQuery() : "Results of DML statement is expected ";
assert Long.valueOf(2).equals(rows.get(0).get(0)) : "2 row must be updated";
rows = res.get(3).getAll();
assert ((QueryCursorImpl) res.get(3)).isQuery() : "Results of SELECT statement is expected ";
assert rows.size() == 3 : "Invalid rows count: " + rows.size();
for (int i = 0; i < rows.size(); ++i) {
assert Integer.valueOf(1).equals(rows.get(i).get(0)) || Integer.valueOf(2).equals(rows.get(i).get(0)) || Integer.valueOf(3).equals(rows.get(i).get(0)) : "Invalid ID: " + rows.get(i).get(0);
}
}
use of org.apache.ignite.internal.processors.cache.QueryCursorImpl in project ignite by apache.
the class H2Utils method zeroCursor.
/**
* @return Single-column, single-row cursor with 0 as number of updated records.
*/
@SuppressWarnings("unchecked")
public static QueryCursorImpl<List<?>> zeroCursor() {
QueryCursorImpl<List<?>> resCur = (QueryCursorImpl<List<?>>) new QueryCursorImpl(Collections.singletonList(Collections.singletonList(0L)), null, false, false);
resCur.fieldsMeta(UPDATE_RESULT_META);
return resCur;
}
Aggregations