@@ -66,6 +66,9 @@ pub struct DataSource {
6666 pub schema : Option < HashMap < String , String > > ,
6767 /// Optional format-specific options
6868 pub options : Option < HashMap < String , String > > ,
69+ /// Registration hierarchy level for database sources (default: table)
70+ #[ serde( default ) ]
71+ pub hierarchy_level : HierarchyLevel ,
6972 /// Access mode: read_only (default) or read_write
7073 #[ serde( default ) ]
7174 pub access_mode : AccessMode ,
@@ -89,6 +92,24 @@ pub enum DataSourceType {
8992 Lance ,
9093}
9194
95+ /// Registration hierarchy level for sources that can expose multiple objects.
96+ #[ derive( Debug , Clone , Deserialize , Serialize , Hash , PartialEq , Eq , Default ) ]
97+ #[ serde( rename_all = "lowercase" ) ]
98+ pub enum HierarchyLevel {
99+ #[ default]
100+ Table ,
101+ Catalog ,
102+ }
103+
104+ impl HierarchyLevel {
105+ fn as_str ( & self ) -> & ' static str {
106+ match self {
107+ Self :: Table => "table" ,
108+ Self :: Catalog => "catalog" ,
109+ }
110+ }
111+ }
112+
92113/// Context configuration file structure
93114#[ derive( Debug , Deserialize ) ]
94115struct ContextConfig {
@@ -743,12 +764,19 @@ async fn register_data_source(
743764 source. options
744765 ) ;
745766
746- // Register PostgreSQL table using the sqlx-based provider
767+ // Forward top-level hierarchy_level via options for provider handling.
768+ let mut postgres_options = source. options . clone ( ) . unwrap_or_default ( ) ;
769+ postgres_options. insert (
770+ "hierarchy_level" . to_string ( ) ,
771+ source. hierarchy_level . as_str ( ) . to_string ( ) ,
772+ ) ;
773+
774+ // Register PostgreSQL table(s) using the sqlx-based provider
747775 sources:: providers:: sqlx:: postgres:: register_postgres_tables (
748776 session_ctx,
749777 & source. name ,
750778 connection_string,
751- source . options . as_ref ( ) ,
779+ Some ( & postgres_options ) ,
752780 source. access_mode . is_read_write ( ) ,
753781 )
754782 . await
0 commit comments