ClickHouse.Client icon indicating copy to clipboard operation
ClickHouse.Client copied to clipboard

Apache Arrow format

Open askatmaster opened this issue 1 year ago • 1 comments

Hello, can the library use the Apache Arrow format to receive data? If yes, then how?

askatmaster avatar Jul 25 '24 08:07 askatmaster

Hello, yes, it's possible:

using var connection = new ClickHouseConnection("host=localhost;port=8123;database=mydb;username=user;");

await using var command = connection.CreateCommand();
command.CommandText = "select * from my_table format ArrowStream";

var result = await command.ExecuteRawResultAsync(cancellationToken);

await using var stream = await result.ReadAsStreamAsync();

using var reader = new ArrowStreamReader(stream, new CompressionCodecFactory());

var recordBatch = await reader.ReadNextRecordBatchAsync(cancellationToken);

Console.WriteLine(recordBatch.ColumnCount);

If it's not too much trouble, could you explain why this might be needed and what are the use cases for it, please? I'm just curious.

MikeAmputer avatar Jul 27 '24 12:07 MikeAmputer