|
22 | 22 | import java.util.Arrays; |
23 | 23 | import java.util.List; |
24 | 24 | import java.util.Map; |
| 25 | +import java.util.Iterator; |
| 26 | + |
25 | 27 | import java.util.concurrent.ConcurrentHashMap; |
26 | 28 | import java.util.concurrent.TimeUnit; |
27 | 29 |
|
|
64 | 66 | import com.fasterxml.jackson.core.JsonProcessingException; |
65 | 67 | import com.fasterxml.jackson.databind.DeserializationContext; |
66 | 68 | import com.fasterxml.jackson.databind.DeserializationFeature; |
| 69 | +import com.fasterxml.jackson.databind.JsonNode; |
67 | 70 | import com.fasterxml.jackson.databind.JsonDeserializer; |
68 | 71 | import com.fasterxml.jackson.databind.JsonSerializer; |
69 | 72 | import com.fasterxml.jackson.databind.KeyDeserializer; |
70 | 73 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 74 | +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; |
71 | 75 | import com.fasterxml.jackson.databind.SerializerProvider; |
72 | 76 | import com.fasterxml.jackson.databind.module.SimpleModule; |
73 | 77 | import com.fasterxml.jackson.module.afterburner.AfterburnerModule; |
@@ -437,6 +441,11 @@ private ParquetFileMetadata_v3 getParquetFileMetadata_v3(ParquetTableMetadata_v3 |
437 | 441 | length += col.getTotalSize(); |
438 | 442 | } |
439 | 443 |
|
| 444 | + // DRILL-5009: Skip the RowGroup if it is empty |
| 445 | + // Note we still read the schema even if there are no values in the RowGroup |
| 446 | + if (rowGroup.getRowCount() == 0) { |
| 447 | + continue; |
| 448 | + } |
440 | 449 | RowGroupMetadata_v3 rowGroupMeta = |
441 | 450 | new RowGroupMetadata_v3(rowGroup.getStartingPos(), length, rowGroup.getRowCount(), |
442 | 451 | getHostAffinity(file, rowGroup.getStartingPos(), length), columnMetadataList); |
@@ -566,6 +575,19 @@ private void readBlockMeta(String path, |
566 | 575 | (createMetaFilesRecursively(Path.getPathWithoutSchemeAndAuthority(p.getParent()).toString())).getLeft(); |
567 | 576 | newMetadata = true; |
568 | 577 | } |
| 578 | + |
| 579 | + // DRILL-5009: Remove the RowGroup if it is empty |
| 580 | + List<? extends ParquetFileMetadata> files = parquetTableMetadata.getFiles(); |
| 581 | + for (ParquetFileMetadata file : files) { |
| 582 | + List<? extends RowGroupMetadata> rowGroups = file.getRowGroups(); |
| 583 | + for (Iterator<? extends RowGroupMetadata> iter = rowGroups.iterator(); iter.hasNext(); ) { |
| 584 | + RowGroupMetadata r = iter.next(); |
| 585 | + if (r.getRowCount() == 0) { |
| 586 | + iter.remove(); |
| 587 | + } |
| 588 | + } |
| 589 | + } |
| 590 | + |
569 | 591 | } |
570 | 592 |
|
571 | 593 | if (newMetadata && metaContext != null) { |
|
0 commit comments