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.

Output format support

See original GitHub issue

Quite often all appication is doing is just feeding query result to a “processing pipeline” in some format (“returning json from rest api to some client, maybe some SPA” is not an exception here). As clickhouse already supports great variety of output formats that could be fed to the “pipeline” (json, protobuf, avro, arrow, parquet, csv) it looks reasonable to allow query results to be returned in desired format to cut ADO and formatting libraries all together. There can be an extension method on a reader object named, for example, “export”, accepting stream where data should be copied:

var command = connection.CreateCommand();
command.Text = ".... Format Protobuf";
using var reader = await command.ExecuteReaderAsync();
await reader.Export(output);

Another option is having extension method for command:

var command = connection.CreateCommand();
command.Text = ".... Format Protobuf";
using var exporter = await command.ExecuteExportAsync();
await exporter.Export(output);

It is important to separate query execution from “copying results” to be able to handle errors

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

DarkWanderercommented, Jun 23, 2020


Added ExecuteRawResultAsync function, example:

            using var command = connection.CreateCommand();
            command.CommandText = "SELECT 1 FORMAT TSV";
            using var result = await command.ExecuteRawResultAsync(CancellationToken.None);
            using var stream = await result.ReadAsStreamAsync();
            using var reader = new StreamReader(stream);
            Assert.AreEqual("1", reader.ReadToEnd().Trim());

It will return an object which exposes an underlying stream, so any format can be used and parsed. Or, if you want to write it somewhere, CopyToAsync to another stream

DarkWanderercommented, Jul 1, 2020

Released version 2.0.0 with this

Read more comments on GitHub >

github_iconTop Results From Across the Web

Output Formats
Format Command‑line parameter Description BMP bmp Windows Bitmap CGImage cgimage Apple Core Graphics DOT canon dot gv xdot xdot1.2 xdot1.4 Graphviz Language
Read more >
Output formats
Output formats are used to determine which data is exported and how data is displayed in many areas of OLIB.
Read more >
Format support by output container - MediaLive
The type of output containers – A given output container supports some captions formats and not others. For example, assume that your input...
Read more >
GenRocket Supported Output Formats - Solutions
GenRocket can generate data in any format you need. GenRocket Receivers handle formatting generated test data. Our team is constantly adding new ...
Read more >
Supported output formats
Standard owner Support for B‑frames VBR Audio Variable... AVI Microsoft Only through hacks Yes No MPEG‑2 PS (Program Stream) MPEG Yes Yes ? MPEG‑2 TS (Transport...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found