| 1 | #include "iostream_debug_helpers.h" |
| 2 | |
| 3 | #include <iostream> |
| 4 | #include <Client/Connection.h> |
| 5 | #include <Core/Block.h> |
| 6 | #include <Core/ColumnWithTypeAndName.h> |
| 7 | #include <Core/Field.h> |
| 8 | #include <Core/NamesAndTypes.h> |
| 9 | #include <DataStreams/IBlockInputStream.h> |
| 10 | #include <DataTypes/IDataType.h> |
| 11 | #include <Functions/IFunction.h> |
| 12 | #include <IO/WriteBufferFromOStream.h> |
| 13 | #include <Interpreters/ExpressionAnalyzer.h> |
| 14 | #include <Interpreters/ExpressionActions.h> |
| 15 | #include <Parsers/IAST.h> |
| 16 | #include <Storages/IStorage.h> |
| 17 | #include <Common/COW.h> |
| 18 | #include <Common/FieldVisitors.h> |
| 19 | |
| 20 | namespace DB |
| 21 | { |
| 22 | |
| 23 | template <> |
| 24 | std::ostream & operator<< <Field>(std::ostream & stream, const Field & what) |
| 25 | { |
| 26 | stream << applyVisitor(FieldVisitorDump(), what); |
| 27 | return stream; |
| 28 | } |
| 29 | |
| 30 | std::ostream & operator<<(std::ostream & stream, const IBlockInputStream & what) |
| 31 | { |
| 32 | stream << "IBlockInputStream(name = " << what.getName() << ")" ; |
| 33 | return stream; |
| 34 | } |
| 35 | |
| 36 | std::ostream & operator<<(std::ostream & stream, const NameAndTypePair & what) |
| 37 | { |
| 38 | stream << "NameAndTypePair(name = " << what.name << ", type = " << what.type << ")" ; |
| 39 | return stream; |
| 40 | } |
| 41 | |
| 42 | std::ostream & operator<<(std::ostream & stream, const IDataType & what) |
| 43 | { |
| 44 | stream << "IDataType(name = " << what.getName() << ", default = " << what.getDefault() << ")" ; |
| 45 | return stream; |
| 46 | } |
| 47 | |
| 48 | std::ostream & operator<<(std::ostream & stream, const IStorage & what) |
| 49 | { |
| 50 | stream << "IStorage(name = " << what.getName() << ", tableName = " << what.getTableName() << ") {" |
| 51 | << what.getColumns().getAllPhysical().toString() << "}" ; |
| 52 | return stream; |
| 53 | } |
| 54 | |
| 55 | std::ostream & operator<<(std::ostream & stream, const TableStructureReadLock &) |
| 56 | { |
| 57 | stream << "TableStructureReadLock()" ; |
| 58 | return stream; |
| 59 | } |
| 60 | |
| 61 | std::ostream & operator<<(std::ostream & stream, const IFunctionOverloadResolver & what) |
| 62 | { |
| 63 | stream << "IFunction(name = " << what.getName() << ", variadic = " << what.isVariadic() << ", args = " << what.getNumberOfArguments() |
| 64 | << ")" ; |
| 65 | return stream; |
| 66 | } |
| 67 | |
| 68 | std::ostream & operator<<(std::ostream & stream, const Block & what) |
| 69 | { |
| 70 | stream << "Block(" |
| 71 | << "num_columns = " << what.columns() << "){" << what.dumpStructure() << "}" ; |
| 72 | return stream; |
| 73 | } |
| 74 | |
| 75 | std::ostream & operator<<(std::ostream & stream, const ColumnWithTypeAndName & what) |
| 76 | { |
| 77 | stream << "ColumnWithTypeAndName(name = " << what.name << ", type = " << *what.type << ", column = " ; |
| 78 | return dumpValue(stream, what.column) << ")" ; |
| 79 | } |
| 80 | |
| 81 | std::ostream & operator<<(std::ostream & stream, const IColumn & what) |
| 82 | { |
| 83 | stream << "IColumn(" << what.dumpStructure() << ")" ; |
| 84 | stream << "{" ; |
| 85 | for (size_t i = 0; i < what.size(); ++i) |
| 86 | { |
| 87 | if (i) |
| 88 | stream << ", " ; |
| 89 | stream << applyVisitor(FieldVisitorDump(), what[i]); |
| 90 | } |
| 91 | stream << "}" ; |
| 92 | |
| 93 | return stream; |
| 94 | } |
| 95 | |
| 96 | std::ostream & operator<<(std::ostream & stream, const Packet & what) |
| 97 | { |
| 98 | stream << "Packet(" |
| 99 | << "type = " << what.type; |
| 100 | // types description: Core/Protocol.h |
| 101 | if (what.exception) |
| 102 | stream << "exception = " << what.exception.get(); |
| 103 | // TODO: profile_info |
| 104 | stream << ") {" << what.block << "}" ; |
| 105 | return stream; |
| 106 | } |
| 107 | |
| 108 | std::ostream & operator<<(std::ostream & stream, const ExpressionAction & what) |
| 109 | { |
| 110 | stream << "ExpressionAction(" << what.toString() << ")" ; |
| 111 | return stream; |
| 112 | } |
| 113 | |
| 114 | std::ostream & operator<<(std::ostream & stream, const ExpressionActions & what) |
| 115 | { |
| 116 | stream << "ExpressionActions(" << what.dumpActions() << ")" ; |
| 117 | return stream; |
| 118 | } |
| 119 | |
| 120 | std::ostream & operator<<(std::ostream & stream, const SyntaxAnalyzerResult & what) |
| 121 | { |
| 122 | stream << "SyntaxAnalyzerResult{" ; |
| 123 | stream << "storage=" << what.storage << "; " ; |
| 124 | if (!what.source_columns.empty()) |
| 125 | { |
| 126 | stream << "source_columns=" ; |
| 127 | dumpValue(stream, what.source_columns); |
| 128 | stream << "; " ; |
| 129 | } |
| 130 | if (!what.aliases.empty()) |
| 131 | { |
| 132 | stream << "aliases=" ; |
| 133 | dumpValue(stream, what.aliases); |
| 134 | stream << "; " ; |
| 135 | } |
| 136 | if (!what.array_join_result_to_source.empty()) |
| 137 | { |
| 138 | stream << "array_join_result_to_source=" ; |
| 139 | dumpValue(stream, what.array_join_result_to_source); |
| 140 | stream << "; " ; |
| 141 | } |
| 142 | if (!what.array_join_alias_to_name.empty()) |
| 143 | { |
| 144 | stream << "array_join_alias_to_name=" ; |
| 145 | dumpValue(stream, what.array_join_alias_to_name); |
| 146 | stream << "; " ; |
| 147 | } |
| 148 | if (!what.array_join_name_to_alias.empty()) |
| 149 | { |
| 150 | stream << "array_join_name_to_alias=" ; |
| 151 | dumpValue(stream, what.array_join_name_to_alias); |
| 152 | stream << "; " ; |
| 153 | } |
| 154 | stream << "rewrite_subqueries=" << what.rewrite_subqueries << "; " ; |
| 155 | stream << "}" ; |
| 156 | |
| 157 | return stream; |
| 158 | } |
| 159 | |
| 160 | } |
| 161 | |