I’d say the basic mission of SqlValidator is to detect user errors and give 
good messages, and assign types.

I hate that it sometimes mutates the tree. Do that as little as possible. If 
you can remove mutations, do it. 

Julian

> On Jan 20, 2026, at 13:18, Sergey Nuyanzin <[email protected]> wrote:
> 
> Hi everyone
> 
> I faced behavior which seems weird to me, however I would like to
> double check first.
> 
> Normally we call
> SqlNode validatedNode = validator.validate(inputNode); //here
> validator is SqlValidatorImpl
> and everything is ok if we do not use inputNode (for whatever reason )
> 
> However if inputNode is used anywhere after validation then in some
> cases validate method makes this node invalid by adding illegal nodes
> 
> From the javadoc for SqlValidator interface it is not clear if this
> method is allowed to mutate SqlNode making it invalid or not[1]
> 
> Would be great to get better understanding whether it is expected
> behavior (may be javadoc should be updated then)  or not
> 
> P.S. Also I tweaked SqlValidatorTest in a way to make it run
> validator.validate(inputNode) 2 times on the same input: there are a
> few tests failed because of the things mentioned above
> 
> [1] 
> https://github.com/apache/calcite/blob/270ba649cfa80228d3f4f6635a08ab06de504399/core/src/main/java/org/apache/calcite/sql/validate/SqlValidator.java#L139-L146
> --
> Best regards,
> Sergey

Reply via email to