qlty_negativeValues
Identify columns containing negative values in Teradata tables to detect data quality issues and ensure numerical accuracy in database analysis.
Instructions
Get the column names that having negative values in a table.
Arguments: database_name - name of the database table_name - table 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 |
Implementation Reference
- The handler function `handle_qlty_negativeValues` implements the core logic for the `qlty_negativeValues` tool. It executes a Teradata query using TD_ColumnSummary to identify columns with negative values in the specified table, processes the results, adds metadata, and returns a formatted response.def handle_qlty_negativeValues(conn: TeradataConnection, database_name: str | None, table_name: str, *args, **kwargs): """ Get the column names that having negative values in a table. Arguments: database_name - name of the database table_name - table name to analyze Returns: ResponseType: formatted response with query results + metadata """ logger.debug(f"Tool: handle_qlty_negativeValues: Args: table_name: {database_name}.{table_name}") if database_name is not None: table_name = f"{database_name}.{table_name}" with conn.cursor() as cur: rows = cur.execute(f"select ColumnName, NegativeCount from TD_ColumnSummary ( on {table_name} as InputTable using TargetColumns ('[:]')) as dt ORDER BY NegativeCount desc") data = rows_to_json(cur.description, rows.fetchall()) metadata = { "tool_name": "qlty_negativeValues", "database_name": database_name, "table_name": table_name, "rows": len(data) } logger.debug(f"Tool: handle_qlty_negativeValues: Metadata: {metadata}") return create_response(data, metadata)