Skip to content

Commit

Permalink
Fix XSV format printing the header once for each batch
Browse files Browse the repository at this point in the history
  • Loading branch information
jachris committed May 8, 2024
1 parent c810f07 commit 28ae64d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
6 changes: 3 additions & 3 deletions libtenzir/builtins/formats/xsv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,9 @@ class xsv_printer final : public plugin_printer {
instantiate([[maybe_unused]] type input_schema, operator_control_plane&) const
-> caf::expected<std::unique_ptr<printer_instance>> override {
auto metadata = chunk_metadata{.content_type = content_type()};
return printer_instance::make([meta = std::move(metadata), args = args_](
table_slice slice) -> generator<chunk_ptr> {
return printer_instance::make([meta = std::move(metadata), args = args_,
first = true](table_slice slice) mutable
-> generator<chunk_ptr> {
if (slice.rows() == 0) {
co_yield {};
co_return;
Expand All @@ -468,7 +469,6 @@ class xsv_printer final : public plugin_printer {
auto input_type = caf::get<record_type>(input_schema);
auto array
= to_record_batch(resolved_slice)->ToStructArray().ValueOrDie();
auto first = true;
for (const auto& row : values(input_type, *array)) {
TENZIR_ASSERT(row);
if (first && not args.no_header) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
foo
1
foo
2

0 comments on commit 28ae64d

Please sign in to comment.