use of org.apache.ignite.internal.sql.engine.QueryProcessor in project ignite-3 by apache.
the class QueryChecker method check.
/**
* Run checks.
*/
public void check() {
// Check plan.
QueryProcessor qryProc = getEngine();
List<SqlCursor<List<?>>> explainCursors = qryProc.query("PUBLIC", "EXPLAIN PLAN FOR " + qry);
Cursor<List<?>> explainCursor = explainCursors.get(0);
List<List<?>> explainRes = getAllFromCursor(explainCursor);
String actualPlan = (String) explainRes.get(0).get(0);
if (!CollectionUtils.nullOrEmpty(planMatchers)) {
for (Matcher<String> matcher : planMatchers) {
assertThat("Invalid plan:\n" + actualPlan, actualPlan, matcher);
}
}
if (exactPlan != null) {
assertEquals(exactPlan, actualPlan);
}
// Check result.
List<SqlCursor<List<?>>> cursors = qryProc.query("PUBLIC", qry, params);
SqlCursor<List<?>> cur = cursors.get(0);
if (expectedColumnNames != null) {
List<String> colNames = cur.metadata().fields().stream().map(ResultFieldMetadata::name).collect(Collectors.toList());
assertThat("Column names don't match", colNames, equalTo(expectedColumnNames));
}
if (expectedColumnTypes != null) {
List<Type> colNames = cur.metadata().fields().stream().map(ResultFieldMetadata::type).map(Commons::nativeTypeToClass).collect(Collectors.toList());
assertThat("Column types don't match", colNames, equalTo(expectedColumnTypes));
}
List<List<?>> res = CursorUtils.getAllFromCursor(cur);
if (expectedResult != null) {
if (!ordered) {
// Avoid arbitrary order.
res.sort(new ListComparator());
expectedResult.sort(new ListComparator());
}
assertEqualsCollections(expectedResult, res);
}
}
Aggregations