-
Notifications
You must be signed in to change notification settings - Fork 47
Description
Hello,
I have been using ORC files created by this library with AWS Athena and have been running into an issue when one of these files contains exactly 10,000 rows. It is failing a check in Presto that I honestly have no idea the intent of. Every other tool that deals with ORC files has no issues with the file.
Without fully understanding the ORC file format, I made a local change to the library that does not call the recordPositions function in flushWriters if recordPositions has just been called on the last write. This appears to fix the issue parsing the files and does not upset any of the unit tests. I'm not sure if there are other actions that should be skipped in this case, so I'm usure if this change creates files that are malformed in other ways. I'm hoping someone with a better understanding of the format can evaluate my patch and determine if it's the right action.
Here's the patch:
diff --git a/writer.go b/writer.go
index 63718e0..2b4d993 100644
--- a/writer.go
+++ b/writer.go
@@ -51,6 +51,7 @@ type Writer struct {
indexOffset uint64
chunkOffset uint64
compressionCodec CompressionCodec
+ lastRecordPositions uint64
}
func ptrInt64(i int64) *int64 {
@@ -162,6 +163,7 @@ func (w *Writer) Write(values ...interface{}) error {
if w.totalRows%uint64(w.footer.GetRowIndexStride()) == 0 {
// Records and resets indexes for each writer.
w.recordPositions()
+ w.lastRecordPositions = w.totalRows
if w.treeWriters.size() >= w.stripeTargetSize {
return w.writeStripe()
@@ -217,7 +219,9 @@ func (w *Writer) flushWriters() error {
if err := w.treeWriter.Flush(); err != nil {
return err
}
- w.recordPositions()
+ if w.lastRecordPositions != w.totalRows {
+ w.recordPositions()
+ }
return nil
}
Thanks
-matt