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

Add a streamAll() method to the Client class to return an iterable of POJO's

Open lin-lu opened this issue 8 months ago • 1 comments

In the client v1, there is a stream() method in the ClickHouseResponse class that returns a stream of POJO's: https://github.com/ClickHouse/clickhouse-java/blob/8649357eb64b14d970148e68815fc46d378c2ab7/clickhouse-client/src/main/java/com/clickhouse/client/ClickHouseResponse.java#L195-L203

In the client v2, the Client class has a queryAll() method that returns a List of POJO's: https://github.com/ClickHouse/clickhouse-java/blob/6b3a2298af610bf8ce8f6a8c80a8e6250569b11f/client-v2/src/main/java/com/clickhouse/client/api/Client.java#L1866-L1925

Would it be possible to add a streamAll() method to the Client class that returns an iterable of POJO's? This would make it more memory efficient when there are a large number of objects returned by the query.

lin-lu avatar Apr 15 '25 13:04 lin-lu

Good day, @lin-lu! Thank you for asking!

We have a iterating API com.clickhouse.client.api.Client#queryRecords(java.lang.String, com.clickhouse.client.api.query.QuerySettings) and yes we can do what you are asking for.

However if you are fetching list of POJOs and need them all anyway - then queryAll would work best.

chernser avatar Apr 15 '25 17:04 chernser