kramerul commented on code in PR #3658:
URL: https://github.com/apache/calcite/pull/3658#discussion_r1469610198


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java:
##########
@@ -257,6 +257,47 @@ public Result visit(Join e) {
     return result(join, leftResult, rightResult);
   }
 
+  private Result maybeFixRenamedFields(Result rightResult, Join e) {
+    Frame last = stack.peekLast();
+    if (last != null && last.r instanceof TableModify) {
+      return rightResult;
+    }
+    List<String> rightFieldNames = e.getRight().getRowType().getFieldNames();
+    List<String> fieldNames = e.getRowType().getFieldNames();
+    int offset = e.getLeft().getRowType().getFieldCount();
+    boolean hasFieldNameCollision = false;
+    for (int i = 0; i < rightFieldNames.size(); i++) {
+      if (!rightFieldNames.get(i).equals(fieldNames.get(offset + i))) {
+        hasFieldNameCollision = true;
+      }
+    }
+    if (!hasFieldNameCollision) {
+      return rightResult;
+    }
+    Builder builder = rightResult.builder(e);
+    List<SqlNode> oldSelectList;
+    if (builder.select.getSelectList() == SqlNodeList.SINGLETON_STAR) {
+      oldSelectList = new ArrayList<>();
+      for (int i = 0; i < rightFieldNames.size(); i++) {
+        oldSelectList.add(new SqlIdentifier(rightFieldNames.get(i), POS));
+      }
+    } else {
+      oldSelectList = 
ImmutableList.<SqlNode>copyOf(builder.select.getSelectList().getList());

Review Comment:
   I fixed the CheckerFramework finding.



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