mihaibudiu commented on code in PR #5056:
URL: https://github.com/apache/calcite/pull/5056#discussion_r3493616847
##########
core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java:
##########
@@ -415,27 +415,42 @@ public SqlConformance getConformance() {
return new SqlNodeList(list, SqlParserPos.ZERO);
}
- @Override public void declareCursor(SqlSelect select,
+ @Override public void declareCursor(SqlNode query,
SqlValidatorScope parentScope) {
- cursorSet.add(select);
+ cursorSet.add(query);
- // add the cursor to a map that maps the cursor to its select based on
+ // add the cursor to a map that maps the cursor to its query based on
// the position of the cursor relative to other cursors in that call
FunctionParamInfo funcParamInfo =
requireNonNull(functionCallStack.peek(), "functionCall");
- Map<Integer, SqlSelect> cursorMap = funcParamInfo.cursorPosToSelectMap;
+ Map<Integer, SqlNode> cursorMap = funcParamInfo.cursorPosToQueryMap;
final int cursorCount = cursorMap.size();
- cursorMap.put(cursorCount, select);
+ cursorMap.put(cursorCount, query);
- // create a namespace associated with the result of the select
+ // create a namespace associated with the result of the query
// that is the argument to the cursor constructor; register it
// with a scope corresponding to the cursor
- SelectScope cursorScope =
- new SelectScope(parentScope, getEmptyScope(), select);
- clauseScopes.put(IdPair.of(select, Clause.CURSOR), cursorScope);
- final SelectNamespace selectNs = createSelectNamespace(select, select);
- final String alias = SqlValidatorUtil.alias(select, nextGeneratedId++);
- registerNamespace(cursorScope, alias, selectNs, false);
+ final SqlValidatorNamespace ns;
+ final SqlValidatorScope cursorScope;
+ if (query instanceof SqlSelect) {
+ SqlSelect select = (SqlSelect) query;
+ cursorScope = new SelectScope(parentScope, getEmptyScope(), select);
+ clauseScopes.put(IdPair.of(select, Clause.CURSOR), cursorScope);
+ ns = createSelectNamespace(select, select);
+ } else if (query.isA(SqlKind.SET_QUERY)) {
+ SqlCall call = (SqlCall) query;
+ cursorScope = new ListScope(parentScope) {
+ @Override public SqlNode getNode() {
+ return call;
+ }
+ };
+ ns = createSetopNamespace(call, call);
+ } else {
Review Comment:
This part is not obvious to me, and it does not have coverage in the tests.
Can it be reached? Could you also reduce the set case in the same way?
--
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]