| 141 | } |
| 142 | |
| 143 | IStorageURLBase::IStorageURLBase( |
| 144 | const String & uri_, |
| 145 | const ContextPtr & context_, |
| 146 | const StorageID & table_id_, |
| 147 | const String & format_name_, |
| 148 | const std::optional<FormatSettings> & format_settings_, |
| 149 | const ColumnsDescription & columns_, |
| 150 | const ConstraintsDescription & constraints_, |
| 151 | const String & comment, |
| 152 | const String & compression_method_, |
| 153 | const HTTPHeaderEntries & headers_, |
| 154 | const String & http_method_, |
| 155 | ASTPtr partition_by_, |
| 156 | bool distributed_processing_) |
| 157 | : IStorage(table_id_) |
| 158 | , uri(uri_) |
| 159 | , compression_method(chooseCompressionMethod(Poco::URI(uri_).getPath(), compression_method_)) |
| 160 | , format_name(format_name_) |
| 161 | , format_settings(format_settings_) |
| 162 | , headers(headers_) |
| 163 | , http_method(http_method_) |
| 164 | , partition_by(partition_by_) |
| 165 | , distributed_processing(distributed_processing_) |
| 166 | { |
| 167 | if (format_name != "auto") |
| 168 | FormatFactory::instance().checkFormatName(format_name); |
| 169 | |
| 170 | StorageInMemoryMetadata storage_metadata; |
| 171 | |
| 172 | if (columns_.empty()) |
| 173 | { |
| 174 | ColumnsDescription columns; |
| 175 | if (format_name == "auto") |
| 176 | std::tie(columns, format_name) = getTableStructureAndFormatFromData(uri, compression_method, headers, format_settings, context_); |
| 177 | else |
| 178 | columns = getTableStructureFromData(format_name, uri, compression_method, headers, format_settings, context_); |
| 179 | |
| 180 | storage_metadata.setColumns(columns); |
| 181 | } |
| 182 | else |
| 183 | { |
| 184 | if (format_name == "auto") |
| 185 | format_name = getTableStructureAndFormatFromData(uri, compression_method, headers, format_settings, context_).second; |
| 186 | |
| 187 | /// We don't allow special columns in URL storage. |
| 188 | if (!columns_.hasOnlyOrdinary()) |
| 189 | throw Exception(ErrorCodes::BAD_ARGUMENTS, "Table engine URL doesn't support special columns like MATERIALIZED, ALIAS or EPHEMERAL"); |
| 190 | storage_metadata.setColumns(columns_); |
| 191 | } |
| 192 | |
| 193 | supports_prewhere = FormatFactory::instance().checkIfFormatSupportsPrewhere(format_name, context_, format_settings); |
| 194 | |
| 195 | storage_metadata.setConstraints(constraints_); |
| 196 | storage_metadata.setComment(comment); |
| 197 | |
| 198 | auto & storage_columns = storage_metadata.columns; |
| 199 | |
| 200 | const auto sample_path = getSampleURI(uri, context_); |
nothing calls this directly
no test coverage detected