kasakrisz commented on code in PR #3843:
URL: https://github.com/apache/hive/pull/3843#discussion_r1043338477


##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/PlanModifierForASTConv.java:
##########
@@ -71,7 +73,10 @@ public class PlanModifierForASTConv {
   public static RelNode convertOpTree(RelNode rel, List<FieldSchema> 
resultSchema, boolean alignColumns)
       throws CalciteSemanticException {
     if (rel instanceof HiveValues) {
-      return rel;
+      RelDataTypeFactory typeFactory = rel.getCluster().getTypeFactory();
+      List<String> fieldNames = 
resultSchema.stream().map(FieldSchema::getName).collect(Collectors.toList());
+      fieldNames = SqlValidatorUtil.uniquify(fieldNames, 
typeFactory.getTypeSystem().isSchemaCaseSensitive());

Review Comment:
   The new column names are the same as a non empty query's result which top 
operator is not `HiveValues`. Example:
   ```
   select * from (select a, b from t1) s
   left join t2 on s.a = t2.c;
   ```
   ```
   select * from (select a, b from t1 where 0 = 1) s
   left join t2 on s.a = t2.c;
   ```
   both produces column names:
   ```
   s.a  s.b     t2.c    t2.d
   ```



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to