[英]Create View in Athena but "column name specified more than once"
I have created a SELECT query that joins three tables in AWS Athena - the query itself works...我创建了一个 SELECT 查询,它连接了 AWS Athena 中的三个表——查询本身有效……
Select t1.*, t2.*, t3.*
from "analytics_poc"."stg_orderitem" as t1
INNER Join "analytics_poc"."stg_orderitemtag" as t2
ON t1.orderitemid=t2.orderitemid
LEFT Join "analytics_poc"."stg_tag" as t3
ON t3.tagid=t2.tagid
However, when I try to create a VIEW from this query I get this error...但是,当我尝试从此查询创建 VIEW 时出现此错误...
CREATE OR REPLACE VIEW "CMS_orderitem_tags"
AS
Select t1.*, t2.*, t3.*
from "analytics_poc"."stg_orderitem" as t1
INNER Join "analytics_poc"."stg_orderitemtag" as t2
ON t1.orderitemid=t2.orderitemid
LEFT Join "analytics_poc"."stg_tag" as t3
ON t3.tagid=t2.tagid
line 1:1: Column name 'orderitemid' specified more than once.
Does anyone know why this is the case?有谁知道为什么会这样?
It would appear that a column called orderitemid
exists in more than one of those tables.看起来在多个表中存在一个名为
orderitemid
的列。
The SELECT
command doesn't mind having multiple output columns with the same name, but CREATE VIEW
doesn't allow it. SELECT
命令不介意多个 output 列同名,但CREATE VIEW
不允许。
You could try USING
instead, which removes the 'join' column.您可以尝试
USING
,它会删除“加入”列。
Change this line:更改此行:
INNER Join "analytics_poc"."stg_orderitemtag" as t2 ON t1.orderitemid=t2.orderitemid
into:进入:
INNER Join "analytics_poc"."stg_orderitemtag" as t2 ON USING(orderitemid)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.