无法识别子查询中“选择”附近的输入
Posted
技术标签:
【中文标题】无法识别子查询中“选择”附近的输入【英文标题】:cannot recognize input near 'select' in subquery 【发布时间】:2016-09-05 17:38:33 【问题描述】:SELECT
(case TRIM(T.tactictype)
WHEN 'Economics' THEN
(select economic_tactic_id from cfext.economic_tactics E where LOWER(E.economic_tactic_name) = LOWER(T.tacticname) )
WHEN 'Cyber' THEN
(select cyber_tactic_id from cfext.cyber_tactics E where LOWER(E.cyber_tactic_name) = LOWER(T.tacticname) )
end) AS tacticid
FROM cfext.banking_crreport_allfiles T
LIMIT 50;
我正在尝试运行上述查询,但出现以下错误。 有人可以帮忙吗?
失败:ParseException line 4:1 无法识别表达式规范中“select”“economic_tactic_id”“from”附近的输入
【问题讨论】:
【参考方案1】:尝试使用
SELECT (case TRIM(T.tactictype) WHEN 'Economics' THEN (select E.economic_tactic_id from cfext.economic_tactics E
where LOWER(E.economic_tactic_name) = LOWER(T.tacticname) )
WHEN 'Cyber' THEN (select E.cyber_tactic_id from cfext.cyber_tactics E where LOWER(E.cyber_tactic_name) = LOWER(T.tacticname) ) end) AS tacticid
FROM cfext.banking_crreport_allfiles T LIMIT 50;
【讨论】:
【参考方案2】:SELECT (case TRIM(T.tactictype)
WHEN 'Economics' THEN
(select et.economic_tactic_id
from cfext.economic_tactics et
where LOWER(et.economic_tactic_name) = LOWER(T.tacticname))
WHEN 'Cyber' THEN
(select e.cyber_tactic_id
from cfext.cyber_tactics e
where LOWER(e.cyber_tactic_name) = LOWER(T.tacticname))
end) AS tacticid`enter code here` FROM cfext.banking_crreport_allfiles T LIMIT 50;
【讨论】:
【参考方案3】:Hive 不支持 SELECT
子句中的子查询。你需要改写逻辑:
SELECT COALESCE(E.economic_tactic_id, C.cyber_tactic_id) as tacticid
FROM cfext.banking_crreport_allfiles T LEFT JOIN
cfext.economic_tactics E
ON LOWER(E.economic_tactic_name) = LOWER(T.tacticname) AND
TRIM(T.tactictype) = 'Economics' LEFT JOIN
cfext.cyber_tactics C
ON LOWER(C.cyber_tactic_name) = LOWER(T.tacticname) AND
TRIM(T.tactictype) = 'Cyber';
【讨论】:
以上是关于无法识别子查询中“选择”附近的输入的主要内容,如果未能解决你的问题,请参考以下文章
BZOJ1396识别子串&BZOJ2865字符串识别(后缀自动机)
蜂巢:ParseException 行 3:23 无法识别“来自”附近的输入
spring cloud导入一个新的spring boot项目作为spring cloud的一个子模块微服务,怎么做/或者 每次导入一个新的spring boot项目,IDEA不识别子module(代