[ https://issues.apache.org/jira/browse/HIVE-26817?focusedWorklogId=832061&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-832061 ]
ASF GitHub Bot logged work on HIVE-26817: ----------------------------------------- Author: ASF GitHub Bot Created on: 08/Dec/22 13:19 Start Date: 08/Dec/22 13:19 Worklog Time Spent: 10m Work Description: kasakrisz commented on code in PR #3843: URL: https://github.com/apache/hive/pull/3843#discussion_r1043344684 ########## 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()); + return ((HiveValues) rel).copy(fieldNames); Review Comment: I checked how `renameTopLevelSelectInResultSchema` and when I went into details I found it calls https://github.com/apache/calcite/blob/742d47795b878576f8cbdab5f62b26d95559792a/core/src/main/java/org/apache/calcite/rex/RexUtil.java#L1152 when creating the project. I also wanted to call `renameTopLevelSelectInResultSchema` but it would create a `Project` on top of `Values` which I want to avoid in order to generate an AST of a pure empty plan so later we can exploit the optimization which cancels query execution at the physical level. Issue Time Tracking ------------------- Worklog Id: (was: 832061) Time Spent: 50m (was: 40m) > Set column names in result schema when plan has Values root > ----------------------------------------------------------- > > Key: HIVE-26817 > URL: https://issues.apache.org/jira/browse/HIVE-26817 > Project: Hive > Issue Type: Improvement > Components: CBO > Reporter: Krisztian Kasa > Assignee: Krisztian Kasa > Priority: Major > Labels: pull-request-available > Time Spent: 50m > Remaining Estimate: 0h > > The query > {code} > select b1, count(a1) count1 from (select a1, b1 from t1) s where 1=0 group by > b1; > {code} > should have a result with column names > {code} > b1 count1 > {code} > but it is > {code} > $f0 $f1 > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)