wombatu-kun opened a new issue, #19240:
URL: https://github.com/apache/hudi/issues/19240

   ### Bug Description
   
   **What happened:**
   
   `BindVisitor#visitPredicate` builds its "unsupported predicate" error by 
interpolating `this` (the visitor) instead of the predicate, and it also omits 
the space before `cannot`:
   
   ```java
   throw new IllegalArgumentException("The expression " + this + "cannot be 
visited as predicate");
   ```
   
   `BindVisitor` has no `toString()` override, so the message that actually 
reaches the user is:
   
   ```
   The expression org.apache.hudi.common.expression.BindVisitor@41a90fa8cannot 
be visited as predicate
   ```
   
   **What you expected:**
   
   The message should name the offending expression, exactly the way the 
sibling `PartialBindVisitor#visitPredicate` already does:
   
   ```java
   throw new IllegalArgumentException("The expression " + predicate + " cannot 
be visited as predicate");
   ```
   
   **Steps to reproduce:**
   
   1. Construct a `Predicates.StringStartsWithAny`. It is the only `Predicate` 
implementation that can reach the guard, because `Not`, `BinaryComparison`, 
`In`, `IsNull`, `IsNotNull`, `StringStartsWith` and `StringContains` are 
handled earlier in `visitPredicate`, while `And`, `Or`, `TrueExpression` and 
`FalseExpression` override `accept` and never enter it.
   2. Call `accept(new BindVisitor(schema, true))` on it.
   3. Read `IllegalArgumentException#getMessage()`.
   
   **Severity and scope:**
   
   This is a diagnostic defect in a defensive guard, not a runtime failure. 
`BindVisitor` is only constructed for partition pruning, in 
`HoodieBackedTableMetadata` and `FileSystemBackedTableMetadata`, whereas 
`StringStartsWithAny` is only constructed as a metadata table key filter, so as 
far as I can tell no current call site can trip the guard. I have not traced 
every engine-side filter translation path, so please treat "currently 
unreachable" as an inference rather than a proven fact. Nothing is broken 
today; the message is simply useless to whoever trips the guard next.
   
   **Related gap:**
   
   `StringStartsWithAny` is the only class in `Predicates.java` without a 
`toString()` override, so even after interpolating `predicate` the message 
would still print an identity hash such as 
`Predicates$StringStartsWithAny@6d06d69c`. It is also constructed with a `null` 
left operand in `HoodieBackedTableMetadata`, so any `toString()` added to it 
has to be null safe.
   
   **Note for whoever picks this up:** I am fixing this myself and will open a 
PR shortly. The regression test naturally belongs in a new `TestBindVisitor`, 
which is also created by the open PR #19204, so whichever of the two lands 
second will need a trivial merge that keeps both tests.
   
   ### Environment
   
   **Hudi version:** master, commit `b22a3d7af37a`
   **Query engine:** not applicable, the defect is in `hudi-common` and is 
engine independent
   **Relevant configs:** none
   
   ### Logs and Stack Trace
   
   Captured from a local run of a reproducing unit test against `b22a3d7af37a`:
   
   ```
   org.opentest4j.AssertionFailedError: The expression 
org.apache.hudi.common.expression.BindVisitor@41a90fa8cannot be visited as 
predicate
        at 
org.apache.hudi.common.expression.TestBindVisitor.testUnsupportedPredicateErrorNamesTheExpression(TestBindVisitor.java:49)
   ```
   


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