You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "ebyhr (via GitHub)" <gi...@apache.org> on 2026/07/07 06:07:26 UTC
[PR] Arrow: Fix valuesRead accumulation in VectorizedDeltaEncodedValuesReader [iceberg]
ebyhr opened a new pull request, #17121:
URL: https://github.com/apache/iceberg/pull/17121
`VectorizedDeltaEncodedValuesReader.readValues` resets `valuesRead` to the current batch size on every call (`valuesRead = total - remaining`) instead of accumulating it (`+=`). On a multi-batch page read the overflow guard `valuesRead + total > totalValueCount` sees a stale count and silently allows reads past the logical end of the page.
The bug does not throw - DELTA_BINARY_PACKED mini-blocks are zero-padded to a fixed size, so the reader decodes the padding zeros as valid deltas and emits plausible-looking but wrong values. For example, a page of [10, 20, ..., 100] read in batches of 6 and 4, then read once more, returns 110 - the next extrapolated delta step - with no error.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Arrow: Fix valuesRead accumulation in VectorizedDeltaEncodedValuesReader [iceberg]
Posted by "nastra (via GitHub) via issues" <is...@iceberg.apache.org>.
nastra commented on PR #17121:
URL: https://github.com/apache/iceberg/pull/17121#issuecomment-6679203889
@pvary can you also take a look at this please?
--
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.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Arrow: Fix valuesRead accumulation in VectorizedDeltaEncodedValuesReader [iceberg]
Posted by "ebyhr (via GitHub) via issues" <is...@iceberg.apache.org>.
ebyhr commented on PR #17121:
URL: https://github.com/apache/iceberg/pull/17121#issuecomment-6676074515
@nastra Thanks for the review! Sure, I'll handle aligning the readers with Spark's in a follow-up PR.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Arrow: Fix valuesRead accumulation in VectorizedDeltaEncodedValuesReader [iceberg]
Posted by "ldudas-marx (via GitHub)" <gi...@apache.org>.
ldudas-marx commented on code in PR #17121:
URL: https://github.com/apache/iceberg/pull/17121#discussion_r3551621893
##########
arrow/src/main/java/org/apache/iceberg/arrow/vectorized/parquet/VectorizedDeltaEncodedValuesReader.java:
##########
@@ -166,7 +166,7 @@ private void readValues(
currentRowId += loadedRows;
remaining -= loadedRows;
}
- valuesRead = total - remaining;
+ valuesRead += total - remaining;
Review Comment:
I just saw that the negative case is handled by #17121.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Arrow: Fix valuesRead accumulation in VectorizedDeltaEncodedValuesReader [iceberg]
Posted by "pvary (via GitHub) via issues" <is...@iceberg.apache.org>.
pvary merged PR #17121:
URL: https://github.com/apache/iceberg/pull/17121
--
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.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Arrow: Fix valuesRead accumulation in VectorizedDeltaEncodedValuesReader [iceberg]
Posted by "pvary (via GitHub) via issues" <is...@iceberg.apache.org>.
pvary commented on PR #17121:
URL: https://github.com/apache/iceberg/pull/17121#issuecomment-6687175083
Merged to main.
Thanks @ebyhr for the fix and @ldudas-marx and @nastra for the review!
--
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.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Arrow: Fix valuesRead accumulation in VectorizedDeltaEncodedValuesReader [iceberg]
Posted by "ebyhr (via GitHub)" <gi...@apache.org>.
ebyhr commented on code in PR #17121:
URL: https://github.com/apache/iceberg/pull/17121#discussion_r3534014909
##########
arrow/src/test/java/org/apache/iceberg/arrow/vectorized/parquet/TestVectorizedDeltaEncodedValuesReader.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.arrow.vectorized.parquet;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import org.apache.parquet.bytes.ByteBufferInputStream;
+import org.apache.parquet.bytes.ByteBufferReleaser;
+import org.apache.parquet.bytes.HeapByteBufferAllocator;
+import org.apache.parquet.column.values.delta.DeltaBinaryPackingValuesWriterForInteger;
+import org.apache.parquet.io.ParquetDecodingException;
+import org.junit.jupiter.api.Test;
+
+class TestVectorizedDeltaEncodedValuesReader {
+ @Test
+ void readIntegersNoMoreValues() throws Exception {
+ // 10 values: read in two batches of 6 then 4, then assert the overflow guard fires
+ int[] values = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100};
+ VectorizedDeltaEncodedValuesReader reader = readerFor(values);
+
+ int[] batch1 = reader.readIntegers(6, 0);
+ int[] batch2 = reader.readIntegers(4, 0);
+
+ assertThat(batch1).containsExactly(10, 20, 30, 40, 50, 60);
+ assertThat(batch2).containsExactly(70, 80, 90, 100);
+
+ assertThat(reader.totalValueCount()).isEqualTo(10);
+ assertThatThrownBy(() -> reader.readIntegers(1, 0))
Review Comment:
`reader.readIntegers(1, 0)` was returning `[110]` without this PR fix.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Arrow: Fix valuesRead accumulation in VectorizedDeltaEncodedValuesReader [iceberg]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #17121:
URL: https://github.com/apache/iceberg/pull/17121#issuecomment-6329615189
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Arrow: Fix valuesRead accumulation in VectorizedDeltaEncodedValuesReader [iceberg]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #17121:
URL: https://github.com/apache/iceberg/pull/17121#issuecomment-5746419392
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Arrow: Fix valuesRead accumulation in VectorizedDeltaEncodedValuesReader [iceberg]
Posted by "pvary (via GitHub) via issues" <is...@iceberg.apache.org>.
pvary commented on code in PR #17121:
URL: https://github.com/apache/iceberg/pull/17121#discussion_r4492504758
##########
arrow/src/test/java/org/apache/iceberg/arrow/vectorized/parquet/TestVectorizedDeltaEncodedValuesReader.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.arrow.vectorized.parquet;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import org.apache.parquet.bytes.ByteBufferInputStream;
+import org.apache.parquet.bytes.ByteBufferReleaser;
+import org.apache.parquet.bytes.HeapByteBufferAllocator;
+import org.apache.parquet.column.values.delta.DeltaBinaryPackingValuesWriterForInteger;
+import org.apache.parquet.io.ParquetDecodingException;
+import org.junit.jupiter.api.Test;
+
+class TestVectorizedDeltaEncodedValuesReader {
+ @Test
+ void readIntegersNoMoreValues() throws Exception {
+ // 10 values: read in two batches of 6 then 4, then assert the overflow guard fires
+ int[] values = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100};
+ VectorizedDeltaEncodedValuesReader reader = readerFor(values);
+
+ int[] batch1 = reader.readIntegers(6, 0);
+ int[] batch2 = reader.readIntegers(4, 0);
+
+ assertThat(batch1).containsExactly(10, 20, 30, 40, 50, 60);
+ assertThat(batch2).containsExactly(70, 80, 90, 100);
+
+ assertThat(reader.totalValueCount()).isEqualTo(10);
+ assertThatThrownBy(() -> reader.readIntegers(1, 0))
+ .isInstanceOf(ParquetDecodingException.class)
+ .hasMessageContaining("No more values to read");
+ }
+
+ private static VectorizedDeltaEncodedValuesReader readerFor(int... values) throws IOException {
+ ByteBuffer encoded = write(values);
+ VectorizedDeltaEncodedValuesReader reader = new VectorizedDeltaEncodedValuesReader();
+ reader.initFromPage(values.length, ByteBufferInputStream.wrap(encoded));
+ return reader;
+ }
+
+ private static ByteBuffer write(int[] values) {
+ try (DeltaBinaryPackingValuesWriterForInteger writer =
+ new DeltaBinaryPackingValuesWriterForInteger(
+ 128, 4, 100, 200, HeapByteBufferAllocator.getInstance())) {
+ for (int value : values) {
+ writer.writeInteger(value);
+ }
+ return writer
Review Comment:
nit: newline
--
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.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Arrow: Fix valuesRead accumulation in VectorizedDeltaEncodedValuesReader [iceberg]
Posted by "ebyhr (via GitHub)" <gi...@apache.org>.
ebyhr commented on code in PR #17121:
URL: https://github.com/apache/iceberg/pull/17121#discussion_r3534014909
##########
arrow/src/test/java/org/apache/iceberg/arrow/vectorized/parquet/TestVectorizedDeltaEncodedValuesReader.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.arrow.vectorized.parquet;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import org.apache.parquet.bytes.ByteBufferInputStream;
+import org.apache.parquet.bytes.ByteBufferReleaser;
+import org.apache.parquet.bytes.HeapByteBufferAllocator;
+import org.apache.parquet.column.values.delta.DeltaBinaryPackingValuesWriterForInteger;
+import org.apache.parquet.io.ParquetDecodingException;
+import org.junit.jupiter.api.Test;
+
+class TestVectorizedDeltaEncodedValuesReader {
+ @Test
+ void readIntegersNoMoreValues() throws Exception {
+ // 10 values: read in two batches of 6 then 4, then assert the overflow guard fires
+ int[] values = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100};
+ VectorizedDeltaEncodedValuesReader reader = readerFor(values);
+
+ int[] batch1 = reader.readIntegers(6, 0);
+ int[] batch2 = reader.readIntegers(4, 0);
+
+ assertThat(batch1).containsExactly(10, 20, 30, 40, 50, 60);
+ assertThat(batch2).containsExactly(70, 80, 90, 100);
+
+ assertThat(reader.totalValueCount()).isEqualTo(10);
+ assertThatThrownBy(() -> reader.readIntegers(1, 0))
Review Comment:
`reader.readIntegers(1, 0)` returns `[110]` without this PR fix.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Arrow: Fix valuesRead accumulation in VectorizedDeltaEncodedValuesReader [iceberg]
Posted by "ldudas-marx (via GitHub)" <gi...@apache.org>.
ldudas-marx commented on code in PR #17121:
URL: https://github.com/apache/iceberg/pull/17121#discussion_r3537097806
##########
arrow/src/main/java/org/apache/iceberg/arrow/vectorized/parquet/VectorizedDeltaEncodedValuesReader.java:
##########
Review Comment:
Nit: I noticed that valuesRead is always 0, so the code can be simplified here.
##########
arrow/src/main/java/org/apache/iceberg/arrow/vectorized/parquet/VectorizedDeltaEncodedValuesReader.java:
##########
@@ -166,7 +166,7 @@ private void readValues(
currentRowId += loadedRows;
remaining -= loadedRows;
}
- valuesRead = total - remaining;
+ valuesRead += total - remaining;
Review Comment:
I think `remaining` is always 0 here. The while loop exit criteria ensures that it is non-positive. In`loadMiniBlockToOutput` `remaining` is an upper bound for the return value `loadedRows` so `remaining -= loadedRows` cannot be negative either.
It could be only negative if `valuesRead = 0` and `total = 0`. In this case it throws an exception now because we try to write the first value to a zero size array. So even if it's a valid use it's buggy anyway. I would add a check or early return if `total` is 0 or less.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Arrow: Fix valuesRead accumulation in VectorizedDeltaEncodedValuesReader [iceberg]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #17121:
URL: https://github.com/apache/iceberg/pull/17121#issuecomment-5274349996
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org