HiveQL中的别名

时间:2014-11-10 02:00:39

标签: hive hiveql

我正在调查this示例

SELECT u.id, actions.date
FROM (
    SELECT av.uid AS uid
    FROM action_video av
    WHERE av.date = '2008-06-03'
    UNION ALL
    SELECT ac.uid AS uid
    FROM action_comment ac
    WHERE ac.date = '2008-06-03'
 ) actions JOIN users u ON (u.id = actions.uid)

我猜avacu是别名。如果是这样,为什么不需要AS

1 个答案:

答案 0 :(得分:0)

没有强制要求在别名中使用。如果表在FROM子句中出现多次,则需要表别名以使它们保持不同

SELECT u.id, actions.date
FROM (
    SELECT av.uid  uid
    FROM action_video av
    WHERE av.date = '2008-06-03'
    UNION ALL
    SELECT ac.uid AS uid
    FROM action_comment ac
    WHERE ac.date = '2008-06-03'
 ) actions JOIN users u ON (u.id = actions.uid)