MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / show_tables

Function show_tables

src/sql/src/plan/statement/show.rs:453–477  ·  view source on GitHub ↗
(
    scx: &'a StatementContext<'a>,
    from: Option<ResolvedSchemaName>,
    on_source: Option<ResolvedItemName>,
    filter: Option<ShowStatementFilter<Aug>>,
)

Source from the content-addressed store, hash-verified

451}
452
453fn show_tables<'a>(
454 scx: &'a StatementContext<'a>,
455 from: Option<ResolvedSchemaName>,
456 on_source: Option<ResolvedItemName>,
457 filter: Option<ShowStatementFilter<Aug>>,
458) -> Result<ShowSelect<'a>, PlanError> {
459 let schema_spec = scx.resolve_optional_schema(&from)?;
460 let mut query = format!(
461 "SELECT name, comment
462 FROM mz_internal.mz_show_tables tables
463 WHERE tables.schema_id = '{schema_spec}'",
464 );
465 if let Some(on_source) = &on_source {
466 let on_item = scx.get_item_by_resolved_name(on_source)?;
467 if on_item.item_type() != CatalogItemType::Source {
468 sql_bail!(
469 "cannot show tables on {} because it is a {}",
470 on_source.full_name_str(),
471 on_item.item_type(),
472 );
473 }
474 query += &format!(" AND tables.source_id = '{}'", on_item.id());
475 }
476 ShowSelect::new(scx, query, filter, None, Some(&["name", "comment"]))
477}
478
479fn show_sources<'a>(
480 scx: &'a StatementContext<'a>,

Callers 1

show_objectsFunction · 0.85

Calls 3

item_typeMethod · 0.45

Tested by

no test coverage detected