| 1082 | } |
| 1083 | |
| 1084 | void Call::initializePipeline(const Block & header) |
| 1085 | { |
| 1086 | chassert(!read_buffer); |
| 1087 | read_buffer = std::make_unique<ReadBufferFromCallback>([this]() -> std::pair<const void *, size_t> |
| 1088 | { |
| 1089 | if (need_input_data_from_insert_query) |
| 1090 | { |
| 1091 | need_input_data_from_insert_query = false; |
| 1092 | if (insert_query && insert_query->data && (insert_query->data != insert_query->end)) |
| 1093 | { |
| 1094 | need_input_data_delimiter = !input_data_delimiter.empty(); |
| 1095 | return {insert_query->data, insert_query->end - insert_query->data}; |
| 1096 | } |
| 1097 | } |
| 1098 | |
| 1099 | while (true) |
| 1100 | { |
| 1101 | if (need_input_data_from_query_info) |
| 1102 | { |
| 1103 | if (need_input_data_delimiter && !query_info.input_data().empty()) |
| 1104 | { |
| 1105 | need_input_data_delimiter = false; |
| 1106 | return {input_data_delimiter.data(), input_data_delimiter.size()}; |
| 1107 | } |
| 1108 | need_input_data_from_query_info = false; |
| 1109 | if (!query_info.input_data().empty()) |
| 1110 | { |
| 1111 | need_input_data_delimiter = !input_data_delimiter.empty(); |
| 1112 | return {query_info.input_data().data(), query_info.input_data().size()}; |
| 1113 | } |
| 1114 | } |
| 1115 | |
| 1116 | if (!query_info.next_query_info()) |
| 1117 | break; |
| 1118 | |
| 1119 | if (!isInputStreaming(call_type)) |
| 1120 | throw Exception(ErrorCodes::INVALID_GRPC_QUERY_INFO, "next_query_info is allowed to be set only for streaming input"); |
| 1121 | |
| 1122 | readQueryInfo(); |
| 1123 | if (!query_info.query().empty() || !query_info.query_id().empty() || !query_info.settings().empty() |
| 1124 | || !query_info.database().empty() || !query_info.input_data_delimiter().empty() || !query_info.output_format().empty() |
| 1125 | || query_info.external_tables_size() || !query_info.user_name().empty() || !query_info.password().empty() |
| 1126 | || !query_info.quota().empty() || !query_info.session_id().empty()) |
| 1127 | { |
| 1128 | throw Exception(ErrorCodes::INVALID_GRPC_QUERY_INFO, |
| 1129 | "Extra query infos can be used only to add more input data. " |
| 1130 | "Only the following fields can be set: input_data, next_query_info, cancel"); |
| 1131 | } |
| 1132 | |
| 1133 | if (isQueryCancelled()) |
| 1134 | break; |
| 1135 | |
| 1136 | LOG_DEBUG(log, "Received extra QueryInfo: input_data: {} bytes", query_info.input_data().size()); |
| 1137 | need_input_data_from_query_info = true; |
| 1138 | } |
| 1139 | |
| 1140 | return {nullptr, 0}; /// no more input data |
| 1141 | }); |
nothing calls this directly
no test coverage detected