Skip to content

Commit eca949e

Browse files
add catalog provider
1 parent 2c5d520 commit eca949e

3 files changed

Lines changed: 334 additions & 53 deletions

File tree

crates/cli/src/main.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ struct LocalDataSource {
8181
path: Option<String>,
8282
connection_string: Option<String>,
8383
options: Option<HashMap<String, String>>,
84+
hierarchy_level: Option<String>,
8485
}
8586

8687
fn resolve_ctx_path(override_path: Option<PathBuf>) -> Result<PathBuf> {
@@ -498,11 +499,19 @@ async fn register_source(
498499
source.name
499500
)
500501
})?;
502+
let mut postgres_options = source.options.clone().unwrap_or_default();
503+
postgres_options.insert(
504+
"hierarchy_level".to_string(),
505+
source
506+
.hierarchy_level
507+
.clone()
508+
.unwrap_or_else(|| "table".to_string()),
509+
);
501510
register_postgres_tables(
502511
session_ctx,
503512
&source.name,
504513
conn_str,
505-
source.options.as_ref(),
514+
Some(&postgres_options),
506515
false,
507516
)
508517
.await

crates/server/src/config.rs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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)]
94115
struct 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

Comments
 (0)