pvillard31 opened a new pull request, #10269:
URL: https://github.com/apache/nifi/pull/10269
# Summary
NIFI-14614 - Fix QueryRecord column/value misalignment with Calcite by
enforcing projection pushdown
I have tested many (like many) things but I think this is now properly fixed
! 🚀
**Summary**
- Fixes incorrect value mapping in QueryRecord when SELECT reorders columns
and for UNION ALL queries under the new Calcite integration
- Restores behavior parity with NiFi 1.x by pushing projections into the
table scan so row values are produced in the exact SELECT order
**Root Cause**
With the NiFi 2.x calcite-utils integration, Calcite did not always push
projections into the Scan. The JDBC layer then returned rows in base table
order while ResultSet metadata reflected the SELECT projection, leading to
label/value misalignment (e.g., reorders and UNION ALL appearing as
duplicated/mislabeled rows)
**Changes**
- Projection Pushdown (calcite-utils):
- Made NiFiProjectTableScanRule public and broadened it to match core
Project
- Relaxed operand to .anyInputs() and verified the input is
NiFiTableScan in onMatch
- Transform Project + NiFiTableScan to a projected NiFiTableScan
carrying selected field indexes in the correct order
- Ensured rule registration in NiFiTableScan.register() and added a safe
constructor registration to avoid cases where register() is not invoked
- ResultSetRecordSet simplification (record module):
- Since projection pushdown ensures SELECT order matches row index
order, simplified value retrieval
- Index-first (aligned to schema order), with label-based fallback only
if index getter returns null (to keep mocks/drivers compatible).
# Tracking
Please complete the following tracking steps prior to pull request creation.
### Issue Tracking
- [ ] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue
created
### Pull Request Tracking
- [ ] Pull Request title starts with Apache NiFi Jira issue number, such as
`NIFI-00000`
- [ ] Pull Request commit message starts with Apache NiFi Jira issue number,
as such `NIFI-00000`
### Pull Request Formatting
- [ ] Pull Request based on current revision of the `main` branch
- [ ] Pull Request refers to a feature branch with one commit containing
changes
# Verification
Please indicate the verification steps performed prior to pull request
creation.
### Build
- [ ] Build completed using `./mvnw clean install -P contrib-check`
- [ ] JDK 21
### Licensing
- [ ] New dependencies are compatible with the [Apache License
2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License
Policy](https://www.apache.org/legal/resolved.html)
- [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE`
files
### Documentation
- [ ] Documentation formatting appears as expected in rendered files
--
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]