dongjoon-hyun commented on a change in pull request #650:
URL: https://github.com/apache/orc/pull/650#discussion_r599568045
##########
File path: java/core/src/java/org/apache/orc/impl/SchemaEvolution.java
##########
@@ -85,58 +85,47 @@ public SchemaEvolution(TypeDescription fileSchema,
this.hasConversion = false;
this.isOnlyImplicitConversion = true;
this.fileSchema = fileSchema;
+ // Use file schema when reader schema not provided
+ readerSchema = readerSchema == null ? this.fileSchema : readerSchema;
this.isAcid = checkAcidSchema(fileSchema);
- boolean readerSchemaIsAcid = readerSchema == null ? false :
checkAcidSchema(readerSchema);
+ boolean readerSchemaIsAcid = checkAcidSchema(readerSchema);
this.includeAcidColumns = options.getIncludeAcidColumns();
this.readerColumnOffset = isAcid && !readerSchemaIsAcid ?
acidEventFieldNames.size() : 0;
- if (readerSchema != null) {
- if (isAcid && !readerSchemaIsAcid) {
- this.readerSchema = createEventSchema(readerSchema);
- } else {
- this.readerSchema = readerSchema;
- }
- if (readerIncluded != null &&
- readerIncluded.length + readerColumnOffset !=
- this.readerSchema.getMaximumId() + 1) {
- throw new IllegalArgumentException("Include vector the wrong length: "
- + this.readerSchema.toJson() + " with include length "
- + readerIncluded.length);
- }
- this.readerFileTypes =
- new TypeDescription[this.readerSchema.getMaximumId() + 1];
- int positionalLevels = 0;
- if (options.getForcePositionalEvolution()) {
- positionalLevels = isAcid ? 2 : options.getPositionalEvolutionLevel();
- } else if (!hasColumnNames(isAcid? getBaseRow(fileSchema) : fileSchema))
{
- if (!this.fileSchema.equals(this.readerSchema)) {
- if (!allowMissingMetadata) {
- throw new RuntimeException("Found that schema metadata is missing"
- + " from file. This is likely caused by"
- + " a writer earlier than HIVE-4243. Will"
- + " not try to reconcile schemas");
- } else {
- LOG.warn("Column names are missing from this file. This is"
- + " caused by a writer earlier than HIVE-4243. The reader will"
- + " reconcile schemas based on index. File type: " +
- this.fileSchema + ", reader type: " + this.readerSchema);
- positionalLevels = isAcid ? 2 :
options.getPositionalEvolutionLevel();
- }
- }
- }
- buildConversion(fileSchema, this.readerSchema, positionalLevels);
+ // Create type conversion using reader schema
+ if (isAcid && !readerSchemaIsAcid) {
+ this.readerSchema = createEventSchema(readerSchema);
} else {
- this.readerSchema = fileSchema;
- this.readerFileTypes =
- new TypeDescription[this.readerSchema.getMaximumId() + 1];
- if (readerIncluded != null &&
- readerIncluded.length + readerColumnOffset !=
- this.readerSchema.getMaximumId() + 1) {
Review comment:
After this removal of `IllegalArgumentException`, what happens when we
hit this condition?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]