[GLUTEN-12238][VL] Translate Velox invalid bitmap position errors to Spark's INVALID_BITMAP_POSITION exception#12544
Conversation
…Spark's INVALID_BITMAP_POSITION exception
|
Run Gluten Clickhouse CI on x86 |
There was a problem hiding this comment.
Pull request overview
This pull request restores Spark error API compatibility for bitmap_construct_agg when executed via the Velox backend by translating Velox “bitmap position out of bounds” failures into Spark’s INVALID_BITMAP_POSITION exception type/condition.
Changes:
- Add JVM-side exception translation in
ColumnarBatchOutIterator.translateExceptionto detect Velox invalid bitmap position failures and rethrow Spark’sINVALID_BITMAP_POSITIONexception (with the original error as the cause). - Introduce Spark-version shims (Spark 3.5/4.0/4.1) to construct the Spark-native exception via a small
org.apache.spark.sql.errorsbridge toprivate[sql]QueryExecutionErrors. - Re-enable previously excluded Velox backend tests for
INVALID_BITMAP_POSITIONon Spark 3.5/4.0/4.1.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| shims/spark41/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala | Adds Spark 4.1 bridge to QueryExecutionErrors.invalidBitmapPositionError. |
| shims/spark41/src/main/scala/org/apache/gluten/sql/shims/spark41/Spark41Shims.scala | Exposes invalidBitmapPositionError via the Spark 4.1 shims implementation. |
| shims/spark40/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala | Adds Spark 4.0 bridge to QueryExecutionErrors.invalidBitmapPositionError. |
| shims/spark40/src/main/scala/org/apache/gluten/sql/shims/spark40/Spark40Shims.scala | Exposes invalidBitmapPositionError via the Spark 4.0 shims implementation. |
| shims/spark35/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala | Adds Spark 3.5 bridge to QueryExecutionErrors.invalidBitmapPositionError. |
| shims/spark35/src/main/scala/org/apache/gluten/sql/shims/spark35/Spark35Shims.scala | Exposes invalidBitmapPositionError via the Spark 3.5 shims implementation. |
| shims/common/src/main/scala/org/apache/gluten/sql/shims/SparkShims.scala | Adds a shim hook for INVALID_BITMAP_POSITION exception creation (defaulting to null for older Spark). |
| gluten-ut/spark41/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala | Re-enables Spark 4.1 INVALID_BITMAP_POSITION tests previously excluded. |
| gluten-ut/spark40/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala | Re-enables Spark 4.0 INVALID_BITMAP_POSITION tests previously excluded. |
| gluten-ut/spark35/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala | Re-enables Spark 3.5 INVALID_BITMAP_POSITION tests previously excluded. |
| gluten-arrow/src/main/java/org/apache/gluten/vectorized/ColumnarBatchOutIterator.java | Implements detection/parsing of Velox bitmap OOB failures and maps them to Spark’s INVALID_BITMAP_POSITION. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
The four failing jobs all appear to be environment issues unrelated to this change:
The re-enabled Could a committer please re-run the failed jobs? Thanks! |
|
Run Gluten Clickhouse CI on x86 |
|
Run Gluten Clickhouse CI on x86 |
|
Run Gluten Clickhouse CI on x86 |
What changes are proposed in this pull request?
When
bitmap_construct_aggis offloaded to Velox, an invalid bitmap position fails the query with aGlutenExceptionwrappingVeloxUserError, instead of theSparkArrayIndexOutOfBoundsExceptionwith error conditionINVALID_BITMAP_POSITIONthat vanilla Spark throws. This breaks Spark error API compatibility for callers that match on the error condition.This PR translates the error on the JVM side, following the existing translation precedent in
ColumnarBatchOutIterator.translateException(which already maps Velox type-conversion errors toSchemaColumnConvertNotSupportedException):ColumnarBatchOutIterator.translateExceptionnow detects Velox'sBitmap position out of boundscheck failure, parses the failing position from the message, and rethrows Spark'sINVALID_BITMAP_POSITIONexception with the original error as the cause. The bitmap size parameter is Velox's fixedkBitmapNumBytes = 4096, which matches Spark's implementation, so the error parameters (bitPosition,bitmapNumBytes,bitmapNumBits) are identical to vanilla Spark's.SparkShims.invalidBitmapPositionErrorshim constructs the exception viaQueryExecutionErrors.invalidBitmapPositionErroron Spark 3.5/4.0/4.1 (through a smallorg.apache.spark.sql.errorsbridge, sinceQueryExecutionErrorsisprivate[sql]). Spark 3.3/3.4 have no bitmap aggregate functions and keep the default behavior.VeloxTestSettingsfor Spark 3.5/4.0/4.1 (INVALID_BITMAP_POSITION: position out of bounds,INVALID_BITMAP_POSITION: negative position), which were excluded as a workaround in [GLUTEN-12143][VL] Route bitmap_construct_agg to native Velox execution #12142.Fixes #12238
How was this patch tested?
Re-enabled the
QueryExecutionErrorsSuitetestsINVALID_BITMAP_POSITION: position out of boundsandINVALID_BITMAP_POSITION: negative positionin the Velox backend test settings for Spark 3.5, 4.0 and 4.1; they are validated by CI.Was this patch authored or co-authored using generative AI tooling?
Claude Code