ddl_builder
module wittgenstein_schema_discovery.ddl_builder
Build DDL strings and documentation text from catalog.yaml table metadata.
Ported from an earlier catalog ingest script. The format produced here must stay consistent with what was indexed by the original ingest — otherwise existing pgvector embeddings won't match new retrieval queries.
Functions
-
build_ddl — Build a CREATE TABLE DDL string for the given table and columns.
-
build_table_doc — Build a one-line table description for documentation indexing.
-
build_column_doc — Build a one-line column description for documentation indexing.
-
build_glossary_entry — Build a one-line glossary entry for documentation indexing.
wittgenstein_schema_discovery.ddl_builder.build_ddl
build_ddl(table_name: str, columns: dict[str, Any]) → str
Build a CREATE TABLE DDL string for the given table and columns.
Parameters
-
table_name : str — PostgreSQL table name.
-
columns : dict[str, Any] — dict of {column_name: {type, ...}} from catalog.yaml.
Returns
-
str — DDL string suitable for indexing into pgvector 'ddl' collection.
wittgenstein_schema_discovery.ddl_builder.build_table_doc
build_table_doc(table_name: str, meta: dict[str, Any]) → str
Build a one-line table description for documentation indexing.
wittgenstein_schema_discovery.ddl_builder.build_column_doc
build_column_doc(table_name: str, col_name: str, info: dict[str, Any]) → str
Build a one-line column description for documentation indexing.
wittgenstein_schema_discovery.ddl_builder.build_glossary_entry
build_glossary_entry(prefix: str, key: str, body: dict[str, Any]) → str
Build a one-line glossary entry for documentation indexing.