@Override
    public void close() {
        this.displayResultExecutorService.shutdown();
    }
@Test
    void testCancelStreamingResultWithDisplayingTimeCost() throws Exception {
        final Configuration testConfig = new Configuration();
        testConfig.set(EXECUTION_RESULT_MODE, ResultMode.TABLEAU);
        testConfig.set(RUNTIME_MODE, RuntimeExecutionMode.STREAMING);

        TestChangelogResult collectResult =
                new TestChangelogResult(
                        () ->
                                TypedResult.payload(
                                        streamingData.subList(0, streamingData.size() / 2)),
                        TypedResult::empty);
        ResultDescriptor resultDescriptor =
                new ResultDescriptor(CliClientTestUtils.createTestClient(schema), testConfig);
        CliTableauResultView view =
                new CliTableauResultView(
                        terminal, resultDescriptor, collectResult, System.currentTimeMillis());

        // submit result display in another thread
        Future<?> furture = EXECUTOR_RESOURCE.getExecutor().submit(view::displayResults);

        // wait until we processed first result
        CommonTestUtils.waitUntilCondition(() -> collectResult.fetchCount.get() > 1, 50L);

        // send signal to cancel
        terminal.raise(Terminal.Signal.INT);
        furture.get(10, TimeUnit.SECONDS);
        view.close();

        assertThat(terminalOutput.toString())
                .contains(
                        "+----+---------+-------------+----------------------+--------------------------------+----------------+----------------------------+--------------------------------+"
                                + System.lineSeparator()
                                + "| op | boolean |         int |               bigint |                        varchar | decimal(10, 5) |                  timestamp |                         binary |"
                                + System.lineSeparator()
                                + "+----+---------+-------------+----------------------+--------------------------------+----------------+----------------------------+--------------------------------+"
                                + System.lineSeparator()
                                + "| +I |  <NULL> |           1 |                    2 |                            abc |        1.23000 | 2020-03-01 18:39:14.000000 |            x'32333485365d737e' |"
                                + System.lineSeparator()
                                + "| -U |   FALSE |      <NULL> |                    0 |                                |        1.00000 | 2020-03-01 18:39:14.100000 |                  x'649e207983' |"
                                + System.lineSeparator()
                                + "| +U |    TRUE |  2147483647 |               <NULL> |                        abcdefg |    12345.00000 | 2020-03-01 18:39:14.120000 |                    x'92e90102' |"
                                + System.lineSeparator()
                                + "| -D |   FALSE | -2147483648 |  9223372036854775807 |                         <NULL> |    12345.06789 | 2020-03-01 18:39:14.123000 |            x'32333485365d737e' |"
                                + System.lineSeparator()
                                + "Query terminated, received a total of 4 rows");

        String[] outputLines = terminalOutput.toString().split("\\r?\\n");
        assertThat(outputLines[outputLines.length - 1])
                .matches(
                        "Query terminated, received a total of 4 rows \\(\\d+\\.\\d{2} seconds\\)");

        // close job manually
        assertThat(collectResult.closed).isTrue();
    }