| 32 | } |
| 33 | |
| 34 | StorageFileCluster::StorageFileCluster( |
| 35 | const ContextPtr & context, |
| 36 | const String & cluster_name_, |
| 37 | const String & filename_, |
| 38 | const String & format_name_, |
| 39 | const String & compression_method, |
| 40 | const StorageID & table_id_, |
| 41 | const ColumnsDescription & columns_, |
| 42 | const ConstraintsDescription & constraints_) |
| 43 | : IStorageCluster(cluster_name_, table_id_, getLogger("StorageFileCluster (" + table_id_.getFullTableName() + ")")) |
| 44 | , filename(filename_) |
| 45 | , format_name(format_name_) |
| 46 | { |
| 47 | StorageInMemoryMetadata storage_metadata; |
| 48 | |
| 49 | /// The archive syntax (e.g. "archive*.zip::file.parquet") is not supported by function fileCluster() yet. |
| 50 | paths = StorageFile::FileSource::parse(filename_, context, /* allow_archive_path_syntax = */ false).paths; |
| 51 | |
| 52 | if (columns_.empty()) |
| 53 | { |
| 54 | ColumnsDescription columns; |
| 55 | if (format_name == "auto") |
| 56 | std::tie(columns, format_name) = StorageFile::getTableStructureAndFormatFromFile(paths, compression_method, std::nullopt, context); |
| 57 | else |
| 58 | columns = StorageFile::getTableStructureFromFile(format_name, paths, compression_method, std::nullopt, context); |
| 59 | |
| 60 | storage_metadata.setColumns(columns); |
| 61 | } |
| 62 | else |
| 63 | { |
| 64 | if (format_name == "auto") |
| 65 | format_name = StorageFile::getTableStructureAndFormatFromFile(paths, compression_method, std::nullopt, context).second; |
| 66 | storage_metadata.setColumns(columns_); |
| 67 | } |
| 68 | |
| 69 | auto & storage_columns = storage_metadata.columns; |
| 70 | |
| 71 | /// Not grabbing the file_columns because it is not necessary to do it here. |
| 72 | std::tie(hive_partition_columns_to_read_from_file_path, std::ignore) = HivePartitioningUtils::setupHivePartitioningForFileURLLikeStorage( |
| 73 | storage_columns, |
| 74 | paths.empty() ? "" : paths.front(), |
| 75 | columns_.empty(), |
| 76 | std::nullopt, |
| 77 | context); |
| 78 | |
| 79 | storage_metadata.setConstraints(constraints_); |
| 80 | storage_metadata.setVirtuals(VirtualColumnUtils::getVirtualsForFileLikeStorage(storage_metadata.columns, context)); |
| 81 | setInMemoryMetadata(storage_metadata); |
| 82 | } |
| 83 | |
| 84 | void StorageFileCluster::updateQueryToSendIfNeeded(DB::ASTPtr & query, const StorageSnapshotPtr & storage_snapshot, const DB::ContextPtr & context) |
| 85 | { |
nothing calls this directly
no test coverage detected