zzwqqq commented on code in PR #5077:
URL: https://github.com/apache/calcite/pull/5077#discussion_r3556627277
##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -2444,18 +2499,89 @@ public Context qualifiedContext() {
return aliasContext(aliases, true);
}
+ /** Returns a result that uses derived-table field names. */
+ private Result forDerivedTable() {
+ if (neededType == null) {
+ return this;
+ }
+ // Internal derived table aliases may need dialect-specific uniqueness.
+ final List<String> fieldNames = derivedTableFieldNames(neededType);
+ if (fieldNames.equals(neededType.getFieldNames())) {
+ return this;
+ }
+ final RelDataType type = renameRowTypeFields(neededType, fieldNames);
+ final SqlNode newNode = withDerivedTableFieldNames(fieldNames);
+ final ImmutableMap.Builder<String, RelDataType> aliasBuilder =
+ ImmutableMap.builder();
+ for (Map.Entry<String, RelDataType> alias : aliases.entrySet()) {
+ aliasBuilder.put(alias.getKey(),
+ alias.getValue() == neededType ? type : alias.getValue());
+ }
+ return new Result(newNode, clauses, neededAlias, type,
aliasBuilder.build(), anon,
+ ignoreClauses, expectedClauses, expectedRel, forceExplicitAlias);
+ }
+
+ /** Rewrites a result for use in a derived table. */
Review Comment:
Thanks. I add clearer dosc.
--
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]