clickhouse-java icon indicating copy to clipboard operation
clickhouse-java copied to clipboard

How to use ClientV2 and ExternalTable

Open den-crane opened this issue 7 months ago • 1 comments

I need an example how to use ClientV2 and ExternalTable

For example I have a simple query select * from numbers(10) where number in ExternalTable;

        final Client client = new Client.Builder().setUsername("default").setPassword("").addEndpoint("http://localhost:8123/")
                .build();

        final String sql = "select * from numbers(10) where number in ExternalTable";
        QueryResponse response = client.query(sql).get(3, TimeUnit.SECONDS);
        ClickHouseBinaryFormatReader reader = client.newBinaryFormatReader(response);
        while (reader.hasNext()) {
            reader.next();
            System.out.println(reader.getLong("number"));
        }

And I need to pass 1\n\2\n3 as ExternalTable.

Like here https://github.com/ClickHouse/clickhouse-java/blob/bed84eecaf34fd959ef10df35ec73912991d5047/clickhouse-client/src/test/java/com/clickhouse/client/ClientIntegrationTest.java#L570

Or here https://github.com/ClickHouse/clickhouse-java/issues/891

https://clickhouse.com/docs/engines/table-engines/special/external-data

I need it because I want to pass a list with 200k values and a query size (SQL length) without using the external data is bigger than 1Mb.

den-crane avatar May 29 '25 23:05 den-crane

@den-crane This is not supported in v2 currently. Will look into it short this week.

chernser avatar Jun 05 '25 01:06 chernser