use of org.apache.ignite.client.proto.query.event.JdbcMetaColumnsResult in project ignite-3 by apache.
the class JdbcQueryEventHandlerImpl method queryMetadataAsync.
/**
* {@inheritDoc}
*/
@Override
public CompletableFuture<JdbcMetaColumnsResult> queryMetadataAsync(JdbcQueryMetadataRequest req) {
SqlCursor<List<?>> cur = openCursors.get(req.cursorId());
if (cur == null) {
return CompletableFuture.completedFuture(new JdbcMetaColumnsResult(Response.STATUS_FAILED, "Failed to find query cursor with ID: " + req.cursorId()));
}
ResultSetMetadata metadata = cur.metadata();
if (metadata == null) {
return CompletableFuture.completedFuture(new JdbcMetaColumnsResult(Response.STATUS_FAILED, "Failed to get query metadata for cursor with ID : " + req.cursorId()));
}
List<JdbcColumnMeta> meta = metadata.fields().stream().map(this::createColumnMetadata).collect(Collectors.toList());
return CompletableFuture.completedFuture(new JdbcMetaColumnsResult(meta));
}
use of org.apache.ignite.client.proto.query.event.JdbcMetaColumnsResult in project ignite-3 by apache.
the class JdbcResultSet method meta.
/**
* Returns columns metadata list.
*
* @return Results metadata.
* @throws SQLException On error.
*/
private List<JdbcColumnMeta> meta() throws SQLException {
if (finished && (!isQuery || autoClose)) {
throw new SQLException("Server cursor is already closed.", SqlStateCode.INVALID_CURSOR_STATE);
}
if (!metaInit) {
JdbcMetaColumnsResult res = qryHandler.queryMetadataAsync(new JdbcQueryMetadataRequest(cursorId)).join();
meta = res.meta();
metaInit = true;
}
return meta;
}
use of org.apache.ignite.client.proto.query.event.JdbcMetaColumnsResult in project ignite-3 by apache.
the class JdbcDatabaseMetadata method getColumns.
/**
* {@inheritDoc}
*/
@Override
public ResultSet getColumns(String catalog, String schemaPtrn, String tblNamePtrn, String colNamePtrn) throws SQLException {
conn.ensureNotClosed();
final List<JdbcColumnMeta> meta = asList(// 1
new JdbcColumnMeta("TABLE_CAT", String.class), // 2
new JdbcColumnMeta("TABLE_SCHEM", String.class), // 3
new JdbcColumnMeta("TABLE_NAME", String.class), // 4
new JdbcColumnMeta("COLUMN_NAME", String.class), // 5
new JdbcColumnMeta("DATA_TYPE", Short.class), // 6
new JdbcColumnMeta("TYPE_NAME", String.class), // 7
new JdbcColumnMeta("COLUMN_SIZE", Integer.class), // 8
new JdbcColumnMeta("BUFFER_LENGTH", Integer.class), // 9
new JdbcColumnMeta("DECIMAL_DIGITS", Integer.class), // 10
new JdbcColumnMeta("NUM_PREC_RADIX", Short.class), // 11
new JdbcColumnMeta("NULLABLE", Short.class), // 12
new JdbcColumnMeta("REMARKS", String.class), // 13
new JdbcColumnMeta("COLUMN_DEF", String.class), // 14
new JdbcColumnMeta("SQL_DATA_TYPE", Integer.class), // 15
new JdbcColumnMeta("SQL_DATETIME_SUB", Integer.class), // 16
new JdbcColumnMeta("CHAR_OCTET_LENGTH", Integer.class), // 17
new JdbcColumnMeta("ORDINAL_POSITION", Integer.class), // 18
new JdbcColumnMeta("IS_NULLABLE", String.class), // 19
new JdbcColumnMeta("SCOPE_CATLOG", String.class), // 20
new JdbcColumnMeta("SCOPE_SCHEMA", String.class), // 21
new JdbcColumnMeta("SCOPE_TABLE", String.class), // 22
new JdbcColumnMeta("SOURCE_DATA_TYPE", Short.class), // 23
new JdbcColumnMeta("IS_AUTOINCREMENT", String.class), // 24
new JdbcColumnMeta("IS_GENERATEDCOLUMN", String.class));
if (!isValidCatalog(catalog)) {
return new JdbcResultSet(Collections.emptyList(), meta);
}
JdbcMetaColumnsResult res = conn.handler().columnsMetaAsync(new JdbcMetaColumnsRequest(schemaPtrn, tblNamePtrn, colNamePtrn)).join();
if (!res.hasResults()) {
throw IgniteQueryErrorCode.createJdbcSqlException(res.err(), res.status());
}
List<List<Object>> rows = new LinkedList<>();
for (int i = 0; i < res.meta().size(); ++i) {
rows.add(columnRow(res.meta().get(i), i + 1));
}
return new JdbcResultSet(rows, meta);
}
Aggregations