Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(catalog): add source columns to rw_columns (#14939) #14942

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions src/frontend/src/catalog/system_catalog/rw_catalog/rw_columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ impl SysCatalogReaderImpl {

Ok(schemas
.flat_map(|schema| {
// view columns
let view_rows = schema.iter_view().flat_map(|view| {
view.columns.iter().enumerate().map(|(index, column)| {
OwnedRow::new(vec![
Expand All @@ -64,6 +65,7 @@ impl SysCatalogReaderImpl {
})
});

// sink columns
let sink_rows = schema
.iter_sink()
.flat_map(|sink| {
Expand All @@ -87,7 +89,8 @@ impl SysCatalogReaderImpl {
})
.chain(view_rows);

let rows = schema
// pg_catalog columns
let catalog_rows = schema
.iter_system_tables()
.flat_map(|table| {
table
Expand All @@ -111,7 +114,8 @@ impl SysCatalogReaderImpl {
})
.chain(sink_rows);

schema
// table columns
let table_rows = schema
.iter_valid_table()
.flat_map(|table| {
table
Expand All @@ -137,7 +141,34 @@ impl SysCatalogReaderImpl {
])
})
})
.chain(rows)
.chain(catalog_rows);

// source columns
schema
.iter_source()
.flat_map(|source| {
source
.columns
.iter()
.enumerate()
.map(move |(index, column)| {
OwnedRow::new(vec![
Some(ScalarImpl::Int32(source.id as i32)),
Some(ScalarImpl::Utf8(column.name().into())),
Some(ScalarImpl::Int32(index as i32 + 1)),
Some(ScalarImpl::Bool(column.is_hidden)),
Some(ScalarImpl::Bool(
source.pk_col_ids.contains(&column.column_id()),
)),
Some(ScalarImpl::Bool(false)),
Some(ScalarImpl::Utf8(column.data_type().to_string().into())),
Some(ScalarImpl::Int32(column.data_type().to_oid())),
Some(ScalarImpl::Int16(column.data_type().type_len())),
Some(ScalarImpl::Utf8(column.data_type().pg_name().into())),
])
})
})
.chain(table_rows)
})
.collect_vec())
}
Expand Down
Loading