假设我希望使用JOIN过滤掉一个带有LATERAL VIEW的巨大表格。例如:
SELECT things.*
FROM a_few_objects fo join
(SELECT an_id,
object.id as object_id,
object.big_thing
FROM big_table
LATERAL VIEW EXPLODE(outer_things) ot AS outer_thing
LATERAL VIEW EXPLODE(objects) o AS object) things
ON fo.objectid = things.object_id
是否有更有效的方法来实例化“事物”子查询(我认为在磁盘上放置一个巨大的表)?
我可以将a_few_objects的行放在内部查询的WHERE子句中,但是我想在Hive中指定a_few_objects,所以我不必一直更改查询。
如果我将连接放在子查询中,Hive就会感到困惑。我正在使用Hive 0.13。
答案 0 :(得分:0)
Hive 0.13有CTE(公用表格式)。
WITH q1 AS (
SELECT an_id,
object.id AS object_id,
object.big_thing
FROM big_table
LATERAL VIEW EXPLODE(outer_things) ot AS outer_thing
LATERAL VIEW EXPLODE(objects) o AS object)
SELECT *
FROM q1
JOIN big_table fo
ON q1.objectid = fo.object_id