HIVE错误:对于第一个LEFT OUTER JOIN的ON子句之后的WHERE子句,我得到1的EOF错误,对于hive中的以下代码

时间:2017-01-02 15:14:28

标签: sql hadoop hive hiveql

private final Map<Integer, Lobby> lobbiesByID;

private boolean isPlayerInLobby(Player player) {
    return lobbiesByID.values().stream().anyMatch(l -> l.hasPlayer(player));
}

public IRemotePublisherForListener connect(Player player, int lobbyID) {
    if(!isPlayerInLobby(player)) {
        //.. insert null-check unless you trust the id
        lobbiesByID.get(lobbyID).addPlayer(player);
    }
    //.. else, log an error, or throw
    return publisher;
}

2 个答案:

答案 0 :(得分:2)

正确形成的SQL查询只有一个where子句(不包括CTE和子查询)。所以:

select *
from table1 a LEFT OUTER JOIN 
     (select * 
      from table99
      where col = 1
     ) b
     ON a.col1 = b.col1 AND
        a.col2 = b.col2 LEFT OUTER JOIN
     (select *
      from table99
      where col = 2
     ) c
     ON a.col1 = c.col1 AND
        a.col2 = c.col2
WHERE SIGN(a.col3) = 1;

然而,这似乎太复杂了。怎么样?

select *
from table1 a LEFT OUTER JOIN 
     table99 b
     ON a.col1 = b.col1 AND
        a.col2 = b.col2 AND
        b.col = 1 LEFT OUTER JOIN
     table99 c
     ON a.col1 = c.col1 AND
        a.col2 = c.col2 AND
        c.col = 2 
WHERE a.col3 > 0;

答案 1 :(得分:0)

我认为你不需要在这句话ON (a.col1 = b.col1)中使用括号,我同意戈登的意见,你应该梳理你的观点和地点