sbroeder opened a new pull request, #5399:
URL: https://github.com/apache/calcite/pull/5399

   AbstractNamespace.validate()'s finally block unconditionally set status to 
VALID even when validateImpl() threw, leaving rowType/type permanently null. A 
later getRowType()/getType() call on that namespace would then recurse into 
validateNamespace() forever, since it always finds rowType still null.
   
   Fixed by storing the exception from a failed validateImpl() and marking the 
namespace VALID on failure, so a later getRowType() re-throws the real error 
instead of unsafely re-entering validateImpl(), which may have already mutated 
shared validator state, or recursing forever into a null rowType.
   
   SqlAdvisorValidator's activeNamespaces guard treated any repeat call to 
validateNamespace() as a cycle, even when the repeat call was a harmless no-op 
on an already-validated namespace. AbstractNamespace already handles that 
safely via its own status field, so the guard is redundant. The guard also gave 
wrong results: it set an empty struct type on the repeat call, so a query such 
as select ename from (select ?, ename from emp) returned no completion hints. 
Removed it and use the namespace's own cycle detection instead. That detection 
throws AssertionError, which the advisor does not mask.
   
   validateNamespace() now masks CalciteException and, on failure, falls back 
to an empty struct type so callers can enumerate zero columns.
   
   Also override inferUnknownTypes() and checkRollUp() to swallow 
CalciteException from unresolvable sub-expressions, like an unresolvable column 
in an incomplete SQL fragment, so a single failing item in a select list no 
longer aborts validation of the whole enclosing namespace. 
SqlValidatorImpl.checkRollUp() becomes protected so that it can be overridden.
   
   ## Jira Link
   [CALCITE-7792](https://issues.apache.org/jira/browse/CALCITE-7792)
   


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