qlty_univariateStatistics
Analyze column data distributions by calculating univariate statistics for Teradata tables to identify patterns, outliers, and data quality insights.
Instructions
Get the univariate statistics for a table.
Arguments: database_name - name of the database table_name - table name to analyze column_name - column name to analyze
Returns: ResponseType: formatted response with query results + metadata
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database_name | Yes | ||
| table_name | Yes | ||
| column_name | Yes |
Implementation Reference
- The handler function that implements the core logic for the qlty_univariateStatistics tool. It executes a Teradata query using TD_UnivariateStatistics to compute all univariate statistics for the specified column in the table.def handle_qlty_univariateStatistics( conn: TeradataConnection, database_name: str | None, table_name: str, column_name: str, *args, **kwargs ): """ Get the univariate statistics for a table. Arguments: database_name - name of the database table_name - table name to analyze column_name - column name to analyze Returns: ResponseType: formatted response with query results + metadata """ logger.debug(f"Tool: handle_qlty_univariateStatistics: Args: table_name: {database_name}.{table_name}, column_name: {column_name}") if database_name is not None: table_name = f"{database_name}.{table_name}" with conn.cursor() as cur: rows = cur.execute(f"select * from TD_UnivariateStatistics ( on {table_name} as InputTable using TargetColumns ('{column_name}') Stats('ALL')) as dt ORDER BY 1,2") data = rows_to_json(cur.description, rows.fetchall()) metadata = { "tool_name": "qlty_univariateStatistics", "database_name": database_name, "table_name": table_name, "column_name": column_name, "stats_calculated": ["ALL"], "rows": len(data) } logger.debug(f"Tool: handle_qlty_univariateStatistics: Metadata: {metadata}") return create_response(data, metadata)
- src/teradata_mcp_server/app.py:273-281 (registration)The dynamic registration code that discovers and registers all handle_* functions (including handle_qlty_univariateStatistics as 'qlty_univariateStatistics') from loaded tool modules as MCP tools, inferring schema from function signatures and using docstrings for descriptions.for name, func in all_functions.items(): if not (inspect.isfunction(func) and name.startswith("handle_")): continue tool_name = name[len("handle_"):] if not any(re.match(p, tool_name) for p in config.get('tool', [])): continue wrapped = make_tool_wrapper(func) mcp.tool(name=tool_name, description=wrapped.__doc__)(wrapped) logger.info(f"Created tool: {tool_name}")
- ModuleLoader maps the 'qlty' prefix to the qlty tools module, enabling lazy loading of the qlty_univariateStatistics handler when qlty tools are required by the profile.MODULE_MAP = { 'base': 'teradata_mcp_server.tools.base', 'dba': 'teradata_mcp_server.tools.dba', 'fs': 'teradata_mcp_server.tools.fs', 'qlty': 'teradata_mcp_server.tools.qlty',
- src/teradata_mcp_server/tools/qlty/__init__.py:1-2 (registration)The qlty package __init__ imports all functions from qlty_tools.py, making handle_qlty_univariateStatistics available for dynamic discovery and registration.from .qlty_resources import * from .qlty_tools import *