use of org.apache.ignite.client.proto.query.event.JdbcMetaTablesRequest in project ignite-3 by apache.
the class JdbcDatabaseMetadata method getTables.
/**
* {@inheritDoc}
*/
@Override
public ResultSet getTables(String catalog, String schemaPtrn, String tblNamePtrn, String[] tblTypes) throws SQLException {
conn.ensureNotClosed();
final List<JdbcColumnMeta> meta = asList(new JdbcColumnMeta("TABLE_CAT", String.class), new JdbcColumnMeta("TABLE_SCHEM", String.class), new JdbcColumnMeta("TABLE_NAME", String.class), new JdbcColumnMeta("TABLE_TYPE", String.class), new JdbcColumnMeta("REMARKS", String.class), new JdbcColumnMeta("TYPE_CAT", String.class), new JdbcColumnMeta("TYPE_SCHEM", String.class), new JdbcColumnMeta("TYPE_NAME", String.class), new JdbcColumnMeta("SELF_REFERENCING_COL_NAME", String.class), new JdbcColumnMeta("REF_GENERATION", String.class));
boolean tblTypeMatch = false;
if (tblTypes == null) {
tblTypeMatch = true;
} else {
for (String type : tblTypes) {
if (TYPE_TABLE.equals(type)) {
tblTypeMatch = true;
break;
}
}
}
if (!isValidCatalog(catalog) || !tblTypeMatch) {
return new JdbcResultSet(Collections.emptyList(), meta);
}
JdbcMetaTablesResult res = conn.handler().tablesMetaAsync(new JdbcMetaTablesRequest(schemaPtrn, tblNamePtrn, tblTypes)).join();
if (!res.hasResults()) {
throw IgniteQueryErrorCode.createJdbcSqlException(res.err(), res.status());
}
List<List<Object>> rows = new LinkedList<>();
for (JdbcTableMeta tblMeta : res.meta()) {
rows.add(tableRow(tblMeta));
}
return new JdbcResultSet(rows, meta);
}
Aggregations