| 238 | } |
| 239 | |
| 240 | VirtualColumnsDescription getVirtualsForFileLikeStorage( |
| 241 | ColumnsDescription & storage_columns, |
| 242 | ContextPtr context, |
| 243 | const std::optional<FormatSettings> & format_settings, |
| 244 | std::optional<PartitionStrategyFactory::StrategyType> partition_strategy, |
| 245 | const std::string & path) |
| 246 | { |
| 247 | VirtualColumnsDescription desc; |
| 248 | |
| 249 | auto add_virtual = [&](const NameAndTypePair & pair) |
| 250 | { |
| 251 | const auto & name = pair.getNameInStorage(); |
| 252 | if (storage_columns.has(name)) |
| 253 | return; |
| 254 | |
| 255 | const auto & type = pair.getTypeInStorage(); |
| 256 | desc.addEphemeral(name, type, "", VirtualsMaterializationPlace::Reader); |
| 257 | }; |
| 258 | |
| 259 | for (const auto & item : getCommonVirtualsForFileLikeStorage()) |
| 260 | add_virtual(item); |
| 261 | |
| 262 | if (!path.empty()) |
| 263 | { |
| 264 | if (!partition_strategy.has_value()) |
| 265 | throw Exception(ErrorCodes::LOGICAL_ERROR, "Expected partition strategy to be specified"); |
| 266 | |
| 267 | /// If partition_stategy == none, we add hive columns, if present, to virtual columns. |
| 268 | if (context->getSettingsRef()[Setting::use_hive_partitioning] |
| 269 | && partition_strategy == PartitionStrategyFactory::StrategyType::NONE) |
| 270 | { |
| 271 | auto hive_columns = HivePartitioningUtils::extractHivePartitionColumnsFromPath(storage_columns, path, format_settings, context); |
| 272 | for (const auto & column : hive_columns) |
| 273 | add_virtual(column); |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | return desc; |
| 278 | } |
| 279 | |
| 280 | /// Appends one row to the already-detached mutable columns of `block`. The columns are detached once |
| 281 | /// by the caller (see `getFilterByPathAndFileIndexes`) so this per-row helper does not pay any |
no test coverage detected