HanumathRao commented on code in PR #3480:
URL: https://github.com/apache/calcite/pull/3480#discussion_r1374840761
##########
core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java:
##########
@@ -3099,9 +3100,23 @@ private void registerSetop(
// A setop is in the same scope as its parent.
scopes.put(call, parentScope);
- for (SqlNode operand : call.getOperandList()) {
+ @NonNull SqlValidatorScope recursiveScope = parentScope;
+ if (enclosingNode.getKind() == SqlKind.WITH_ITEM) {
+ if (node.getKind() != SqlKind.UNION) {
Review Comment:
The recursive flag is not explicitly checked here because for only recursive
queries we pass WITH_ITEM as enclosed node(essentially it is kind of an
implicit check). For non recursive queries we pass the original enclosed node
which is either WITH or its parent.
`And I think we should implement this validation logic in
org.apache.calcite.sql.validate.WithItemNamespace#validateImpl or
org.apache.calcite.sql.validate.SetopNamespace#validateImpl instead of
registerSetop. WDYT?`
As regards to the validation logic implementation I did go that path but I
think code is getting messy. I thought if we can create a WithRecursive*
classes for these we could do custom logic for recursive queries alone.
--
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]