losipiuk commented on a change in pull request #2040:
URL: https://github.com/apache/hive/pull/2040#discussion_r589336031



##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/io/avro/AvroGenericRecordReader.java
##########
@@ -88,22 +88,38 @@ public AvroGenericRecordReader(JobConf job, FileSplit 
split, Reporter reporter)
       gdr.setExpected(latest);
     }
 
-    if (split.getLength() == 0) {
-      this.isEmptyInput = true;
-      this.start = 0;
-      this.reader = null;
+    org.apache.avro.file.FileReader<GenericRecord> nonFinalReader = null;
+    try {
+      if (split.getLength() == 0) {
+        this.isEmptyInput = true;
+        this.start = 0;
+        this.reader = null;
+      } else {
+        this.isEmptyInput = false;
+        nonFinalReader = new DataFileReader<GenericRecord>(new 
FsInput(split.getPath(), job), gdr);
+        this.reader = nonFinalReader;
+        this.reader.sync(split.getStart());
+        this.start = reader.tell();

Review comment:
       No. Not really. Problematic exceptions I saw were coming from 
`extractWriterTimezoneFromMetadata` below. 
   So maybe we could only wrap
   ```
         this.writerTimezone = extractWriterTimezoneFromMetadata(job, split, 
gdr);
         this.writerProleptic = extractWriterProlepticFromMetadata(job, split, 
gdr);
   ```
   section.
   
   Yet I think it is safer to keep it around everything. E.g. I am not sure if 
`reader.sync` is guaranteed to not throw. 
   Also having it all covered guards as from future changes to this code.




----------------------------------------------------------------
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to