risingwave_frontend/binder/
for_system.rsuse std::sync::Arc;
use risingwave_connector::sink::catalog::SinkCatalog;
use risingwave_sqlparser::ast::ObjectName;
use crate::binder::BindFor;
use crate::catalog::root_catalog::SchemaPath;
use crate::catalog::view_catalog::ViewCatalog;
use crate::error::Result;
use crate::Binder;
pub struct BoundSink {
pub sink_catalog: Arc<SinkCatalog>,
}
pub struct BoundView {
pub view_catalog: Arc<ViewCatalog>,
}
impl Binder {
pub fn bind_sink_by_name(&self, name: ObjectName) -> Result<BoundSink> {
matches!(self.bind_for, BindFor::System);
let (schema_name, sink_name) = Self::resolve_schema_qualified_name(&self.db_name, name)?;
let search_path = SchemaPath::new(
schema_name.as_deref(),
&self.search_path,
&self.auth_context.user_name,
);
let (sink_catalog, _) =
self.catalog
.get_sink_by_name(&self.db_name, search_path, &sink_name)?;
Ok(BoundSink {
sink_catalog: sink_catalog.clone(),
})
}
pub fn bind_view_by_name(&self, name: ObjectName) -> Result<BoundView> {
matches!(self.bind_for, BindFor::System);
let (schema_name, view_name) = Self::resolve_schema_qualified_name(&self.db_name, name)?;
let search_path = SchemaPath::new(
schema_name.as_deref(),
&self.search_path,
&self.auth_context.user_name,
);
let (view_catalog, _) =
self.catalog
.get_view_by_name(&self.db_name, search_path, &view_name)?;
Ok(BoundView {
view_catalog: view_catalog.clone(),
})
}
}