You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cosmos: Allow the Query Pipeline to return an alternative query to execute in each request (#3166)
For Hybrid Search, as well as ReadMany support, the query engine will
need to direct the SDK to issue **multiple different queries**. However,
the Rust SDK's query executor expects to be able to replay the original
query on each request. This PR changes that expectation to allow (but
not require) each Query Request coming from the pipeline to provide an
alternate query. When an alternate query is provided, the pipeline can
also indicate if the parameters from the original query should be sent.
Often, the alternate query does NOT use the parameters, but in some
circumstances (hybrid search) it will.
There are also some small fixes for doc tests and error checking in the
engine-less cross-partition query tests. Not sure why these are coming
up here and not in `main`.
Copy file name to clipboardExpand all lines: sdk/cosmos/azure_data_cosmos/CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,8 @@
4
4
5
5
### Features Added
6
6
7
+
- Adjusted the query engine abstraction to support future enhancements and optimizations. ([#3166](https://github.com/Azure/azure-sdk-for-rust/pull/3166))
Copy file name to clipboardExpand all lines: sdk/cosmos/azure_data_cosmos/src/query/engine.rs
+38-1Lines changed: 38 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -3,14 +3,42 @@ pub struct QueryRequest {
3
3
/// The ID of the partition key range to query.
4
4
pubpartition_key_range_id:String,
5
5
6
+
/// The index of this request, within the partition key range.
7
+
///
8
+
/// This value will always increase for subsequent requests for the same partition key range.
9
+
/// It must be provided back to the pipeline when providing data, so that the pipeline can ensure that data is provided in order.
10
+
pubindex:usize,
11
+
6
12
/// The continuation to use, if any.
7
13
pubcontinuation:Option<String>,
14
+
15
+
/// The query to execute for this partition key range, if different from the original query.
16
+
pubquery:Option<String>,
17
+
18
+
/// If a query is specified, this flag indicates if the query parameters should be included with that query.
19
+
///
20
+
/// Sometimes, when an override query is specified, it differs in structure from the original query, and the original parameters are not valid.
21
+
pubinclude_parameters:bool,
22
+
23
+
/// If specified, indicates that the SDK should IMMEDIATELY drain all remaining results from this partition key range, following continuation tokens, until no more results are available.
24
+
/// All the data from this partition key range should be provided BEFORE any new items will be made available.
25
+
///
26
+
/// This allows engines to optimize for non-streaming scenarios, where the entire result set must be provided to the engine before it can make progress.
27
+
pubdrain:bool,
8
28
}
9
29
10
30
/// The request of a single-partition query for a specific partition key range.
11
31
pubstructQueryResult<'a>{
32
+
/// The ID of the partition key range that was queried.
12
33
pubpartition_key_range_id:&'astr,
34
+
35
+
/// The index of the [`QueryRequest`] that generated this result.
36
+
pubrequest_index:usize,
37
+
38
+
/// The continuation token to be used for the next request, if any.
/// Data from multiple partition ranges may be provided at once.
71
+
/// However, each page of data must be provided in order.
72
+
/// So, for any given partition key range, page n's results must be earlier in the `data` vector than page n+1's results.
73
+
/// Data from different partition key ranges may be interleaved, as long as each partition key range's pages are in order.
74
+
///
75
+
/// The pipeline will use the [`QueryResult::request_index`] field to validate this.
76
+
///
77
+
/// When providing data from a draining request (i.e. a request with `drain = true`), all pages for that draining request can share the same [`QueryResult::request_index`].
Copy file name to clipboardExpand all lines: sdk/cosmos/azure_data_cosmos/src/query/mod.rs
+42Lines changed: 42 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -108,6 +108,15 @@ impl Query {
108
108
Ok(self)
109
109
}
110
110
111
+
/// Replaces all parameters in this [`Query`] instance with the parameters from another [`Query`] instance, and returns it.
112
+
///
113
+
/// Since the parameters in the other query are already serialized, this method cannot fail.
114
+
#[cfg(feature = "preview_query_engine")]// Crate-private for now, and thus only in the preview_query_engine feature (which is the only place it's used).
0 commit comments