qlty_negativeValues
Identify columns containing negative values in Teradata database tables to detect data quality issues and ensure numerical data integrity.
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
- Handler function that implements the qlty_negativeValues tool. It queries the TD_ColumnSummary table function to find columns with negative values in the specified table and returns the results with metadata.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)