use of org.apache.ignite.internal.processors.query.QueryField in project ignite by apache.
the class DynamicColumnsAbstractTest method checkTableState.
/**
* Check that given columns are seen by client.
* @param node Node to check.
* @param schemaName Schema name to look for the table in.
* @param tblName Table name to check.
* @param cols Columns whose presence must be checked.
* @return Number of other columns.
*/
static int checkTableState(IgniteEx node, String schemaName, String tblName, QueryField... cols) throws SQLException {
List<QueryField> flds = new ArrayList<>();
try (Connection c = connect(node)) {
try (ResultSet rs = c.getMetaData().getColumns(null, schemaName, tblName, "%")) {
while (rs.next()) {
String name = rs.getString("COLUMN_NAME");
short type = rs.getShort("DATA_TYPE");
String typeClsName = DataType.getTypeClassName(DataType.convertSQLTypeToValueType(type));
short nullable = rs.getShort("NULLABLE");
flds.add(new QueryField(name, typeClsName, nullable == 1));
}
}
}
Iterator<QueryField> it = flds.iterator();
for (int i = flds.size() - cols.length; i > 0 && it.hasNext(); i--) it.next();
for (QueryField exp : cols) {
assertTrue("New column not found in metadata: " + exp.name(), it.hasNext());
QueryField act = it.next();
assertEquals(exp.name(), act.name());
assertEquals(exp.typeName(), act.typeName());
assertEquals(exp.isNullable(), act.isNullable());
}
return flds.size() - cols.length;
}
Aggregations