Uh oh!
There was an error while loading. Please reload this page.
core: add JSON parser for ContentFile and FileScanTask - #6934
Conversation
| /** | ||
| * Return the schema for this file scan task. | ||
| */ | ||
| default Schema schema() { |
There was a problem hiding this comment.
this is needed so that FileScanTaskParser (added in this PR) can serialize the schema. Then during the deserialization part, schema can be pass into the constructor of BaseFileScanTask.
Keep it at this level (not base ContentScanTask interface or lower) to limit the scope of change.
| return file; | ||
| } | ||
| protected Schema schema() { |
There was a problem hiding this comment.
exposed as protected so that BaseFileScanTask can use it to implement the FileScanTask#schema() method
There was a problem hiding this comment.
Little odd that we reverse engineer the schema from the string here, but seems like the most backwards compatible thing we can do here.
There was a problem hiding this comment.
agree it is a little odd. On the other hand, partition spec is in the same model in this class. As you said, otherwise we would have to change the constructors of a bunch of classes. The current choice of passing schema and spec as strings is to make those scan tasks serializable.
@Override
public PartitionSpec spec() {
if (spec == null) {
synchronized (this) {
if (spec == null) {
this.spec = PartitionSpecParser.fromJson(schema(), specString);
}
}
}
return spec;
}
cc @nastra
| import org.apache.iceberg.util.ArrayUtil; | ||
| import org.apache.iceberg.util.JsonUtil; | ||
| class ContentFileParser { |
There was a problem hiding this comment.
since DataFile and DeleteFile has the same structure, calling this ContentFileParser without any generic type.
| private ByteBuffer keyMetadata = null; | ||
| private List<Long> splitOffsets = null; | ||
| private List<Integer> equalityFieldIds = null; | ||
| private Integer sortOrderId = SortOrder.unsorted().orderId(); |
There was a problem hiding this comment.
relocated the line here to follow the same order of definition
| private Map<Integer, ByteBuffer> upperBounds = null; | ||
| private ByteBuffer keyMetadata = null; | ||
| private List<Long> splitOffsets = null; | ||
| private List<Integer> equalityFieldIds = null; |
There was a problem hiding this comment.
add a setter for equalityFieldIds so that the parser unit test can cover this field too.
| private final PartitionSpec spec; | ||
| ContentFileParser(PartitionSpec spec) { |
There was a problem hiding this comment.
Unlike other JSON parser with a static singleton pattern, ContentFileParser depends on the partition spec. Hence this is a regular class and constructor.
Uh oh!
There was an error while loading. Please reload this page.
af84243 to
f271871Compare
nastra
left a comment
There was a problem hiding this comment.
did a high-level pass over the parsers themselves and left a few comments. I haven't had a chance to look closer at the tests yet
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
a8062a7 to
4d57100CompareUh oh!
There was an error while loading. Please reload this page.
78fec72 to
92a162fCompare
nastra
left a comment
There was a problem hiding this comment.
sorry for the late re-review @stevenzwu, I've left a few more comments.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
nastra
left a comment
There was a problem hiding this comment.
I've been mainly focusing on the JSON parsers and left a few comments, but overall this looks almost ready. It would be great to get some additional input from another reviewer
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| import org.junit.jupiter.params.provider.Arguments; | ||
| import org.junit.jupiter.params.provider.MethodSource; | ||
| public class TestContentFileParser { |
There was a problem hiding this comment.
I think it would be good to also add a test with a plain JSON string to see how the full JSON looks like. And then maybe also another test with a plain JSON string where all optional fields (metrics, equality field ids, sort order id, split offsets, ...) are missing
4242a0b to
00bf6c0Compare| JsonNode pNode = node.get(property); | ||
| Preconditions.checkArgument( | ||
| pNode.isTextual(), "Cannot parse from non-text value: %s: %s", property, pNode); |
There was a problem hiding this comment.
nit: maybe we should mention that we're trying to parse this from text to a binary representation
There was a problem hiding this comment.
I also fixed a couple other error msgs with the same problem.
stevenzwu
commented
May 4, 2023
Spark CI build failed with some seemingly env problem |
61e40a7 to
0016f36Comparea465d34 to
8105811Comparestevenzwu
commented
Jun 26, 2023
merging after rebase |
@stevenzwu we are seeing Trino OOM issue during scan planning and it might be because we introduce table schema to each file scan task in this PR. The issue happens in conjunction with very wide table schema and ParallelIterable usage. I wonder your thought on this? One possible way is to store schema id instead of actual schema to save memory usage. LMK if this is the right place to discuss or we can move somewhere else. |
stevenzwu
commented
Aug 22, 2025
@puchengy please create a new issue to track and discuss this problem. Agree with the overhead of serializing the schema for scan task. If we were to just serialize schema id, the serializer would need to get hold of the schemas. It would require major refactoring of the call stack to allow pass-in. At that time, we opted into the simpler approach. But we can discuss the alternative. Does Trino use the JSON parser for file scan task? |
this closes issue #1698.
There are two motivations as described by issue #1698.