@Override
  public void close() {
    if (_executionFuture != null) {
      _executionFuture.cancel(true);
    }
  }
@Test
  public void shouldGetErrorBlockWhenInstanceResponseContainsError() {
    // Given:
    QueryContext queryContext = QueryContextConverterUtils.getQueryContext("SELECT strCol, intCol FROM tbl");
    DataSchema schema = new DataSchema(new String[]{"strCol", "intCol"},
        new DataSchema.ColumnDataType[]{DataSchema.ColumnDataType.STRING, DataSchema.ColumnDataType.INT});
    List<BaseResultsBlock> dataBlocks = Collections.singletonList(
        new SelectionResultsBlock(schema, Arrays.asList(new Object[]{"foo", 1}, new Object[]{"", 2}), queryContext));
    InstanceResponseBlock errorBlock = new InstanceResponseBlock();
    errorBlock.addException(QueryException.QUERY_EXECUTION_ERROR.getErrorCode(), "foobar");
    QueryExecutor queryExecutor = mockQueryExecutor(dataBlocks, errorBlock);
    LeafStageTransferableBlockOperator operator =
        new LeafStageTransferableBlockOperator(OperatorTestUtil.getTracingContext(), mockQueryRequests(1), schema,
            queryExecutor, _executorService);
    _operatorRef.set(operator);

    // When:
    TransferableBlock resultBlock = operator.nextBlock();

    // Then: error block can be returned as first or second block depending on the sequence of the execution
    if (!resultBlock.isErrorBlock()) {
      Assert.assertTrue(operator.nextBlock().isErrorBlock());
    }

    operator.close();
  }