| 154 | } |
| 155 | |
| 156 | void StorageExecutable::readImpl( |
| 157 | QueryPlan & query_plan, |
| 158 | const Names & column_names, |
| 159 | const StorageSnapshotPtr & storage_snapshot, |
| 160 | SelectQueryInfo & query_info, |
| 161 | ContextPtr context, |
| 162 | QueryProcessingStage::Enum /*processed_stage*/, |
| 163 | size_t max_block_size, |
| 164 | size_t /*threads*/) |
| 165 | { |
| 166 | auto & script_name = settings->script_name; |
| 167 | |
| 168 | auto user_scripts_path = context->getUserScriptsPath(); |
| 169 | auto script_path = user_scripts_path + '/' + script_name; |
| 170 | |
| 171 | if (!fileOrSymlinkPathStartsWith(script_path, user_scripts_path)) |
| 172 | throw Exception(ErrorCodes::UNSUPPORTED_METHOD, |
| 173 | "Executable file {} must be inside user scripts folder {}", |
| 174 | script_name, |
| 175 | user_scripts_path); |
| 176 | |
| 177 | if (!FS::exists(script_path)) |
| 178 | throw Exception(ErrorCodes::UNSUPPORTED_METHOD, |
| 179 | "Executable file {} does not exist inside user scripts folder {}", |
| 180 | script_name, |
| 181 | user_scripts_path); |
| 182 | |
| 183 | if (!FS::canExecute(script_path)) |
| 184 | throw Exception(ErrorCodes::UNSUPPORTED_METHOD, |
| 185 | "Executable file {} is not executable inside user scripts folder {}", |
| 186 | script_name, |
| 187 | user_scripts_path); |
| 188 | |
| 189 | Pipes inputs; |
| 190 | QueryPlanResourceHolder resources; |
| 191 | inputs.reserve(input_queries.size()); |
| 192 | |
| 193 | for (auto & input_query : input_queries) |
| 194 | { |
| 195 | QueryPipelineBuilder builder; |
| 196 | if (context->getSettingsRef()[Setting::allow_experimental_analyzer]) |
| 197 | builder = InterpreterSelectQueryAnalyzer(input_query, context, {}).buildQueryPipeline(); |
| 198 | else |
| 199 | builder = InterpreterSelectWithUnionQuery(input_query, context, {}).buildQueryPipeline(); |
| 200 | inputs.emplace_back(QueryPipelineBuilder::getPipe(std::move(builder), resources)); |
| 201 | } |
| 202 | |
| 203 | /// For executable pool we read data from input streams and convert it to single blocks streams. |
| 204 | if (settings->is_executable_pool) |
| 205 | transformToSingleBlockSources(inputs); |
| 206 | |
| 207 | auto sample_block = storage_snapshot->metadata->getSampleBlock(); |
| 208 | |
| 209 | ShellCommandSourceConfiguration configuration; |
| 210 | configuration.max_block_size = max_block_size; |
| 211 | |
| 212 | if (settings->is_executable_pool) |
| 213 | { |
nothing calls this directly
no test coverage detected