| 1 | #include <iostream> |
| 2 | |
| 3 | #include <IO/WriteBufferFromOStream.h> |
| 4 | #include <Storages/System/StorageSystemNumbers.h> |
| 5 | #include <DataStreams/LimitBlockInputStream.h> |
| 6 | #include <Formats/FormatFactory.h> |
| 7 | #include <DataStreams/copyData.h> |
| 8 | #include <DataTypes/DataTypesNumber.h> |
| 9 | #include <Interpreters/Context.h> |
| 10 | |
| 11 | |
| 12 | int main(int, char **) |
| 13 | try |
| 14 | { |
| 15 | using namespace DB; |
| 16 | |
| 17 | StoragePtr table = StorageSystemNumbers::create("numbers" , false); |
| 18 | |
| 19 | Names column_names; |
| 20 | column_names.push_back("number" ); |
| 21 | |
| 22 | Block sample; |
| 23 | ColumnWithTypeAndName col; |
| 24 | col.type = std::make_shared<DataTypeUInt64>(); |
| 25 | sample.insert(std::move(col)); |
| 26 | |
| 27 | WriteBufferFromOStream out_buf(std::cout); |
| 28 | |
| 29 | auto context = Context::createGlobal(); |
| 30 | context.makeGlobalContext(); |
| 31 | QueryProcessingStage::Enum stage = table->getQueryProcessingStage(context); |
| 32 | |
| 33 | LimitBlockInputStream input(table->read(column_names, {}, context, stage, 10, 1)[0], 10, 96); |
| 34 | BlockOutputStreamPtr out = FormatFactory::instance().getOutput("TabSeparated" , out_buf, sample, context); |
| 35 | |
| 36 | copyData(input, *out); |
| 37 | |
| 38 | return 0; |
| 39 | } |
| 40 | catch (const DB::Exception & e) |
| 41 | { |
| 42 | std::cerr << e.what() << ", " << e.displayText() << std::endl; |
| 43 | return 1; |
| 44 | } |
| 45 | |