|
23 | 23 | #include <cstddef> |
24 | 24 | #include <cstdint> |
25 | 25 | #include <format> |
| 26 | +#include <map> |
26 | 27 | #include <memory> |
27 | 28 | #include <ranges> |
28 | 29 | #include <unordered_map> |
@@ -265,19 +266,21 @@ bool PartitionSpec::HasSequentialFieldIds(const PartitionSpec& spec) { |
265 | 266 |
|
266 | 267 | Status PartitionSpec::ValidateRedundantPartitions(const PartitionSpec& spec) { |
267 | 268 | // Use a map to track deduplication keys (source_id + transform dedup name) |
268 | | - std::unordered_map<std::pair<int32_t, std::string>, const PartitionField*> dedup_fields; |
| 269 | + std::map<std::pair<int32_t, std::string>, const PartitionField*> dedup_fields; |
269 | 270 |
|
270 | 271 | for (const auto& field : spec.fields()) { |
271 | | - // Create dedup key: (source_id, transform_dedup_name) |
| 272 | + // The dedup name is provided by the transform's DedupName() method |
| 273 | + // which typically returns the transform's string representation |
272 | 274 | auto dedup_key = std::make_pair(field.source_id(), field.transform()->DedupName()); |
273 | 275 |
|
274 | 276 | // Check if this dedup key already exists |
| 277 | + // If it does, we have found a redundant partition field |
275 | 278 | auto existing_field_iter = dedup_fields.find(dedup_key); |
276 | 279 | ICEBERG_PRECHECK(existing_field_iter == dedup_fields.end(), |
277 | 280 | "Cannot add redundant partition: {} conflicts with {}", |
278 | 281 | field.ToString(), existing_field_iter->second->ToString()); |
279 | 282 |
|
280 | | - // Add this field to the dedup map |
| 283 | + // Add this field to the dedup map for future conflict detection |
281 | 284 | dedup_fields[dedup_key] = &field; |
282 | 285 | } |
283 | 286 |
|
|
0 commit comments