question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to get multiple result sets from single query?

See original GitHub issue

ClickHouse sometimes returns multiple tables from single query. For instance, you may specify GROUP BY WITH ROLLUP and get multiple tables. So how is it possible to retrieve such results w/ JDBC or new clickhouse-client interface? Looking into the JDBC code, it seems the statement implementation doesn’t support getMoreResults() in such a way.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
zhicwucommented, Feb 21, 2022

Yes, it will append a few more aggregated rows to the same result set. It’s probably better to return multiple result sets instead.

SELECT year, month, day, count(*)
FROM (
	select 2019 as year, 1 as month, 5 as day
	union all
	select 2019 as year, 1 as month, 15 as day
	union all
	select 2020 as year, 10 as month, 5 as day
) t 
GROUP BY year, month, day WITH ROLLUP

image

1reaction
den-cranecommented, Feb 22, 2022

There is zero guarantee that WITH ROLLUP returns in multiple blocks in Native format. Basically it just the current behavior, it can be changed tomorrow.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Queries returning multiple result sets - java - Stack Overflow
The answer: it is NOT possible. The only way: Run them as separate queries.
Read more >
Using multiple result sets - JDBC Driver for SQL Server
Learn how to query and retrieve multiple result sets from a single execute using the JDBC Driver for SQL Server.
Read more >
Multiple Result Sets With .Net Core and SQL Server
In this post, I will show you how to use multiple result sets to do the following: Reduce the complexity of queries; Reduce...
Read more >
Handling Multiple Resultsets - Dapper .NET - Medium
The correct solution is to query the Customer table and create the single Customer object and then query the Order table, create the...
Read more >
16.20 - Multiple Result Sets Toolbar - Teradata Studio
This option is enabled when you execute multiple SQL statements in a single execution, using the following SQL Editor menu options: Execute All,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found