Skip to content

[ASTERIXDB-3021][COMP] Emit cross product warning for implicit joins#49

Open
pineappleBest123 wants to merge 1 commit intoapache:masterfrom
pineappleBest123:fix/asterixdb-3021-cross-product-warning
Open

[ASTERIXDB-3021][COMP] Emit cross product warning for implicit joins#49
pineappleBest123 wants to merge 1 commit intoapache:masterfrom
pineappleBest123:fix/asterixdb-3021-cross-product-warning

Conversation

@pineappleBest123
Copy link
Copy Markdown

Problem

When a SQL++ query uses implicit cross join syntax (e.g., FROM customers, orders
without an explicit join condition), SimpleUnnestToProductRule rewrites the unnest
pipeline into an InnerJoinOperator with a constant TRUE condition. However, no
warning is emitted to alert the user that a cross product is being performed.

By contrast, an explicit JOIN ... ON TRUE already triggers a CROSS_PRODUCT_JOIN
warning through JoinUtils.warnIfCrossProduct(). This inconsistency means users of
the implicit syntax receive no feedback about potentially expensive cross products,
which can lead to unexpected performance issues or incorrect query results.

Changes

JoinUtils.java

  • Changed warnIfCrossProduct() from private static to public static so it can
    be called from outside the class.

SimpleUnnestToProductRule.java

  • Added import for JoinUtils.
  • Added a call to JoinUtils.warnIfCrossProduct() immediately after the cross product
    join operator is constructed, consistent with how explicit joins are handled.

Testing

  • mvn compile passes on the algebricks-rewriter module.
  • mvn test passes (BUILD SUCCESS) on the algebricks-rewriter module.

Related

When a query uses implicit cross join syntax (FROM A, B without a join
condition), SimpleUnnestToProductRule rewrites the unnest pipeline into
an InnerJoinOperator with a constant TRUE condition but never emits a
warning. Explicit JOIN ... ON TRUE already triggers the CROSS_PRODUCT_JOIN
warning via JoinUtils. This change closes that gap.

- Change warnIfCrossProduct() in JoinUtils from private to public
- Call JoinUtils.warnIfCrossProduct() in SimpleUnnestToProductRule
  after the cross product join is constructed
@pineappleBest123 pineappleBest123 marked this pull request as ready for review April 6, 2026 05:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant