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

VReplication: Support for BETWEEN/NOT BETWEEN filter in VStream #17721

Merged
merged 13 commits into from
Feb 19, 2025

Conversation

beingnoble03
Copy link
Member

@beingnoble03 beingnoble03 commented Feb 8, 2025

Description

This PR adds support for BETWEEN filter in VStream.

Related Issue(s)

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Deployment Notes

Signed-off-by: Noble Mittal <noblemittal@outlook.com>
Copy link
Contributor

vitess-bot bot commented Feb 8, 2025

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@vitess-bot vitess-bot bot added NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsWebsiteDocsUpdate What it says labels Feb 8, 2025
@github-actions github-actions bot added this to the v22.0.0 milestone Feb 8, 2025
@beingnoble03 beingnoble03 added Type: Enhancement Logical improvement (somewhere between a bug and feature) Component: VReplication and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Feb 8, 2025
Copy link

codecov bot commented Feb 8, 2025

Codecov Report

Attention: Patch coverage is 78.04878% with 18 lines in your changes missing coverage. Please review.

Project coverage is 67.45%. Comparing base (4c27ea8) to head (2a71721).
Report is 28 commits behind head on main.

Files with missing lines Patch % Lines
.../vt/vttablet/tabletserver/vstreamer/planbuilder.go 78.04% 18 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17721      +/-   ##
==========================================
- Coverage   67.97%   67.45%   -0.52%     
==========================================
  Files        1586     1592       +6     
  Lines      255195   258145    +2950     
==========================================
+ Hits       173468   174142     +674     
- Misses      81727    84003    +2276     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Noble Mittal <noblemittal@outlook.com>
@beingnoble03
Copy link
Member Author

Tested this locally using the example local cluster.

Signed-off-by: Noble Mittal <noblemittal@outlook.com>
Signed-off-by: Noble Mittal <noblemittal@outlook.com>
Signed-off-by: Noble Mittal <noblemittal@outlook.com>
Signed-off-by: Noble Mittal <noblemittal@outlook.com>
Signed-off-by: Noble Mittal <noblemittal@outlook.com>
Copy link
Contributor

@mattlord mattlord left a comment

Choose a reason for hiding this comment

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

This is looking really good. Nice work on this so far!

Can you please look at the TestVStreamPushdownFilters endtoend test in go/test/endtoend/vreplication/vstream_test.go? We should add to that (additional test cases) or mimic it. This way we have an end to end test that covers both the copy phase (rowstreamer filtering) and the running phase (vstreamer filtering).

Please let me know if I can be of any help!

Signed-off-by: Noble Mittal <noblemittal@outlook.com>
@rohit-nayak-ps
Copy link
Contributor

@beingnoble03 let's update the website docs for this: https://vitess.io/docs/22.0/reference/vreplication/materialize/ (https://github.com/vitessio/website). Also check if we need to update that doc with the newly supported filter predicates since the docs were last updated.

Signed-off-by: Noble Mittal <noblemittal@outlook.com>
@rohit-nayak-ps
Copy link
Contributor

This is looking really good. Nice work on this so far!

Can you please look at the TestVStreamPushdownFilters endtoend test in go/test/endtoend/vreplication/vstream_test.go? We should add to that (additional test cases) or mimic it. This way we have an end to end test that covers both the copy phase (rowstreamer filtering) and the running phase (vstreamer filtering).

Please let me know if I can be of any help!

I see there is an additional e2e test added now just for the between filter and pushdown functionality. We should be testing this in unit tests and not adding a full new e2e test for each type of filter. It will become very expensive in terms of CI times. Is there already a unit test what was added for the validating pushdown filters? If so we can add between to that. If not is can we create one?

Signed-off-by: Rohit Nayak <rohit@planetscale.com>
@rohit-nayak-ps
Copy link
Contributor

@beingnoble03 I was testing locally and was trying a more complex filter expression and then thought it would be useful to add permanently to the existing ones. So took the liberty of pushing it to the PR.

@beingnoble03
Copy link
Member Author

I see there is an additional e2e test added now just for the between filter and pushdown functionality. We should be testing this in unit tests and not adding a full new e2e test for each type of filter. It will become very expensive in terms of CI times. Is there already a unit test what was added for the validating pushdown filters? If so we can add between to that. If not is can we create one?

Thanks Rohit for the additional unit test. Unit tests for pushdown filters(for the case of BETWEEN) were added in this commit: 8c477c7

@rohit-nayak-ps
Copy link
Contributor

I see there is an additional e2e test added now just for the between filter and pushdown functionality. We should be testing this in unit tests and not adding a full new e2e test for each type of filter. It will become very expensive in terms of CI times. Is there already a unit test what was added for the validating pushdown filters? If so we can add between to that. If not is can we create one?

Thanks Rohit for the additional unit test. Unit tests for pushdown filters(for the case of BETWEEN) were added in this commit: 8c477c7

Sorry, had missed that unit test change.

@mattlord since unit tests cover it do we need a new e2e test just for this filter? I would suggest removing the new one that was created in this PR .

Copy link
Contributor

@rohit-nayak-ps rohit-nayak-ps left a comment

Choose a reason for hiding this comment

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

Other than a minor refactor suggestion and the issue about the extra e2e tests being discussed in comments, this looks good.

@@ -570,6 +594,46 @@ func (plan *Plan) appendTupleFilter(values sqlparser.ValTuple, opcode Opcode, co
return nil
}

func (plan *Plan) getFromAndToEvalResult(expr *sqlparser.BetweenExpr) (*evalengine.EvalResult, *evalengine.EvalResult, error) {
// From value.
fromVal, ok := expr.From.(*sqlparser.Literal)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please extract the two identical code blocks for from and to.

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

Signed-off-by: Noble Mittal <noblemittal@outlook.com>
… between-op-vrep

Signed-off-by: Noble Mittal <noblemittal@outlook.com>
Copy link
Contributor

@mattlord mattlord left a comment

Choose a reason for hiding this comment

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

Excellent work on this @beingnoble03 !

@mattlord since unit tests cover it do we need a new e2e test just for this filter? I would suggest removing the new one that was created in this PR .

Yeah, now that I look at the new tests... I don't think they really give us anything more than we have with the existing TestVStreamPushdownFilters test and the new unit tests. @beingnoble03 , I'm sorry, but do you mind keeping the minor refactor you did in the e2e test file and removing the two new tests?

Signed-off-by: Noble Mittal <noblemittal@outlook.com>
@beingnoble03
Copy link
Member Author

@mattlord done.

@mattlord mattlord merged commit 83e2a4f into vitessio:main Feb 19, 2025
103 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: VReplication Type: Enhancement Logical improvement (somewhere between a bug and feature)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants