配置单元的采样问题

Sampling Issue with hive

"all_members" 是具有 10m 行和 1 列的配置单元中的 table:"membership_nbr"。我想采样 3000 行。这就是我所做的:

hive>create table sample_members as select * from all_members limit 1;
hive>insert overwrite table sample_members select membership_nbr from all_members tablesample(3000 rows);
hive>select count(*) from sample_members;

确定 45000

如果我用300行替换3000行,结果不会改变 我做错了什么吗?

Table 使用 tablesample(3000 rows) 的采样不会从整个 table 中获取 3000 行,而是从每个输入拆分中获取 3000 行。

因此,您的查询可能 运行 15 个映射器。因此,每个映射器将获取 3000 行。总共 3000 * 15 = 45000 行。此外,如果您将 3000 行更改为 300 行,您将在采样后获得 4500 行作为输出。

因此,根据您的要求,您必须提供 tablesample(200 rows)。结果,每个映射器将获取 200 行。最后,15 个映射器将获取 3000 个采样行。

参考以下link各种类型的抽样: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Sampling