risingwave_frontend/binder/
create.rs

1// Copyright 2025 RisingWave Labs
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use itertools::Itertools;
16use risingwave_common::catalog::{ColumnCatalog, Field};
17
18use crate::Binder;
19use crate::error::Result;
20
21impl Binder {
22    pub fn bind_columns_to_context(
23        &mut self,
24        name: String,
25        column_catalogs: &[ColumnCatalog],
26    ) -> Result<()> {
27        let columns = column_catalogs
28            .iter()
29            .map(|c| (c.is_hidden, Field::from(&c.column_desc)))
30            .collect_vec();
31        self.bind_table_to_context(columns, name, None)
32    }
33
34    pub fn get_column_binding_index(
35        &mut self,
36        table_name: String,
37        column_name: &String,
38    ) -> Result<usize> {
39        Ok(self
40            .context
41            .get_column_binding_index(&Some(table_name), column_name)?)
42    }
43}