在hive环境下执行语句:create table DM_M_YX_HTGL_i as select contract_no contract_name bus_number contractbatchcode orderid date_formatstart_date yyyy-MM-dd as start_date date_formatend_da
在Hive环境下执行语句时,报错"column start_date cannot be resolved"和"column end_date cannot be resolved"是因为子查询中的字段start_date和end_date无法解析。
可能的原因是子查询中的表别名t没有被正确引用,导致无法解析子查询中的字段。请确保子查询的结果表别名t被正确引用。
以下是修复该问题的示例代码:
create table DM_M_YX_HTGL_i as
select
contract_no,
contract_name,
bus_number,
contractbatchcode,
orderid,
date_format(start_date, 'yyyy-MM-dd') as start_date,
date_format(end_date, 'yyyy-MM-dd') as end_date
from(
select a.*, b.contractbatchcode, b.orderid, c.start_date, c.end_date from DM_M_YX_HTGL_YXD_1 a
left join(
select contractbatchcode, orderId, serialNumber from ZQ_DWA.DWA_M_EVT_DD_ORDER_INFO
where month_id = '202307'
) b
on a.contract_no = b.contractbatchcode and a.bus_number = b.serialNumber
left join (
SELECT arrair_no, start_date, end_date from ZQ_DWD.DWD_D_ACC_ICT_CONTRACT_INFO
where month_id = '202307'
) c
on a.contract_no = c.arrair_no
)t;
在这个示例中,我将子查询的结果表别名t中的start_date和end_date字段添加到了外部查询的字段列表中,确保这些字段可以被正确解析
原文地址: https://www.cveoy.top/t/topic/iUjH 著作权归作者所有。请勿转载和采集!