shyjsarah commented on code in PR #760:
URL: https://github.com/apache/paimon-rust/pull/760#discussion_r3901354008


##########
crates/paimon/src/table/vector_search_builder.rs:
##########
@@ -1217,11 +1270,30 @@ impl<'a> BatchVectorSearchBuilder<'a> {
     pub async fn execute(&self) -> crate::Result<Vec<SearchResult>> {
         let timing_enabled = vector_search_timing_enabled();
         let total_start = timing_enabled.then(Instant::now);
+        if let Some(prepared) = &self.prepared_filter {
+            if !same_vector_search_table(self.table, prepared.table()) {
+                return Err(crate::Error::DataInvalid {
+                    message: format!(
+                        "Prepared vector search filter belongs to a different 
table: builder target is '{}@{}', prepared filter target is '{}@{}'",
+                        self.table.location(),
+                        self.table.branch(),
+                        prepared.table().location(),
+                        prepared.table().branch(),
+                    ),
+                    source: None,
+                });
+            }
+        }
         // Fail closed: like `execute_read` and the single-query builder, this
         // returns data-derived row ids/scores outside `TableScan`/`TableRead`,
         // so it must refuse a `query-auth.enabled` table before any fast path
         // (an empty snapshot would otherwise return empty results and bypass 
it).
-        let core = CoreOptions::new(self.table.schema().options());
+        let execution_table = self
+            .prepared_filter
+            .as_ref()
+            .map(PreparedVectorSearchFilter::table)
+            .unwrap_or(self.table);
+        let core = CoreOptions::new(execution_table.schema().options());

Review Comment:
   Fixed in `5b67f99`. `BatchVectorSearchBuilder::execute` now authorizes the 
live builder target before inspecting or switching to a prepared snapshot, so 
current auth/type policy remains authoritative even when the prepared value 
carries older options. The pinned execution table is still authorized 
separately as defense in depth. Added the public-API stale-prepared -> 
auth-enabled-target regression; it failed before the fix with an empty 
successful result and now returns the expected `query-auth.enabled` 
`Unsupported` error. Paimon lib tests (2527 passed, 2 ignored), DataFusion 
lateral tests, formatting, and clippy all pass.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to