#include #include #include #include #include #include #include #include #include #include #include #include using namespace DB; int main() try { Block sample; { // a ColumnWithTypeAndName col; col.name = "a"; col.type = std::make_shared(); sample.insert(std::move(col)); } { // b ColumnWithTypeAndName col; col.name = "b"; col.type = std::make_shared(); sample.insert(std::move(col)); } { // c ColumnWithTypeAndName col; col.name = "c"; col.type = std::make_shared(); sample.insert(std::move(col)); } { // d ColumnWithTypeAndName col; col.name = "d"; col.type = std::make_shared(); sample.insert(std::move(col)); } { // e ColumnWithTypeAndName col; col.name = "e"; col.type = std::make_shared(); sample.insert(std::move(col)); } { // f ColumnWithTypeAndName col; col.name = "f"; col.type = std::make_shared(); sample.insert(std::move(col)); } { // g ColumnWithTypeAndName col; col.name = "g"; col.type = std::make_shared(); sample.insert(std::move(col)); } { // h ColumnWithTypeAndName col; col.name = "h"; col.type = std::make_shared(); sample.insert(std::move(col)); } ReadBufferFromFile in_buf("test_in"); WriteBufferFromFile out_buf("test_out"); FormatSettings format_settings; format_settings.with_names_use_header = true; format_settings.skip_unknown_fields = true; format_settings.csv.delimiter = '\x01'; format_settings.hive_text.input_field_names = { "d", "e", "f", "a", "b", "c", "g", "h", "i", "j", }; RowInputFormatParams in_params{DEFAULT_INSERT_BLOCK_SIZE}; InputFormatPtr input_format = std::make_shared(sample, in_buf, in_params, format_settings); auto pipeline = QueryPipeline(std::move(input_format)); auto reader = std::make_unique(pipeline); OutputFormatPtr output_format = std::make_shared(out_buf, sample, true, true, format_settings); Block res; while (reader->pull(res)) { output_format->write(res); } return 0; } catch (...) { std::cerr << getCurrentExceptionMessage(true) << '\n'; return 1; }