Hive执行SQL提示SemanticException TOK_ALLCOLREF is not supported in current context的问题

错误原因,执行distinct *时报错,hive不支持。

原SQL如下:

 SELECT
        DISTINCT *
    FROM
        ( SELECT
            test1.fkd1512d23 AS fkb80bb774 ,
            test1.fk89a97c52 AS fk919b1d80 ,
            test1.fk252c0958 AS fk418c5509 ,
            test1.fk8688024b AS fkbb5855f0 
        FROM
            `test1` 
        UNION
        ALL SELECT
            test2.fkf23ff905 AS fkb80bb774 ,
            test2.fk4dee5147 AS fk919b1d80 ,
            test2.fkc812e4cc AS fk418c5509 ,
            test2.fka2d83dc0 AS fkbb5855f0 
        FROM
            `test2` 
    ) AS fk3c92fb73

修改为:

 SELECT
        DISTINCT fkb80bb774, fk919b1d80, fk418c5509, fkbb5855f0
    FROM
        ( SELECT
            test1.fkd1512d23 AS fkb80bb774 ,
            test1.fk89a97c52 AS fk919b1d80 ,
            test1.fk252c0958 AS fk418c5509 ,
            test1.fk8688024b AS fkbb5855f0 
        FROM
            `test1` 
        UNION
        ALL SELECT
            test2.fkf23ff905 AS fkb80bb774 ,
            test2.fk4dee5147 AS fk919b1d80 ,
            test2.fkc812e4cc AS fk418c5509 ,
            test2.fka2d83dc0 AS fkbb5855f0 
        FROM
            `test2` 
    ) AS fk3c92fb73

即可。