use of org.apache.calcite.avatica.remote.Service.ExecuteRequest in project calcite-avatica by apache.
the class ExecuteRequestTest method testNewFieldIsUsed.
@Test
public void testNewFieldIsUsed() {
Requests.ExecuteRequest proto = Requests.ExecuteRequest.newBuilder().setFirstFrameMaxSize(2).setStatementHandle(STATEMENT_HANDLE.toProto()).build();
ExecuteRequest request = new ExecuteRequest();
request = request.deserialize(proto);
assertEquals(proto.getFirstFrameMaxSize(), request.maxRowCount);
}
use of org.apache.calcite.avatica.remote.Service.ExecuteRequest in project calcite-avatica by apache.
the class ExecuteRequestTest method testNewFieldOverridesOldField.
@Test
public void testNewFieldOverridesOldField() {
Requests.ExecuteRequest proto = Requests.ExecuteRequest.newBuilder().setDeprecatedFirstFrameMaxSize(1).setFirstFrameMaxSize(2).setStatementHandle(STATEMENT_HANDLE.toProto()).build();
ExecuteRequest request = new ExecuteRequest();
request = request.deserialize(proto);
assertEquals(proto.getFirstFrameMaxSize(), request.maxRowCount);
}
use of org.apache.calcite.avatica.remote.Service.ExecuteRequest in project calcite-avatica by apache.
the class ProtobufTranslationImplTest method getRequests.
/**
* Generates a collection of Requests whose serialization will be tested.
*/
private static List<Request> getRequests() {
LinkedList<Request> requests = new LinkedList<>();
requests.add(new CatalogsRequest());
requests.add(new DatabasePropertyRequest());
requests.add(new SchemasRequest("connectionId", "catalog", "schemaPattern"));
requests.add(new TablesRequest("connectionId", "catalog", "schemaPattern", "tableNamePattern", Arrays.asList("STRING", "BOOLEAN", "INT")));
requests.add(new TableTypesRequest());
requests.add(new ColumnsRequest("connectionId", "catalog", "schemaPattern", "tableNamePattern", "columnNamePattern"));
requests.add(new TypeInfoRequest());
requests.add(new PrepareAndExecuteRequest("connectionId", Integer.MAX_VALUE, "sql", Long.MAX_VALUE));
requests.add(new PrepareRequest("connectionId", "sql", Long.MAX_VALUE));
List<TypedValue> paramValues = Arrays.asList(TypedValue.create(Rep.BOOLEAN.name(), Boolean.TRUE), TypedValue.create(Rep.STRING.name(), "string"));
FetchRequest fetchRequest = new FetchRequest("connectionId", Integer.MAX_VALUE, Long.MAX_VALUE, Integer.MAX_VALUE);
requests.add(fetchRequest);
requests.add(new CreateStatementRequest("connectionId"));
requests.add(new CloseStatementRequest("connectionId", Integer.MAX_VALUE));
Map<String, String> info = new HashMap<>();
info.put("param1", "value1");
info.put("param2", "value2");
requests.add(new OpenConnectionRequest("connectionId", info));
requests.add(new CloseConnectionRequest("connectionId"));
requests.add(new ConnectionSyncRequest("connectionId", new ConnectionPropertiesImpl(Boolean.FALSE, Boolean.FALSE, Integer.MAX_VALUE, "catalog", "schema")));
requests.add(new SyncResultsRequest("connectionId", 12345, getSqlQueryState(), 150));
requests.add(new SyncResultsRequest("connectionId2", 54321, getMetadataQueryState1(), 0));
requests.add(new SyncResultsRequest("connectionId3", 5, getMetadataQueryState2(), 10));
requests.add(new CommitRequest("connectionId"));
requests.add(new RollbackRequest("connectionId"));
// ExecuteBatchRequest omitted because of the special protobuf conversion it does
List<String> commands = Arrays.asList("command1", "command2", "command3");
requests.add(new PrepareAndExecuteBatchRequest("connectionId", 12345, commands));
List<ColumnMetaData> columns = Collections.emptyList();
List<AvaticaParameter> params = Collections.emptyList();
Meta.CursorFactory cursorFactory = Meta.CursorFactory.create(Style.LIST, Object.class, Collections.<String>emptyList());
Signature signature = Signature.create(columns, "sql", params, cursorFactory, Meta.StatementType.SELECT);
Meta.StatementHandle handle = new Meta.StatementHandle("1234", 1, signature);
requests.add(new ExecuteRequest(handle, Arrays.<TypedValue>asList((TypedValue) null), 10));
requests.add(new ExecuteRequest(handle, Arrays.asList(TypedValue.EXPLICIT_NULL), 10));
return requests;
}
use of org.apache.calcite.avatica.remote.Service.ExecuteRequest in project calcite-avatica by apache.
the class ExecuteRequestTest method testUsesDeprecatedFieldIfPresent.
@Test
public void testUsesDeprecatedFieldIfPresent() {
Requests.ExecuteRequest proto = Requests.ExecuteRequest.newBuilder().setDeprecatedFirstFrameMaxSize(1).setStatementHandle(STATEMENT_HANDLE.toProto()).build();
ExecuteRequest request = new ExecuteRequest();
request = request.deserialize(proto);
assertEquals(proto.getDeprecatedFirstFrameMaxSize(), request.maxRowCount);
}
use of org.apache.calcite.avatica.remote.Service.ExecuteRequest in project calcite-avatica by apache.
the class ExecuteRequestTest method testBothFieldsAreSerialized.
@Test
public void testBothFieldsAreSerialized() {
ExecuteRequest request = new ExecuteRequest(STATEMENT_HANDLE, Collections.<TypedValue>emptyList(), 5);
Requests.ExecuteRequest proto = request.serialize();
assertEquals(request.maxRowCount, proto.getDeprecatedFirstFrameMaxSize());
assertEquals(request.maxRowCount, proto.getFirstFrameMaxSize());
}
Aggregations