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

Changed SearchAfter field type to FieldValue instead of String #769

Merged
merged 5 commits into from
Dec 26, 2023

Conversation

channel-dante
Copy link
Contributor

Description

  • Changed SearchAfter of SearchRequest type to FieldValue instead of String
  • Written in the same way as other models receive various types

Issues Resolved

#755

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@channel-dante channel-dante changed the title Changed SearchAfter of SearchRequest type to FieldValue instead of St… Changed SearchAfter field type to FieldValue instead of String Dec 13, 2023
Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

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

So, existing code that was .searchAfter("string") worked, right? Therefore after this change that code would no longer build?

This would make the change backwards incompatible, which would require a major version bump. Can we implement it in a way that doesn't break backwards compat?

CHANGELOG.md Outdated
@@ -42,6 +42,7 @@ This section is for maintaining a changelog for all breaking changes for the cli
### Dependencies

### Changed
- Changed SearchAfter of SearchRequest type to FieldValue instead of String
Copy link
Member

Choose a reason for hiding this comment

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

Add a link to the PR like other line-items.

Copy link
Contributor Author

@channel-dante channel-dante Dec 14, 2023

Choose a reason for hiding this comment

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

Since overload cannot distinguish between List<FieldValue> and List<String>, I think you have no choice but to make backwards incompatible. It can be implemented as shown below, but it seems that there will be a side effect of allowing unintended Object type.

And by adding this overloading, the issue of not being able to find the targeted method in the deserializer also occurs.

image image

Copy link
Member

Choose a reason for hiding this comment

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

@reta any ideas what's best here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@reta Can you give me any comment here? 🥲

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry folks, overlooked this pull request, we could add the varargs overload:

public final Builder searchAfter(String value, String... values) {

but indeed due to erasure, we may only keep List<String> for backward compatibility in 2.x (and convert it to FielValue internally) but use List<FieldValue> in 3.x, what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@reta Converting to FieldValue only internally doesn't seem to make sense. So, how about applying this PR to 3.x? If I have to do that, should I move the branch to 3.x?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure @channel-dante , the main is 3.x so no need to change anything

@dblock
Copy link
Member

dblock commented Dec 21, 2023

I think this PR looks good, it's a breaking change for 3.0. For a backport to 2.x your plan LGTM.

How about we start introducing an UPGRADING.md that describes all things that change in a way that is backwards incompatible? @channel-dante Care to add an UPGRADING.md in the same format as https://github.com/opensearch-project/opensearch-py/blob/main/UPGRADING.md? And rebase.

Thank you for hanging in here with us!

UPGRADING.md Outdated
## [UPGRADING 2.x to 3.0]
### SearchAfter of SearchRequest type
- Changed SearchAfter of SearchRequest type to FieldValue instead of String
- Consider using `FieldValue.of("")` to make string type values compatible.
Copy link
Collaborator

@reta reta Dec 22, 2023

Choose a reason for hiding this comment

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

Suggested change
- Consider using `FieldValue.of("")` to make string type values compatible.
- Consider using `FieldValue.of` to make string type values compatible.

reta
reta previously approved these changes Dec 22, 2023
UPGRADING.md Outdated Show resolved Hide resolved
@channel-dante
Copy link
Contributor Author

@dblock Can you please confirm about this pr?

@dblock dblock merged commit 3738026 into opensearch-project:main Dec 26, 2023
47 checks passed
@dblock
Copy link
Member

dblock commented Dec 26, 2023

Merged, thanks @channel-dante. Want to do a manual backport for a backwards compatible variation?

@channel-dante
Copy link
Contributor Author

@dblock I didn't understand what kind of work it was. Can you give a little explanation?

@dblock
Copy link
Member

dblock commented Dec 27, 2023

Nevermind, I re-read the comments on bcw above. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v3.0.0 Issues and PRs related to version v3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants