dmitry-chirkov-dremio opened a new pull request, #55608:
URL: https://github.com/apache/arrow/pull/55608

   ### Rationale for this change
   
   The cache key is built from `Expression::ToString()`. Different expressions 
can print the same text, so the second `Projector::Make` reuses the compiled 
code of the first. The result is wrong, with no error. Three cases on main:
   - `a AND (b OR c)` and `(a AND b) OR c` print the same text.
   - String literals are not escaped, so two `IF` expressions can print the 
same text.
   - The key has no output field type. An `int64` output skips validation after 
an `int32` one was compiled, and returns garbage.
   
   The key also ignores field nullability, so validation is skipped for a field 
with the wrong nullability after a valid one was compiled.
   
   ### What changes are included in this PR?
   
   This PR currently contains only the tests. 10 of the 11 new tests are 
expected to fail on main until the fix commit is pushed. The fix is in 
`expression_cache_key.h` and comes as the second commit.
   
   The fix builds the key with a visitor over the expression tree, with the 
output field type. It is a compact binary form. Every node starts with a tag, 
tokens carry their length, and child lists carry their count. Types and names 
that repeat are written once and then as a short reference. It also sorts `IN` 
lists and finds `like` by node, not by text.
   
   ### Are these changes tested?
   
   The new tests cover the cases above, `IN` value lists, and the compact form 
of type parameters and floating point literals. Numbers for the time to build 
the key and its size will come in a comment with the fix.
   
   ### Are there any user-facing changes?
   
   No.
   
   **This PR contains a "Critical Fix".** It fixes a bug that returned 
incorrect data without an error.
   
   ### Was AI used for this PR?
   
   AI tools helped investigate the bug and write the fix, tests, and 
description.
   
   **PR code and description written by:**
   - [ ] Human
   - [x] AI
   
   **Reviewed before submission by:**
   - [ ] Human
   - [ ] AI
   - [ ] Not reviewed
   


-- 
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]

Reply via email to