0lai0 opened a new pull request, #3709:
URL: https://github.com/apache/datafusion-comet/pull/3709
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases. You can
link an issue to this PR using the GitHub syntax. For example `Closes #123`
indicates that this PR will close issue #123.
-->
Closes #3332
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in
the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your
changes and offer better suggestions for fixes.
-->
Previously, list_extract.rs iterated over index_array.values(), which
returns the raw Arrow buffer (&[i32]). In the Arrow memory format, the
underlying buffer for NULL slots contains undefined/garbage values (typically
0). When arr[idx] was evaluated and idx was NULL, Comet incorrectly read this
default 0 value instead of checking the validity bitmap, resulting in arr[0]
being returned instead of NULL.
By switching to index_array.iter(), which returns an Option<i32>, we can
safely use pattern matching to handle None correctly and append nulls to the
output array without touching the garbage data.
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is
sometimes worth providing a summary of the individual changes in this PR.
-->
This PR fixes a correctness bug in the native execution of GetArrayItem when
dealing with dynamic indices containing NULL values. It also removes the
Incompatible fallback workaround, fully re-enabling native execution for this
expression.
The following changes were made:
1. Rust Core Fix (list_extract.rs): Replaced index_array.values() with
index_array.iter().
2. Remove Workaround (arrays.scala): Removed the getSupportLevel override in
CometGetArrayItem that forced fallback to Spark.
3. Test Cleanup:
- Re-enabled the SQL test in get_array_item.sql by changing query
ignore to query spark_answer_only.
- Removed the now-unnecessary allowIncompatible configuration for
GetArrayItem across CometExpressionSuite, CometNativeReaderSuite, and
ParquetReadSuite.
## How are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are
they covered by existing tests)?
-->
- Existing tests in get_array_item.sql have been un-ignored and now
successfully pass against the Spark answers.
- `make test` executed to ensure no regressions in native arrays/list
extraction handling.
--
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]