Skip to content

Fix #2459 allow overrides for "findAndRerank" command#2460

Merged
tatu-at-datastax merged 32 commits into
mainfrom
tatu/2459-find-and-rerank-override
May 12, 2026
Merged

Fix #2459 allow overrides for "findAndRerank" command#2460
tatu-at-datastax merged 32 commits into
mainfrom
tatu/2459-find-and-rerank-override

Conversation

@tatu-at-datastax
Copy link
Copy Markdown
Contributor

@tatu-at-datastax tatu-at-datastax commented Apr 27, 2026

What this PR does:

Adds ability to provide rerank provider/model overrides for findAndRerank; see #2459 for details.

Which issue(s) this PR fixes:
Fixes #2459

Checklist

  • Changes manually tested
  • Automated Tests added/updated
  • Documentation added/updated
  • CLA Signed: DataStax CLA

@tatu-at-datastax tatu-at-datastax self-assigned this Apr 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 27, 2026

Unit Test Coverage Report

Overall Project 51.62% -0.09% 🍏
Files changed 65.33% 🍏

File Coverage
RequestException.java 100% 🍏
FindAndRerankCommand.java 88.79% 🍏
FindAndRerankOperationBuilder.java 81.97% -2.19% 🍏
CollectionRerankDef.java 52.34% -10.85% 🍏

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 27, 2026

📈 Integration Test Coverage Delta vs Main Branch (dse69-it)

Metric Value
Main Branch 72.66%
This PR 72.78%
Delta 🟢 +0.12%
✅ Coverage improved!

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 27, 2026

Integration Test Coverage Report (dse69-it)

Overall Project 72.78% -0.04% 🍏
Files changed 85.4% 🍏

File Coverage
RequestException.java 100% 🍏
FindAndRerankOperationBuilder.java 84.7% 🍏
FindAndRerankCommand.java 84.11% 🍏
CollectionRerankDef.java 79.12% -5.49% 🍏

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 27, 2026

Integration Test Coverage Report (hcd-it)

Overall Project 74.21% -0.04% 🍏
Files changed 85.4% 🍏

File Coverage
RequestException.java 100% 🍏
FindAndRerankOperationBuilder.java 90.57% 🍏
FindAndRerankCommand.java 85.05% 🍏
CollectionRerankDef.java 79.4% -5.49% 🍏

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

📈 Integration Test Coverage Delta vs Main Branch (hcd-it)

Metric Value
Main Branch 74.10%
This PR 74.21%
Delta 🟢 +0.11%
✅ Coverage improved!

private boolean hasRerankOverride() {
var override =
getOrDefault(command.options(), FindAndRerankCommand.Options::rerankServiceOverride, null);
return override != null && (override.provider() != null || override.modelName() != null);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

there is an isEmpty() on the record, the one on the create collection command is better. we should use that.

@tatu-at-datastax tatu-at-datastax changed the title Implement #2459: allow overrides for "findAndRerank" command Implement #2459 (https://github.com/stargate/data-api/issues/2459): allow overrides for "findAndRerank" command Apr 29, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 29, 2026

📈 Unit Test Coverage Delta vs Main Branch

Metric Value
Main Branch 51.42%
This PR 51.62%
Delta 🟢 +0.20%
✅ Coverage improved!

@tatu-at-datastax
Copy link
Copy Markdown
Contributor Author

Re-prompted:

Requirements changed -- re-plan based on issue https://github.com/stargate/data-api/issues/2459 that this PR is for
...
Review your work
...
Now, can you add one or more unit tests
...
Add one or more ITs as well
...
How about tests with auth override?

@tatu-at-datastax tatu-at-datastax marked this pull request as ready for review May 4, 2026 20:18
@tatu-at-datastax tatu-at-datastax requested a review from a team as a code owner May 4, 2026 20:18
@amorton amorton changed the title Implement #2459 (https://github.com/stargate/data-api/issues/2459): allow overrides for "findAndRerank" command Fix #2459 allow overrides for "findAndRerank" command May 6, 2026
amorton
amorton previously requested changes May 6, 2026
Copy link
Copy Markdown
Contributor

@amorton amorton left a comment

Choose a reason for hiding this comment

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

see comments, too much code duplication going on.

* providers configuration.
*/
// package-private for unit testing
void validateRerankOverride(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

-1 for this function, it is duplicating code and breaking encapsulation.

CollectionRerankDef.fromApiDesc() is the existing funciton we use to validate the reranking provided by the user. It is designed to be called when from create collection. It has parts we can re-use for vliadating the service description, the only difference is that we may use a different error code

e.g. INVALID_CREATE_COLLECTION_OPTIONS for create and RequestException.Code.INVALID_RERANK_OVERRIDE for findAndRerank.

AND theat we may have different rules for the model support.

When we do createCollection the model cannot be DEPRECATED or END_OF_LIFE

When we do findAndReRank using the model from the collection schema it cannot be END_OF_LIFE

when we do findAndRerank using an overload it cannot be DEPRECATED or END_OF_LIFE

Refactor CollectionRerankDef as needed so we can all it to create the CollectionRerankDef for the overridden service def, and centralize error throwing into it for checking the model has the correct support status. We should update all places we check model status to be in this class.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok. Good clarification: I was not sure whether DEPRECATED should be allowed (like from defaults) for overrides or not -- could see either way being possible.

But decision is that overrides are not allowed to use DEPRECATED model.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Refactored to reduce code duplication, centralize handling. Have a look if this makes sense, @amorton.

Comment thread src/main/resources/errors.yaml Outdated
Comment thread src/main/resources/errors.yaml Outdated
Comment thread src/main/resources/errors.yaml Outdated
Comment thread src/main/resources/errors.yaml Outdated
@tatu-at-datastax tatu-at-datastax requested a review from amorton May 11, 2026 20:37
@erichare erichare self-requested a review May 11, 2026 20:41
private CollectionRerankDef.RerankServiceDef resolveRerankServiceDef() {
var rerankOverride =
getOrDefault(command.options(), FindAndRerankCommand.Options::rerankServiceOverride, null);
boolean hasOverride = rerankOverride != null && !rerankOverride.isEmpty();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NIT: I believe this would mean that:

"rerank": {"provider": null, "modelName": null}

Would be treated as hasOverride=FALSE (if i'm thinking of isEmpty() correctly). Just wondering if we want to be more explicit there - that's a case where (potentially) the client might want to provide an override, but made a mistake that led to nulls for the values. In which case, maybe we'd want to either document this, or reject these as invalid?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmmmh. Good question. Let me see.

Copy link
Copy Markdown
Contributor Author

@tatu-at-datastax tatu-at-datastax May 12, 2026

Choose a reason for hiding this comment

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

Ok. Looks like it is rather difficult to both allow { } AND exclude {"provider": null, "modelName": null} -- especially when we are re-using (for better or worse) RerankingServiceDesc for both reranking definition (Collection creation) and for reranking overrides.
But I'll see if I can figure out something. :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@erichare Changed so that Overrides with both { } and {"provider": null, "modelName": null} will now fail: only explicit null (and missing override) are accepted as valid "no overrides".

Copy link
Copy Markdown
Contributor

@erichare erichare left a comment

Choose a reason for hiding this comment

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

LGTM @tatu-at-datastax ! One NIT that i found.

@tatu-at-datastax tatu-at-datastax dismissed amorton’s stale review May 12, 2026 17:43

Aaron indicated review by Eric and/or Hazel sufficient to address concerns.

@tatu-at-datastax
Copy link
Copy Markdown
Contributor Author

LGTM @tatu-at-datastax ! One NIT that i found.

This has now been resolved: no more quiet ignoral of non-null overrides.

@tatu-at-datastax tatu-at-datastax merged commit 554fe9a into main May 12, 2026
3 checks passed
@tatu-at-datastax tatu-at-datastax deleted the tatu/2459-find-and-rerank-override branch May 12, 2026 19:11
@tatu-at-datastax tatu-at-datastax added this to the 1.0.47 milestone May 12, 2026
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.

Allow overriding Reranking options (provider, model, auth, parameters) on per-request basis for findAndRerank command

3 participants