You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2021/01/18 09:53:35 UTC

[GitHub] [hive] kasakrisz commented on a change in pull request #1865: HIVE-24633: Support CTE with column labels

kasakrisz commented on a change in pull request #1865:
URL: https://github.com/apache/hive/pull/1865#discussion_r559440784



##########
File path: ql/src/test/queries/clientpositive/cte_8.q
##########
@@ -0,0 +1,34 @@
+set hive.cli.print.header=true;
+
+create table t1(int_col int, bigint_col bigint);
+
+insert into t1 values(1, 2), (3, 4);
+
+explain cbo
+with cte1(a, b) as (select int_col x, bigint_col y from t1)
+select a, b from cte1;
+
+with cte1(a, b) as (select int_col x, bigint_col y from t1)
+select a, b from cte1;
+
+with cte1(a) as (select int_col x, bigint_col y from t1)

Review comment:
       Our behavior is the same as Postgres: ambiguous column reference is only allowed when the main query has `select *`
   If the main query has an explicit reference to the ambiguous column the query won't compile.
   Added test case for both scenario.
   
   The difference between Hive and Postgres is the final column names int the result set:
   ```
   with cte1(a) as (select int_col x, bigint_col a from t1)
   select * from cte1;
   ``` 
   Postgres: `a, a`
   Hive: `cte1.a	cte1._col1`
   
   After some research I found that we alter the column name to its internal name because CBO cannot handle ambiguous column names: [HIVE-19770](https://issues.apache.org/jira/browse/HIVE-19770)




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org