Catalog System

Overview

The catalog system manages metadata for database tables, columns, and business rules.

Catalog Store

Filesystem Implementation

Catalog Loader

class openchatbi.catalog.catalog_loader.DataCatalogLoader(engine: Engine, include_tables: list[str] | None = None)[source]

Bases: object

The loader to load data catalog from data warehouse metadata and save to catalog store.

__init__(engine: Engine, include_tables: list[str] | None = None)[source]

Initialize catalog loader.

Parameters:
  • engine (Engine) – SQLAlchemy engine instance

  • include_tables (Optional[List[str]]) – List of table names to include, None for all

get_tables_and_columns() dict[str, list[dict[str, Any]]][source]

Extract table and column metadata including comments using SQLAlchemy inspector.

Returns:

Dictionary mapping table names to list of column information

Return type:

Dict[str, List[Dict[str, Any]]]

get_table_indexes(table_name: str) list[dict[str, Any]][source]

Get index information for a specific table.

Parameters:

table_name (str) – Name of the table

Returns:

List of index information

Return type:

List[Dict[str, Any]]

get_foreign_keys(table_name: str) list[dict[str, Any]][source]

Get foreign key information for a specific table.

Parameters:

table_name (str) – Name of the table

Returns:

List of foreign key information

Return type:

List[Dict[str, Any]]

save_to_catalog_store(catalog_store: CatalogStore, database_name: str | None = None, update: bool = False) bool[source]

Extract warehouse metadata and save to catalog store.

Parameters:
  • catalog_store (CatalogStore) – Target catalog store to load data to

  • database_name (Optional[str]) – Database name in catalog, defaults to ‘default’

  • update (bool) – Update existing catalog store to sync with data warehouse

Returns:

True if load was successful, False otherwise

Return type:

bool

openchatbi.catalog.catalog_loader.load_catalog_from_data_warehouse(catalog_store: CatalogStore) bool[source]

Load catalog data from data warehouse using SQLAlchemy based on data warehouse config (URI)

Main entry point for catalog loading.

Parameters:

catalog_store (CatalogStore) – Target catalog store

Returns:

True if load was successful, False otherwise

Return type:

bool

Schema Retrieval