编译语句时出错:FAILED: SemanticException [Error 10002] - MAKE SELECT WITH MAX ON HIVE
Posted
技术标签:
【中文标题】编译语句时出错:FAILED: SemanticException [Error 10002] - MAKE SELECT WITH MAX ON HIVE【英文标题】:Error while compiling statement: FAILED: SemanticException [Error 10002] - MAKE SELECT WITH MAX ON HIVE 【发布时间】:2020-06-03 19:43:35 【问题描述】:我正在尝试执行此选择以仅返回最近插入的记录
我正在使用 HIVE
co_junta_comer 和 co_informacao 可以重复,但需要最近的记录
select *
from reference_data.reference_data_novajunta A
where A.ts_inclusao IN
(select max(row2.ts_inclusao)
from reference_data.reference_data_novajunta row2
where A.co_junta_comer = row2.co_junta_comer
AND row2.co_informacao = A.co_informacao)
我收到错误消息
Error while compiling statement: FAILED: SemanticException [Error 10002]: line 4:28 Invalid column reference 'co_junta_comer'`
【问题讨论】:
要在您的内部子查询中引用外部表,您必须使用相关子查询。正如@zealous 所说,这意味着使用exists
。这在 hive 中可能很困难,有 lots of restrictions.
不需要EXISTS,IN也可以。
select A.co_junta_comer from reference_data.reference_data_novajunta A
工作吗?
@jarlh 是的存在。如果列不存在,则错误将是编译语句时出错:FAILED: SemanticException [Error 10002]: line 1:9 Invalid column reference 'co_junta_comer'
【参考方案1】:
使用row_number()
:
select rdn.*
from (select rdn.*,
row_number() over (partition by co_junta_comer, co_informacao order by ts_inclusao desc) as seqnum
from reference_data.reference_data_novajunta rdn
) rdn
where seqnum = 1;
【讨论】:
以上是关于编译语句时出错:FAILED: SemanticException [Error 10002] - MAKE SELECT WITH MAX ON HIVE的主要内容,如果未能解决你的问题,请参考以下文章
编译语句时出错:FAILED: SemanticException [Error 10002] - MAKE SELECT WITH MAX ON HIVE
Android Studio3.1.2编译时Java Compiler出错:Warning: Failed to parse host proxy3.bj...
cordova发布编译出错,提示:cordova-build error : Execution failed for task ':mergeReleaseResources'.或(
cordova发布编译出错,提示:cordova-build error : Execution failed for task ':mergeReleaseResources'.或(
maven 编译出错 Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean
maven 编译出错 Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean