1 回答

TA贡献1825条经验 获得超4个赞
你有几个选择:
加入。 将所有 id 放入 HDFS 中的一个文件中,在文件目录顶部创建表。
CREATE EXTERNAL TABLE table_ids(item_id int)
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n'
STORED AS TEXTFILE
location '/hive/data' --location(directory) in hdfs where the file is
;
select item_name from table a
inner join table_ids b on a.item_id=b.item_id
使用 in_file: 将所有 id 放入文件中,一个 id 连续。
select item_name from table where in_file(item_id, '/tmp/myfilename'); --local file
使用 join with stack,如果它适合内存:
select item_name from table a
inner join
(
select stack(10, --the number of IDs, add more IDs
0, 1, 2, 3, 4, 5, 6, 7, 8, 9) as (item_id)
) b
on a.item_id=b.item_id
添加回答
举报