Skip to content

Commit

Permalink
ORC-562:Don't wrap readerSchema in acidSchema, if readerSchema is alr…
Browse files Browse the repository at this point in the history
…eady acid
  • Loading branch information
Laszlo Pinter committed Oct 24, 2019
1 parent b7fd75c commit 2d0f52a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion java/core/src/java/org/apache/orc/impl/SchemaEvolution.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ public SchemaEvolution(TypeDescription fileSchema,
this.fileSchema = fileSchema;
this.isAcid = checkAcidSchema(fileSchema);
this.includeAcidColumns = options.getIncludeAcidColumns();
this.readerColumnOffset = isAcid ? acidEventFieldNames.size() : 0;
this.readerColumnOffset = (isAcid && readerSchema != null && checkAcidSchema(readerSchema)) || !isAcid
? 0 : acidEventFieldNames.size();
if (readerSchema != null) {
if (isAcid) {
this.readerSchema = createEventSchema(readerSchema);
Expand Down Expand Up @@ -614,6 +615,10 @@ public static boolean checkAcidSchema(TypeDescription type) {
* @return ORC types for the ACID event based on the row's type description
*/
public static TypeDescription createEventSchema(TypeDescription typeDescr) {
// if reader schema is already acid, no need to wrap it in acid schema again
if (checkAcidSchema(typeDescr)) {
return typeDescr;
}
TypeDescription result = TypeDescription.createStruct()
.addField("operation", TypeDescription.createInt())
.addField("originalTransaction", TypeDescription.createLong())
Expand Down

0 comments on commit 2d0f52a

Please sign in to comment.