| 225 | |
| 226 | template <typename Definition, typename Configuration, bool is_data_lake> |
| 227 | StoragePtr TableFunctionObjectStorage<Definition, Configuration, is_data_lake>::executeImpl( |
| 228 | const ASTPtr & /* ast_function */, |
| 229 | ContextPtr context, |
| 230 | const std::string & table_name, |
| 231 | ColumnsDescription cached_columns, |
| 232 | bool is_insert_query) const |
| 233 | { |
| 234 | chassert(configuration); |
| 235 | ColumnsDescription columns; |
| 236 | |
| 237 | if (configuration->structure != "auto") |
| 238 | columns = parseColumnsListFromString(configuration->structure, context); |
| 239 | else if (!structure_hint.empty()) |
| 240 | columns = structure_hint; |
| 241 | else if (!cached_columns.empty()) |
| 242 | columns = cached_columns; |
| 243 | |
| 244 | StoragePtr storage; |
| 245 | const auto & query_settings = context->getSettingsRef(); |
| 246 | |
| 247 | const auto parallel_replicas_cluster_name = query_settings[Setting::cluster_for_parallel_replicas].toString(); |
| 248 | /// Only use parallel replicas if the Cluster variant of this table function exists |
| 249 | /// (e.g. `s3Cluster` for `s3`). Table functions without a Cluster variant (e.g. `paimonLocal`) |
| 250 | /// cannot distribute work via task iterators, so distributing would just read all data on every replica. |
| 251 | const auto can_use_parallel_replicas = !parallel_replicas_cluster_name.empty() |
| 252 | && query_settings[Setting::parallel_replicas_for_cluster_engines] |
| 253 | && context->canUseTaskBasedParallelReplicas() |
| 254 | && !context->isDistributed() |
| 255 | && TableFunctionFactory::instance().isTableFunctionName(String(name) + "Cluster"); |
| 256 | |
| 257 | const auto is_secondary_query = context->getClientInfo().query_kind == ClientInfo::QueryKind::SECONDARY_QUERY; |
| 258 | |
| 259 | if (can_use_parallel_replicas && !is_secondary_query && !is_insert_query) |
| 260 | { |
| 261 | storage = std::make_shared<StorageObjectStorageCluster>( |
| 262 | parallel_replicas_cluster_name, |
| 263 | configuration, |
| 264 | getObjectStorage(context, !is_insert_query), |
| 265 | StorageID(getDatabaseName(), table_name), |
| 266 | columns, |
| 267 | ConstraintsDescription{}, |
| 268 | partition_by, |
| 269 | context, |
| 270 | /* is_table_function */true); |
| 271 | |
| 272 | storage->startup(); |
| 273 | return storage; |
| 274 | } |
| 275 | |
| 276 | std::string disk_name; |
| 277 | if constexpr (is_data_lake) |
| 278 | { |
| 279 | disk_name = settings && (*settings)[DataLakeStorageSetting::disk].changed |
| 280 | ? (*settings)[DataLakeStorageSetting::disk].value |
| 281 | : ""; |
| 282 | } |
| 283 | |
| 284 | ObjectStoragePtr current_object_storage; |
nothing calls this directly
no test coverage detected