Skip to content

Commit c176352

Browse files
authored
[ENH] Facilitate Where and Rank construction (#5659)
## Description of changes _Summarize the changes made by this PR._ - Improvements & Bug fixes - Facilitate `Where` and `Rank` construction with operator overrides and builder pattern - Cleanups - Drop default KNN limit from 128 to 16, which is consistent with python client - Update type of `RankExpr::Knn.key` to `Key` - New functionality - N/A ## Test plan _How are these changes tested?_ - [ ] Tests pass locally with `pytest` for python, `yarn test` for js, `cargo test` for rust ## Migration plan _Are there any migrations, or any forwards/backwards compatibility changes needed in order to make sure this change deploys reliably?_ ## Observability plan _What is the plan to instrument and monitor this change?_ ## Documentation Changes _Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the [docs section](https://github.com/chroma-core/chroma/tree/main/docs/docs.trychroma.com)?_
1 parent c6d6c8d commit c176352

File tree

6 files changed

+667
-22
lines changed

6 files changed

+667
-22
lines changed

rust/frontend/src/impls/service_based_frontend.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1723,7 +1723,10 @@ impl ServiceBasedFrontend {
17231723
let knn_queries = rank_expr.knn_queries();
17241724
for knn_query in knn_queries {
17251725
schema
1726-
.is_knn_key_indexing_enabled(&knn_query.key, &knn_query.query)
1726+
.is_knn_key_indexing_enabled(
1727+
&knn_query.key.to_string(),
1728+
&knn_query.query,
1729+
)
17271730
.map_err(|err| {
17281731
QueryError::Other(Box::new(err) as Box<dyn ChromaError>)
17291732
})?;

rust/types/src/execution/error.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,18 @@ pub enum QueryConversionError {
2222
Where(#[from] WhereConversionError),
2323
#[error("Error parsing scan: {0}")]
2424
Scan(#[from] ScanToProtoError),
25+
#[error("Validation error: {0}")]
26+
Validation(String),
2527
}
2628

2729
impl QueryConversionError {
2830
pub fn field(name: impl ToString) -> Self {
2931
Self::Field(name.to_string())
3032
}
33+
34+
pub fn validation(msg: impl ToString) -> Self {
35+
Self::Validation(msg.to_string())
36+
}
3137
}
3238

3339
impl From<QueryConversionError> for Status {

0 commit comments

Comments
 (0)