You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@sedona.apache.org by "paleolimbot (via GitHub)" <gi...@apache.org> on 2026/10/14 21:44:00 UTC

[PR] feat(rust/sedona): expose catalog table lookup [sedona-db]

paleolimbot opened a new pull request, #1444:
URL: https://github.com/apache/sedona-db/pull/1444

   Exposes SedonaCatalogRegistry and adds catalog-aware table() and table_provider() methods to SedonaContext. Centralizes SQL and wrapper table resolution on the registry so foreign-catalog precedence and built-in fallback stay consistent. Adds unit and downstream visibility coverage.\n\ncloses #1434


-- 
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: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(rust/sedona): expose catalog table lookup [sedona-db]

Posted by "paleolimbot (via GitHub)" <gi...@apache.org>.
paleolimbot merged PR #1444:
URL: https://github.com/apache/sedona-db/pull/1444


-- 
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: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(rust/sedona): expose catalog table lookup [sedona-db]

Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu commented on code in PR #1444:
URL: https://github.com/apache/sedona-db/pull/1444#discussion_r4292294669


##########
rust/sedona/src/catalog.rs:
##########
@@ -66,6 +66,40 @@ impl SedonaCatalogRegistry {
         *foreign = foreign.iter().cloned().chain([catalogs]).collect();
     }
 
+    /// Look up a table using the same catalog precedence as Sedona SQL.
+    ///
+    /// Bare and partially qualified references are resolved against the
+    /// session's default catalog and schema. Foreign catalogs are searched
+    /// newest-first before falling back to DataFusion's built-in catalogs.
+    pub async fn table(
+        &self,
+        table_ref: impl Into<TableReference>,
+    ) -> Result<Option<Arc<dyn TableProvider>>> {
+        let state = self
+            .state
+            .upgrade()
+            .ok_or_else(|| plan_datafusion_err!("session state is no longer available"))?
+            .read()
+            .clone();
+        let defaults = &state.config_options().catalog;
+        let resolved = table_ref
+            .into()
+            .resolve(&defaults.default_catalog, &defaults.default_schema);
+        if let Some(catalog) = self.foreign_catalog(&resolved.catalog).await? {
+            return catalog
+                .table(&[&resolved.catalog, &resolved.schema, &resolved.table])
+                .await;
+        }
+
+        let Some(catalog) = self.catalog(&resolved.catalog) else {
+            return Ok(None);
+        };
+        let Some(schema) = catalog.schema(&resolved.schema) else {

Review Comment:
   Could we keep `state.schema_for_ref()` for the built-in fallback? `information_schema` is created there, so looking it up through `catalog.schema()` misses it.
   
   This reproduces without a foreign catalog:
   
   ```rust
   let ctx = SedonaContext::new();
   ctx.ctx.state_ref().write().config_mut().options_mut()
       .catalog.information_schema = true;
   ctx.ctx.table("information_schema.tables").await?; // succeeds
   ctx.table("information_schema.tables").await?;     // No table named 'tables'
   ```
   
   With the existing `test_context()` foreign catalog registered, `SELECT table_name FROM information_schema.tables` also fails through `ctx.sql()`. I ran that case on both commits: it passes on the base and fails here.



-- 
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: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org