Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add index join conditions #12461

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

xiaoxmeng
Copy link
Contributor

Summary:
Change index join condition from SQL expression to a more strict condition structure
to present in query plan node

Differential Revision: D70233337

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 27, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D70233337

Copy link

netlify bot commented Feb 27, 2025

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit c856260
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/67c15927bf920900086049b4

@@ -1768,6 +1768,74 @@ class MergeJoinNode : public AbstractJoinNode {
static PlanNodePtr create(const folly::dynamic& obj, void* context);
};

struct IndexJoinCondition;
using IndexJoinConditionPtr = std::shared_ptr<IndexJoinCondition>;
struct IndexJoinCondition : public ISerializable {
Copy link
Contributor

@zhztheplayer zhztheplayer Feb 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just my 2 cents: Does IndexJoinCondition have to extend ISerializable given the subclasses are unlikely using name JSON field as type annotations?

xiaoxmeng added a commit to xiaoxmeng/velox that referenced this pull request Feb 27, 2025
Summary:

Change index join condition from SQL expression to a more strict condition structure
to present in query plan node

Differential Revision: D70233337
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D70233337

xiaoxmeng added a commit to xiaoxmeng/velox that referenced this pull request Feb 27, 2025
Summary:

Change index join condition from SQL expression to a more strict condition structure
to present in query plan node

Differential Revision: D70233337
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D70233337

Copy link
Contributor

@mbasmanova mbasmanova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xiaoxmeng Meng, would you update PR description to explain what kinds of conditions are supported for index join?

@@ -584,8 +588,8 @@ class Connector {
/// Here,
/// - 'inputType' is ROW{t.sid, t.event_list}
/// - 'numJoinKeys' is 1 since only t.sid is used in join equi-clauses.
/// - 'joinConditions' is list of one expression: contains(t.event_list,
/// u.event_type)
/// - 'joinConditions' is list of one join condition: contains(t.event_list,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: "is list of one join condition" - why would we need a list of one?

Copy link
Contributor Author

@xiaoxmeng xiaoxmeng Feb 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to describe a particular example. The join conditions is a list of conditions and in above example, there is only one condition. I rephrase a bit to make it clear.


IndexJoinCondition(FieldAccessTypedExprPtr _key) : key(std::move(_key)) {}

folly::dynamic serialize() const override;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we leave this not implemented?

TypedExprPtr upper;

BetweenIndexJoinCondition(
FieldAccessTypedExprPtr key,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_key

/// @param joinType Type of the join supported: inner, left.
///
/// See hashJoin method for the description of the other parameters.
PlanBuilder& indexLookupJoin(
const std::vector<std::string>& leftKeys,
const std::vector<std::string>& rightKeys,
const core::TableScanNodePtr& right,
const std::vector<std::string>& joinCondition,
const std::vector<IndexJoinCondition>& joinConditions,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep this as a SQL string as it is easier to use? Let's document what SQL strings are supported.

Copy link
Contributor Author

@xiaoxmeng xiaoxmeng Feb 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

return isConstant;
}

void addBetweenCondition(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you ad comments to explain what these functions do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment added.

xiaoxmeng added a commit to xiaoxmeng/velox that referenced this pull request Feb 27, 2025
Summary:

Change index join condition from SQL expression to a more strict condition structure
to present in query plan node

Differential Revision: D70233337
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D70233337

xiaoxmeng added a commit to xiaoxmeng/velox that referenced this pull request Feb 27, 2025
Summary:
Pull Request resolved: facebookincubator#12461

Change index join condition from SQL expression to a more strict condition structure
to present in query plan node

Differential Revision: D70233337
xiaoxmeng added a commit to xiaoxmeng/velox that referenced this pull request Feb 27, 2025
Summary:

Change index join condition from SQL expression to a more strict condition structure
to present in query plan node

Differential Revision: D70233337
std::move(keyColumnExpr), std::move(lowerExpr), std::move(upperExpr));
}

VELOX_USER_FAIL("Invalid index join condition: {}", joinCondition);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you update the API comments to clarify what are supported conditions and enhance this error message to include that as well?

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D70233337

xiaoxmeng added a commit to xiaoxmeng/velox that referenced this pull request Feb 27, 2025
Summary:
Pull Request resolved: facebookincubator#12461

Change index join condition from SQL expression to a more strict condition structure
to present in query plan node

Differential Revision: D70233337
xiaoxmeng added a commit to xiaoxmeng/velox that referenced this pull request Feb 27, 2025
Summary:

Change index join condition from SQL expression to a more strict condition structure
to present in query plan node

Differential Revision: D70233337
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D70233337

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D70233337

xiaoxmeng added a commit to xiaoxmeng/velox that referenced this pull request Feb 27, 2025
Summary:

Change index join condition from SQL expression to a more strict condition structure
to present in query plan node

Differential Revision: D70233337
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D70233337

xiaoxmeng added a commit to xiaoxmeng/velox that referenced this pull request Feb 28, 2025
Summary:

Change index join condition from SQL expression to a more strict condition structure
to present in query plan node

Reviewed By: wenqiwooo, zacw7

Differential Revision: D70233337
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D70233337

xiaoxmeng added a commit to xiaoxmeng/velox that referenced this pull request Feb 28, 2025
Summary:

Change index join condition from SQL expression to a more strict condition structure
to present in query plan node

Reviewed By: wenqiwooo, zacw7

Differential Revision: D70233337
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D70233337

xiaoxmeng added a commit to xiaoxmeng/velox that referenced this pull request Feb 28, 2025
Summary:

Change index join condition from SQL expression to a more strict condition structure
to present in query plan node

Reviewed By: wenqiwooo, zacw7

Differential Revision: D70233337
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D70233337

xiaoxmeng added a commit to xiaoxmeng/velox that referenced this pull request Feb 28, 2025
Summary:
Pull Request resolved: facebookincubator#12461

Change index join condition from SQL expression to a more strict condition structure
to present in query plan node

Reviewed By: wenqiwooo, zacw7

Differential Revision: D70233337
xiaoxmeng added a commit to xiaoxmeng/velox that referenced this pull request Feb 28, 2025
Summary:

Change index join condition from SQL expression to a more strict condition structure
to present in query plan node

Reviewed By: wenqiwooo, zacw7

Differential Revision: D70233337
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D70233337

xiaoxmeng added a commit to xiaoxmeng/velox that referenced this pull request Feb 28, 2025
Summary:

Change index join condition from SQL expression to a more strict condition structure
to present in query plan node

Reviewed By: wenqiwooo, zacw7

Differential Revision: D70233337
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D70233337

xiaoxmeng added a commit to xiaoxmeng/velox that referenced this pull request Feb 28, 2025
Summary:

Change index join condition from SQL expression to a more strict condition structure
to present in query plan node

Reviewed By: wenqiwooo, zacw7

Differential Revision: D70233337
xiaoxmeng added a commit to xiaoxmeng/velox that referenced this pull request Feb 28, 2025
Summary:

Change index join condition from SQL expression to a more strict condition structure
to present in query plan node

Reviewed By: wenqiwooo, zacw7

Differential Revision: D70233337
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D70233337

Summary:
Pull Request resolved: facebookincubator#12461

Change index join condition from SQL expression to a more strict condition structure
to present in query plan node

Reviewed By: wenqiwooo, zacw7

Differential Revision: D70233337
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D70233337

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants