怎么允许hive.mapred.mode=nonstrict?

How allow hive.mapred.mode=nonstrict?

我正在尝试 运行 这是一个查询,JOIN 没有 ON 属性。

我运行查询如下:

hive -v -f  my_file.hql

我收到这条消息:

In strict mode, cartesian product is not allowed. If you really want to perform the operation, set hive.mapred.mode=nonstrict

我将 hql 文件更新为:
set hive.mapred.mode=nonstrict 在上面。

但后来我收到了这条消息:

SET hive.mapred.mode=nonstrict Query returned non-zero code: 1, cause: Cannot modify hive.mapred.mode at runtime. It is in the listof parameters that can't be modified at runtime

我该如何解决这个问题?

ps:我想做这个cartesian product

我如何实现它?我在哪里可以设置这个变量 hive.mapred.mode 有效?

如您所知,在严格模式下不允许使用笛卡尔积(并且有充分的理由)。在您的用例中,您似乎无权更改这些类型的配置单元设置。

要解决此问题,您可以执行以下操作。 先新建两张表

create table new_1 as SELECT *,1 as join_key from table1;
create table new_2 as SELECT *,1 as join_key2 from table2;

然后在此 join_key 上加入这些表。结果将是笛卡尔积,因为它将匹配 table1 的每一行与 table2.

的每一行
select * from new_1 join new_2 on join_key=join_key2

刚刚发现使用 --hiveconf 解决了问题:

hive -v -f  my_file.hql --hiveconf hive.mapred.mode=nonstrict

将允许 nonstrict mode 专门针对此查询。