risingwave_frontend/binder/
for_system.rs1use std::sync::Arc;
16
17use risingwave_connector::sink::catalog::SinkCatalog;
18use risingwave_sqlparser::ast::ObjectName;
19
20use crate::Binder;
21use crate::binder::BindFor;
22use crate::catalog::root_catalog::SchemaPath;
23use crate::catalog::view_catalog::ViewCatalog;
24use crate::error::Result;
25
26pub struct BoundSink {
27 pub sink_catalog: Arc<SinkCatalog>,
28}
29
30pub struct BoundView {
31 pub view_catalog: Arc<ViewCatalog>,
32}
33
34impl Binder {
35 pub fn bind_sink_by_name(&self, name: ObjectName) -> Result<BoundSink> {
36 matches!(self.bind_for, BindFor::System);
37 let (schema_name, sink_name) = Self::resolve_schema_qualified_name(&self.db_name, name)?;
38
39 let search_path = SchemaPath::new(
40 schema_name.as_deref(),
41 &self.search_path,
42 &self.auth_context.user_name,
43 );
44 let (sink_catalog, _) =
45 self.catalog
46 .get_sink_by_name(&self.db_name, search_path, &sink_name)?;
47 Ok(BoundSink {
48 sink_catalog: sink_catalog.clone(),
49 })
50 }
51
52 pub fn bind_view_by_name(&self, name: ObjectName) -> Result<BoundView> {
53 matches!(self.bind_for, BindFor::System);
54 let (schema_name, view_name) = Self::resolve_schema_qualified_name(&self.db_name, name)?;
55
56 let search_path = SchemaPath::new(
57 schema_name.as_deref(),
58 &self.search_path,
59 &self.auth_context.user_name,
60 );
61 let (view_catalog, _) =
62 self.catalog
63 .get_view_by_name(&self.db_name, search_path, &view_name)?;
64 Ok(BoundView {
65 view_catalog: view_catalog.clone(),
66 })
67 }
68}