MCPcopy Create free account
hub / github.com/apache/impala / AdjustFieldIdForMigratedPartitionedTables

Method AdjustFieldIdForMigratedPartitionedTables

be/src/exec/file-metadata-utils.cc:306–355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

304}
305
306Status FileMetadataUtils::AdjustFieldIdForMigratedPartitionedTables(int *fieldID) const {
307 DCHECK(file_desc_ != nullptr);
308 DCHECK(scan_node_->hdfs_table()->IsIcebergTable());
309 DCHECK(fieldID != nullptr);
310
311 using namespace org::apache::impala::fb;
312
313 auto transforms = IcebergPartitionTransforms();
314 if (transforms == nullptr || transforms->size() == 0) return Status::OK();
315
316 vector<int> sourceIDs;
317 sourceIDs.reserve(transforms->size());
318 for (auto transform : *transforms) {
319 if (transform->transform_type() !=
320 FbIcebergTransformType::FbIcebergTransformType_IDENTITY) {
321 return Status(Substitute("$0 has invalid partition transform: $1",
322 file_desc_->filename, transform->transform_type()));
323 }
324 sourceIDs.push_back(transform->source_id());
325 }
326
327 DCHECK_EQ(sourceIDs.size(), transforms->size());
328 sort(sourceIDs.begin(), sourceIDs.end());
329
330 string errorMsg = Substitute(
331 "Migrated file $0 has unexpected schema or partitioning.", file_desc_->filename);
332
333 // Field IDs must be consecutive.
334 for (int i = 0; i < sourceIDs.size() - 1; ++i) {
335 if (sourceIDs[i+1] - sourceIDs[i] != 1) {
336 return Status(errorMsg);
337 }
338 }
339
340 int fileFieldID = *fieldID;
341
342 if (sourceIDs.front() == fileFieldID) {
343 // Partition columns are not stored in the data file (as expected).
344 // In this case we need to adjust fieldID (as it was calculated based on
345 // the file schema only).
346 *fieldID += sourceIDs.size();
347 } else if (sourceIDs.back() == fileFieldID - 1) {
348 // Partition columns are stored in the data file, no need to adjust fieldID.
349 } else {
350 // Some partitions are stored, some aren't let's raise an error for this mess.
351 return Status(errorMsg);
352 }
353
354 return Status::OK();
355}
356
357bool FileMetadataUtils::NeedDataInFile(const SlotDescriptor* slot_desc) {
358 if (IsValuePartitionCol(slot_desc)) return false;

Callers 2

GenerateFieldIDsMethod · 0.80
GenerateFieldIDsMethod · 0.80

Calls 12

OKFunction · 0.85
SubstituteFunction · 0.85
sortFunction · 0.85
IsIcebergTableMethod · 0.80
hdfs_tableMethod · 0.80
reserveMethod · 0.80
push_backMethod · 0.80
frontMethod · 0.80
StatusClass · 0.70
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected