in core/src/main/java/org/apache/calcite/avatica/remote/MockProtobufService.java [45:107]
private Map<Request, Response> createMapping() {
HashMap<Request, Response> mappings = new HashMap<>();
// Add in mappings
mappings.put(
new OpenConnectionRequest(connectionId, new HashMap<String, String>()),
new OpenConnectionResponse());
// Get the schema, no.. schema..?
mappings.put(
new SchemasRequest(connectionId, null, null),
// ownStatement=false just to avoid the extra close statement call.
new ResultSetResponse(null, 1, false, null, Meta.Frame.EMPTY, -1, null));
// Get the tables, no tables exist
mappings.put(new TablesRequest(connectionId, null, null, null, Collections.<String>emptyList()),
// ownStatement=false just to avoid the extra close statement call.
new ResultSetResponse(null, 150, false, null, Meta.Frame.EMPTY, -1, null));
// Create a statement, get back an id
mappings.put(new CreateStatementRequest("0"), new CreateStatementResponse("0", 1, null));
// Prepare and execute a query. Values and schema are returned
mappings.put(
new PrepareAndExecuteRequest(connectionId, 1,
"select * from (\\n values (1, 'a'), (null, 'b'), (3, 'c')) as t (c1, c2)", -1),
new ResultSetResponse("0", 1, true,
Meta.Signature.create(
Arrays.<ColumnMetaData>asList(
MetaImpl.columnMetaData("C1", 0, Integer.class, true),
MetaImpl.columnMetaData("C2", 1, String.class, true)),
null, null, Meta.CursorFactory.ARRAY, Meta.StatementType.SELECT),
Meta.Frame.create(0, true,
Arrays.<Object>asList(new Object[] {1, "a"},
new Object[] {null, "b"}, new Object[] {3, "c"})), -1, null));
// Prepare a query. Schema for results are returned, but no values
mappings.put(
new PrepareRequest(connectionId,
"select * from (\\n values(1, 'a'), (null, 'b'), (3, 'c')), as t (c1, c2)", -1),
new ResultSetResponse("0", 1, true,
Meta.Signature.create(
Arrays.<ColumnMetaData>asList(
MetaImpl.columnMetaData("C1", 0, Integer.class, true),
MetaImpl.columnMetaData("C2", 1, String.class, true)),
null, Collections.<AvaticaParameter>emptyList(),
Meta.CursorFactory.ARRAY, Meta.StatementType.SELECT),
null, -1, null));
mappings.put(
new ColumnsRequest(connectionId, null, null, "my_table", null),
new ResultSetResponse("00000000-0000-0000-0000-000000000000", -1, true,
Meta.Signature.create(
Arrays.<ColumnMetaData>asList(
MetaImpl.columnMetaData("TABLE_NAME", 0, String.class, true),
MetaImpl.columnMetaData("ORDINAL_POSITION", 1, Long.class, true)), null,
Collections.<AvaticaParameter>emptyList(), Meta.CursorFactory.ARRAY, null),
Meta.Frame.create(0, true,
Arrays.<Object>asList(new Object[] {new Object[]{"my_table", 10}})), -1, null));
return Collections.unmodifiableMap(mappings);
}