PerumalsamyR opened a new pull request, #12544:
URL: https://github.com/apache/gluten/pull/12544

   ## What changes are proposed in this pull request?
   
   When `bitmap_construct_agg` is offloaded to Velox, an invalid bitmap 
position fails the query with a `GlutenException` wrapping `VeloxUserError`, 
instead of the `SparkArrayIndexOutOfBoundsException` with error condition 
`INVALID_BITMAP_POSITION` that 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 to 
`SchemaColumnConvertNotSupportedException`):
   
   - `ColumnarBatchOutIterator.translateException` now detects Velox's `Bitmap 
position out of bounds` check failure, parses the failing position from the 
message, and rethrows Spark's `INVALID_BITMAP_POSITION` exception with the 
original error as the cause. The bitmap size parameter is Velox's fixed 
`kBitmapNumBytes = 4096`, which matches Spark's implementation, so the error 
parameters (`bitPosition`, `bitmapNumBytes`, `bitmapNumBits`) are identical to 
vanilla Spark's.
   - A new `SparkShims.invalidBitmapPositionError` shim constructs the 
exception via `QueryExecutionErrors.invalidBitmapPositionError` on Spark 
3.5/4.0/4.1 (through a small `org.apache.spark.sql.errors` bridge, since 
`QueryExecutionErrors` is `private[sql]`). Spark 3.3/3.4 have no bitmap 
aggregate functions and keep the default behavior.
   - Re-enables the two previously excluded tests in `VeloxTestSettings` for 
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 #12142.
   
   Fixes #12238
   
   ## How was this patch tested?
   
   Re-enabled the `QueryExecutionErrorsSuite` tests `INVALID_BITMAP_POSITION: 
position out of bounds` and `INVALID_BITMAP_POSITION: negative position` in 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?
   
   Generated-by: Claude 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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to