Hive 环境下 "column start_date cannot be resolved" 错误解决方法
在 Hive 环境下执行语句时,报错 "column start_date cannot be resolved" 和 "column end_date cannot be resolved" 是因为子查询中的字段 start_date 和 end_date 无法解析。\n\n可能的原因是子查询中的表别名 t 没有被正确引用,导致无法解析子查询中的字段。请确保子查询的结果表别名 t 被正确引用。\n\n以下是修复该问题的示例代码:\n\nsql\ncreate table DM_M_YX_HTGL_i as \nselect \n contract_no,\n contract_name,\n bus_number,\n contractbatchcode,\n orderid,\n date_format(start_date, 'yyyy-MM-dd') as start_date,\n date_format(end_date, 'yyyy-MM-dd') as end_date\nfrom(\n select a.*, b.contractbatchcode, b.orderid, c.start_date, c.end_date from DM_M_YX_HTGL_YXD_1 a\n left join(\n select contractbatchcode, orderId, serialNumber from ZQ_DWA.DWA_M_EVT_DD_ORDER_INFO\n where month_id = '202307'\n ) b\n on a.contract_no = b.contractbatchcode and a.bus_number = b.serialNumber\n left join (\n SELECT arrair_no, start_date, end_date from ZQ_DWD.DWD_D_ACC_ICT_CONTRACT_INFO\n where month_id = '202307'\n ) c\n on a.contract_no = c.arrair_no\n)t;\n
\n\n在这个示例中,我将子查询的结果表别名 t 中的 start_date 和 end_date 字段添加到了外部查询的字段列表中,确保这些字段可以被正确解析。

原文地址: http://www.cveoy.top/t/topic/qAiZ 著作权归作者所有。请勿转载和采集!