-
Notifications
You must be signed in to change notification settings - Fork 46
Column projection of union type #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,18 @@ public ProjectionDatumReader(Function<Schema, DatumReader<?>> getReader, | |
| this.nameMapping = nameMapping; | ||
| } | ||
|
|
||
| public ProjectionDatumReader(Function<Schema, DatumReader<?>> getReader, | ||
| org.apache.iceberg.Schema expectedSchema, | ||
| Map<String, String> renames, | ||
| NameMapping nameMapping, | ||
| Schema fileSchema) { | ||
| this.getReader = getReader; | ||
| this.expectedSchema = expectedSchema; | ||
| this.renames = renames; | ||
| this.nameMapping = nameMapping; | ||
| this.fileSchema = fileSchema; | ||
| } | ||
|
|
||
| @Override | ||
| public void setRowPositionSupplier(Supplier<Long> posSupplier) { | ||
| if (wrapped instanceof SupportsRowPosition) { | ||
|
|
@@ -59,7 +71,9 @@ public void setRowPositionSupplier(Supplier<Long> posSupplier) { | |
|
|
||
| @Override | ||
| public void setSchema(Schema newFileSchema) { | ||
| this.fileSchema = newFileSchema; | ||
| if (this.fileSchema == null) { | ||
| this.fileSchema = newFileSchema; | ||
| } | ||
|
Comment on lines
73
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems we are ignoring
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pls refer to the comment above. |
||
| if (nameMapping == null && !AvroSchemaUtil.hasIds(fileSchema)) { | ||
| nameMapping = MappingUtil.create(expectedSchema); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only called in the tests. I am not sure how it is called in the non-test path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this code together with the code change in
ProjectionDatumReader.setSchemaare added only for test the case thatfileSchemato read Avro file is different from the actual schema to write the Avro file. This test case proves that the data cannot be returned by mistake if the schema to read the file is different from the schema to write the file. In normal code flow, thefileSchemato read Avro file is always read from the metadata of the actual Avro file, therefore the schema to read file is always the same as the schema to write the file. This code change is for test only and does not affect the normal code flow. It can be removed.