<b / />ODPS-0130252</b>

更新时间:
复制 MD 格式

This error occurs when a JOIN has no ON condition, causing MaxCompute to attempt a Cartesian product while odps.sql.allow.cartesian is set to false.

Error: cartesian product is not allowed without mapjoin

Error message

ODPS-0130252:[m,n] Cartesian product is not allowed - cartesian product is not allowed without mapjoin

Problem description

A JOIN without an ON condition degrades to a Cartesian product — every row in the first table is paired with every row in the second. When odps.sql.allow.cartesian is false, MaxCompute blocks the operation and returns ODPS-0130252.

Solutions

Add an ON condition to the JOIN. The fix depends on the type of join condition required:

  • Equality condition — add an ON clause using =. If the table is small and a Cartesian product is intentional, set odps.sql.allow.cartesian to true.

  • Non-equality condition — add an ON clause with a mapjoin hint (/*+mapjoin(t1)*/). Do not set odps.sql.allow.cartesian to true for large tables: the Cartesian product causes data explosion.

Query examples

-- Error: Cartesian product is blocked when odps.sql.allow.cartesian=false
odps> SET odps.sql.allow.cartesian=false;
odps> SELECT t1. *
FROM src t1
JOIN src t2;

FAILED: ODPS-0130252:[3,1] Cartesian product is not allowed - cartesian product is not allowed without mapjoin

-- Fix 1: add an equality join condition
odps> SELECT t1. *
FROM src t1
JOIN src t2
ON t1.key = t2.key;

-- Fix 2: add a non-equality join condition with a mapjoin hint
odps> SELECT /*+mapjoin(t1) * / t1.*
FROM src t1
JOIN src t2
ON t1.key > t2.key;