You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "zahed1994 (via GitHub)" <gi...@apache.org> on 2026/08/20 19:38:43 UTC

[PR] [SPARK-55968][SQL] Do not treat vectorized reader capacity overflow as corrupt file exception when ignoreCorruptFiles is enabled [spark]

zahed1994 opened a new pull request, #58176:
URL: https://github.com/apache/spark/pull/58176

   ### What changes were proposed in this PR?
   This PR introduces `VectorizedReaderCapacityOverflowException` thrown by `WritableColumnVector` when the vectorized reader capacity is exhausted or encounters an integer overflow. `DataSourceUtils.shouldIgnoreCorruptFileException` is updated so that `VectorizedReaderCapacityOverflowException` is not ignored when `spark.sql.files.ignoreCorruptFiles=true`. Additionally, invalid negative element capacities (from corrupted file data) throw `IllegalArgumentException` so corrupt files are still safely skipped.
   
   ### Why are the changes needed?
   When `ignoreCorruptFiles=true`, vectorized reader capacity overflow was previously caught as a general `RuntimeException`, silently skipping files and dropping user data without warning.
   
   ### Does this PR introduce any user-facing change?
   No API changes. Fixes incorrect silent file skipping on vectorized reader capacity overflow.
   
   ### How was this patch tested?
   - Added unit tests in `ParquetQuerySuite` asserting `DataSourceUtils.shouldIgnoreCorruptFileException` behavior.
   - Ran scalastyle (`sql/scalastyle`) and compilation checks (`sql/Test/compile`).
   


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-55968][SQL] Do not treat vectorized reader capacity overflow as corrupt file exception when ignoreCorruptFiles is enabled [spark]

Posted by "tdcmeehan (via GitHub)" <gi...@apache.org>.
tdcmeehan commented on code in PR #58176:
URL: https://github.com/apache/spark/pull/58176#discussion_r3935298846


##########
sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/VectorizedReaderCapacityOverflowException.java:
##########
@@ -0,0 +1,34 @@
+/*
+ * 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.spark.sql.execution.vectorized;
+
+import org.apache.spark.annotation.DeveloperApi;
+
+/**
+ * Exception thrown when the vectorized reader capacity is exhausted or cannot be reserved.
+ */
+@DeveloperApi

Review Comment:
   I believe this introduces this exception to the public API.  Is this intentional?  It would seem the consumer would have to disable vectorized reader, or ignore corrupt files, and the user wouldn't directly handle this exception.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-55968][SQL] Do not treat vectorized reader capacity overflow as corrupt file exception when ignoreCorruptFiles is enabled [spark]

Posted by "zahed1994 (via GitHub)" <gi...@apache.org>.
zahed1994 commented on PR #58176:
URL: https://github.com/apache/spark/pull/58176#issuecomment-5519801683

   Thanks @krismo-oai. Good catch on the decoder boundary.
   
   Updated the patch to validate decoded lengths in `VectorizedDeltaByteArrayReader` before passing them to `WritableColumnVector`:
   - Checked `prefixLength >= 0`, `suffixLength >= 0`, `prefixLength <= previous.remaining()`, and `(long) prefixLength + suffixLength <= Integer.MAX_VALUE`, throwing `ParquetDecodingException` on invalid values. This keeps malformed delta pages on the corrupt file path when `ignoreCorruptFiles=true`.
   - Added defensive checks in `WritableColumnVector.reserveAdditional` and `appendBytes` to reject negative arguments with `IllegalArgumentException`, keeping `VectorizedReaderCapacityOverflowException` strictly for genuine capacity exhaustion.
   - Added decoder unit tests in `ParquetDeltaByteArrayEncodingSuite` for negative prefix and prefix exceeding previous length.
   - Added an end-to-end file-scan test in `ParquetQuerySuite` (exercised on both V1 and V2) using a mutated 2-row delta byte array fixture (`prefixLength = -2`), verifying it gets skipped under `ignoreCorruptFiles=true` and surfaces `ParquetDecodingException` (not capacity overflow) under `ignoreCorruptFiles=false`.
   


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-55968][SQL] Do not treat vectorized reader capacity overflow as corrupt file exception when ignoreCorruptFiles is enabled [spark]

Posted by "zahed1994 (via GitHub)" <gi...@apache.org>.
zahed1994 closed pull request #58176: [SPARK-55968][SQL] Do not treat vectorized reader capacity overflow as corrupt file exception when ignoreCorruptFiles is enabled
URL: https://github.com/apache/spark/pull/58176


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-55968][SQL] Do not treat vectorized reader capacity overflow as corrupt file exception when ignoreCorruptFiles is enabled [spark]

Posted by "zahed1994 (via GitHub)" <gi...@apache.org>.
zahed1994 commented on PR #58176:
URL: https://github.com/apache/spark/pull/58176#issuecomment-5827388446

   Rebased onto the latest master to resolve conflicts following the merge of SPARK-59352. All unit and integration tests (\ParquetQuerySuite\ across V1/V2 and \ParquetDeltaByteArrayEncodingSuite\) as well as linters (\scalastyle\ and \checkstyle\) have passed cleanly.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-55968][SQL] Do not treat vectorized reader capacity overflow as corrupt file exception when ignoreCorruptFiles is enabled [spark]

Posted by "zahed1994 (via GitHub)" <gi...@apache.org>.
zahed1994 commented on PR #58176:
URL: https://github.com/apache/spark/pull/58176#issuecomment-5493961744

   Hi @sunchao, thanks for catching the `DELTA_BYTE_ARRAY` correctness regression in #54805.
   
   I’ve reopened #58176 to continue working on SPARK-55968 and have revised the approach based on your feedback.
   
   The current patch introduces a dedicated `VectorizedReaderCapacityOverflowException` for the vectorized reader capacity-exhaustion path, so `DataSourceUtils.shouldIgnoreCorruptFileException` can distinguish this condition by exception type rather than by matching the exception message.
   
   However, your `DELTA_BYTE_ARRAY` example highlights an important remaining distinction: a corrupt encoded length can also reach `WritableColumnVector.reserve()` and produce the same underlying integer-overflow error. In that case, it should continue to be treated as a corrupt file when `ignoreCorruptFiles=true`.
   
   I think the remaining fix should therefore be to ensure that invalid capacities originating from encoded input are rejected before they can be classified as `VectorizedReaderCapacityOverflowException`.
   
   Concretely, I’m looking at the following behavior:
   
   * A valid positive capacity request that exceeds the vectorized reader's supported capacity → `VectorizedReaderCapacityOverflowException` → `ignoreCorruptFiles` does **not** suppress it.
   * An invalid/negative capacity originating from malformed Parquet data (such as the negative suffix length in the `DELTA_BYTE_ARRAY` case) → a regular corruption-related exception such as `IllegalArgumentException` → `ignoreCorruptFiles` continues to suppress it.
   * `DataSourceUtils` should only special-case the dedicated capacity-overflow exception and should not rely on matching the exception message.
   
   I’ll add a regression test covering the malformed `DELTA_BYTE_ARRAY` case you identified, in addition to the existing capacity-overflow test, so that both behaviors are explicitly covered.
   
   This should preserve the original SPARK-55968 fix while avoiding the correctness regression in #54805.
   
   Would appreciate your thoughts on whether this separation between invalid input capacity and genuine reader capacity exhaustion is the right approach, @sunchao.
   


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-55968][SQL] Do not treat vectorized reader capacity overflow as corrupt file exception when ignoreCorruptFiles is enabled [spark]

Posted by "zahed1994 (via GitHub)" <gi...@apache.org>.
zahed1994 commented on PR #58176:
URL: https://github.com/apache/spark/pull/58176#issuecomment-5817739471

   Friendly ping @tdcmeehan @sunchao.
   
   The @DeveloperApi annotation has been removed from VectorizedReaderCapacityOverflowException to keep it internal, and all previous feedback on the DELTA_BYTE_ARRAY decoder bounds has been addressed with regression tests.
   
   All CI checks are green and the branch is clean without conflicts. Whenever you have a chance, could you please take another look?


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-55968][SQL] Do not treat vectorized reader capacity overflow as corrupt file exception when ignoreCorruptFiles is enabled [spark]

Posted by "krismo-oai (via GitHub)" <gi...@apache.org>.
krismo-oai commented on code in PR #58176:
URL: https://github.com/apache/spark/pull/58176#discussion_r3917229493


##########
sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/WritableColumnVector.java:
##########
@@ -156,7 +156,7 @@ private void throwUnsupportedException(int requiredCapacity, Throwable cause) {
         "refer to " + SQLConf.ORC_VECTORIZED_READER_BATCH_SIZE().key() +
         " (default " + SQLConf.ORC_VECTORIZED_READER_BATCH_SIZE().defaultValueString() +
         ") and " + SQLConf.ORC_VECTORIZED_READER_ENABLED().key() + ".";
-    throw new RuntimeException(message, cause);
+    throw new VectorizedReaderCapacityOverflowException(message, cause);

Review Comment:
   ### [P2] Keep malformed Parquet lengths in the corrupt-file path
   
   Following up on the malformed-length case discussed above: this is still reproducible at `0b78648c`.
   
   The helper changed in `WritableColumnVector.java:159` is reachable for malformed encoded lengths, not just genuine capacity exhaustion. For example, a `DELTA_BYTE_ARRAY` page with prefix lengths `[0, -2]`, suffix lengths `[1, 1]`, and suffix bytes `ab` successfully decodes its first value. The second value then calls `appendBytes(-2, ...)`, which requests `reserve(1 + -2)` before copying any bytes. This now throws `VectorizedReaderCapacityOverflowException`, which `DataSourceUtils.shouldIgnoreCorruptFileException` explicitly excludes. Consequently, a genuinely corrupt file aborts the query even with `ignoreCorruptFiles=true`.
   
   I reproduced this with a 246-byte Parquet file alongside a healthy file across all eight combinations of V1/V2, row/batch delivery, and heap/off-heap vectors. The reviewed head fails; substituting the exact base versions of `WritableColumnVector` and `DataSourceUtils` correctly skips the corrupt file and returns the healthy row. Restoring the head reproduces the failure again.
   
   Please validate decoded lengths—including delta-prefix bounds against the previous value—before they reach capacity arithmetic, while preserving the dedicated exception for genuine overflow/allocation failures. The new test manually constructs an `IllegalArgumentException`; it does not verify that malformed input actually takes that path. A decoder or file-scan regression test should cover this case.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-55968][SQL] Do not treat vectorized reader capacity overflow as corrupt file exception when ignoreCorruptFiles is enabled [spark]

Posted by "zahed1994 (via GitHub)" <gi...@apache.org>.
zahed1994 commented on code in PR #58176:
URL: https://github.com/apache/spark/pull/58176#discussion_r3949745479


##########
sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/VectorizedReaderCapacityOverflowException.java:
##########
@@ -0,0 +1,34 @@
+/*
+ * 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.spark.sql.execution.vectorized;
+
+import org.apache.spark.annotation.DeveloperApi;
+
+/**
+ * Exception thrown when the vectorized reader capacity is exhausted or cannot be reserved.
+ */
+@DeveloperApi

Review Comment:
   Good point. The exception is only intended as an internal marker so DataSourceUtils can distinguish genuine vectorized reader capacity exhaustion from corrupt input; it is not intended as a user-facing/developer API. I'll remove the @DeveloperApi annotation and keep the exception internal to the implementation.



##########
sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/VectorizedReaderCapacityOverflowException.java:
##########
@@ -0,0 +1,34 @@
+/*
+ * 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.spark.sql.execution.vectorized;
+
+import org.apache.spark.annotation.DeveloperApi;
+
+/**
+ * Exception thrown when the vectorized reader capacity is exhausted or cannot be reserved.
+ */
+@DeveloperApi

Review Comment:
   Good point. The exception is only intended as an internal marker so DataSourceUtils can distinguish genuine vectorized reader capacity exhaustion from corrupt input; it is not intended as a user-facing/developer API. I'll remove the @DeveloperApi annotation and keep the exception internal to the implementation.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-55968][SQL] Do not treat vectorized reader capacity overflow as corrupt file exception when ignoreCorruptFiles is enabled [spark]

Posted by "zahed1994 (via GitHub)" <gi...@apache.org>.
zahed1994 commented on code in PR #58176:
URL: https://github.com/apache/spark/pull/58176#discussion_r3949747480


##########
sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/VectorizedReaderCapacityOverflowException.java:
##########
@@ -0,0 +1,34 @@
+/*
+ * 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.spark.sql.execution.vectorized;
+
+import org.apache.spark.annotation.DeveloperApi;
+
+/**
+ * Exception thrown when the vectorized reader capacity is exhausted or cannot be reserved.
+ */
+@DeveloperApi

Review Comment:
   Good point. The exception is only intended as an internal marker so DataSourceUtils can distinguish genuine vectorized reader capacity exhaustion from corrupt input; it is not intended as a user-facing/developer API. I'll remove the @DeveloperApi annotation and keep the exception internal to the implementation.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-55968][SQL] Do not treat vectorized reader capacity overflow as corrupt file exception when ignoreCorruptFiles is enabled [spark]

Posted by "zahed1994 (via GitHub) via reviews" <re...@spark.apache.org>.
zahed1994 commented on PR #58176:
URL: https://github.com/apache/spark/pull/58176#issuecomment-6799602489

   Friendly ping @sunchao @tdcmeehan. Whenever you have a moment, could you please take another look? 
   All previous feedback has been addressed and CI is green.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-55968][SQL] Do not treat vectorized reader capacity overflow as corrupt file exception when ignoreCorruptFiles is enabled [spark]

Posted by "zahed1994 (via GitHub)" <gi...@apache.org>.
zahed1994 commented on PR #58176:
URL: https://github.com/apache/spark/pull/58176#issuecomment-5450927885

   Closing as duplicate of earlier open PR #54805.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-55968][SQL] Do not treat vectorized reader capacity overflow as corrupt file exception when ignoreCorruptFiles is enabled [spark]

Posted by "zahed1994 (via GitHub)" <gi...@apache.org>.
zahed1994 closed pull request #58176: [SPARK-55968][SQL] Do not treat vectorized reader capacity overflow as corrupt file exception when ignoreCorruptFiles is enabled
URL: https://github.com/apache/spark/pull/58176


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org