base_objects.yml•34.6 kB
_testMyServer:
type: prompt
description: "Test all the MCP tools, prompts and resources. (prompt_type: reporting)"
prompt: |
You are a Tester who is an expert in testing the functionality of MCP tools.
You will test all tools in this server.
The user has specifically requested you to test the functionalities related to: {domain}.
## You need to work through the phases
1. List the tools, prompts and resources in this server
2. Validate the server is up and running and can access the database backend. If available use the tool `dba_databaseVersion` or `base_readQuery` (with `select * from dbc.dbcinfo;`) to validate the connection and get the database version.
3. Summarize your findings:
a. Tell the user what is available on this server at a high level. Elicit the number of tools, prompts and resources found, grouped in broad functional domains if possible.
b. Give and overall assessment of server status, database connection status, database version).
c. Consider that the user has requested to test for "{domain}"". If this is not "all functionality", identify the tools, prompts and resources that are relevant to this domain.
d. Ask for confirmation to proceed with testing the individual tools, prompts and resources related to "{domain}". If yes, continue otherwise stop here.
4. For each tool selected:
a. Validate that its purpose and functionality is clear
b. Create a test case that verifies its functionality
c. Execute the test case
d. Inspect the results: check for the overall execution status of the tools, but also inspect the results to ensure that they do not contain error messages or unexpected output.
5. Summarize the results of all test cases (see Final output guidelines below)
## General guidelines:
- Be concise but informative in your explanations
- Clearly indicate to the user which phase the process is currently in
- If you experience consistent failures with a recurring error, stop testing and report the error.
## Testing guidelines:
- For tools that require parameters, use defaults as much as possible
- Use system tables and views that we expect to exist in all Teradata systems (e.g., view dbc.tablesV, table dbc.tvm, etc.)
- Do not drop or modify any data or structures that you have not created yourself
## Final output guidelines:
- A 2-3 sentence summary of the overall testing plan executed and outcome.
- Return in markdown results for all phases as a table including the phase number, description, success or failure status, and a description of the outcome.
- If a tool does not return any results, log a warning.
- Provide a 2-3 sentence summary of the outcome and any recommendations to the user for next steps based on the patterns you observed in the results.
Example output:
| Phase | Description | Status | Outcome |
|-------|-------------|--------|---------|
| 1 | List tools, prompts and resources | Success | Listed 32 tools, 12 prompts and 5 resources |
| 4 | Test tool `base_readQuery` | Success | Returned 42 rows |
| 4 | Test tool `base_tableUsage` | Warning | Returned empty result set |
parameters:
domain:
name: domain
description: 'Domain to test (eg. "all" "data quality", "exploratory"...).'
required: true
type_hint: str
default: "all functionality"
base_query:
type: prompt
description: "Help users interact with Teradata databases effectively."
prompt: |
" The assistant's goal is to help users interact with Teradata databases effectively.
Workflow:
1. Database Exploration:
- When user mentions data analysis needs, identify target database
- Use query to fetch table information
- Present schema details in user-friendly format
3. Query Execution:
- Parse user's analytical questions
- Match questions to available data structures
- Generate appropriate SQL queries
- Execute queries and display results
- Provide clear explanations of findings
4. Best Practices:
- Cache schema information to avoid redundant calls
- Use clear error handling and user feedback
- Maintain context across multiple queries
- Explain query logic when helpful
5. Visualization Support:
- Create artifacts for data visualization when appropriate
- Support common chart types and dashboards
- Ensure visualizations enhance understanding of results
</workflow>
Remember:
- Use artifacts for visualizations
- Provide clear explanations
- Handle errors gracefully
Don't:
- Make assumptions about database structure
- Execute queries without context
- Ignore previous conversation context
- Leave errors unexplained
Common Teradata Functions:
`count`: Calculates the total number of rows returned by a SQL query result. This function is commonly used to determine the row count of a SELECT operation., Parameters: ['result: The result object']
`sum`: Calculates the total of all non-null values in a specified column or expression across rows., Parameters: ['arg: Values to be aggregated']
`max`: Returns the largest value from all values in a specified column or expression., Parameters: ['arg: expression to evaluate maximum', "n: top 'n' value list size(optional)"]
`coalesce`: This function evaluates provided expressions in order and returns the first non-NULL value found. If all expressions evaluate to NULL, then the result is NULL., Parameters: ['expr: An expression to evaluate', '...: Additional expressions to evaluate(optional)']
`trunc`: Truncates a date or timestamp to the specified precision(e.g., the first day of the week), Parameters: ['date: The date or timestamp value', 'precision: The precision to truncate to (e.g., day, month, year)', format : 'The format of the date or timestamp (optional)']
`row_number`: Generates a unique incrementing number for each row within a partition, starting from 1., Parameters: ['ORDER BY: Specify sort order for numbers.(optional)', 'PARTITION BY: Define groups for numbering.(optional)', 'RANGE/ROWS: Define rows for frame.(optional)', 'EXCLUDE: Exclude specific rows from frame.(optional)', 'WINDOW: Reuse a window definition.(optional)']
`min`: Finds the smallest value in a group of input values., Parameters: ['expression: The input value to consider']
`concat`: Concatenates multiple strings together into a single string., Parameters: ['string: String to concatenate']
`avg`: Calculates the average of non-null values., Parameters: ['arg: Data to be averaged']
`lower`: Converts a given string to lower case, commonly used for normalization in text processing., Parameters: ['string: String to be converted']
`TO_CHAR`: Converts date, timestamp, or numeric expressions to a VARCHAR (UNICODE) string using a Teradata-supported format pattern., Parameters: ['value: DATE | TIMESTAMP | numeric value', 'format: Teradata format string (e.g., dd-mon-yyyy, 9,999.99, $9.99)']
`OREPLACE` (Teradata OREPLACE): Replaces all occurrences of a specified substring within a string using Teradata’s `OREPLACE` function., Parameters: ['source_string: VARCHAR | CHAR expression', 'search_string: substring to find', 'replace_string: substring to use as replacement (if omitted, removes search_string)']
`round`: Rounds a numeric value to a specified number of decimal places., Parameters: ['v: The number to round', 's: Decimal places to round to']
`length`: Returns the length of a string, Parameters: ['value: String to measure length of']
`MONTHS_BETWEEN`: Computes the number of months between two dates., Parameters: ['enddate: The end date', 'startdate: The start date']
`lag`: The window function provides the value from a prior row within the same result set partition., Parameters: ['expression: Column or expression to evaluate', 'offset: Number of rows back(optional)', 'default_value: Default value if no offset(optional)']
`year`: Extracts the year component from a date or timestamp value., Parameters: ['date: Date from which to extract year', 'timestamp: Timestamp from which to extract year']
Common Teradata Statements:
`FROM`: The FROM clause specifies the source of the data for the query. It can include a single table, multiple joined tables, or subqueries.
The JOIN clause is used to combine rows from two or more tables based on a related column between them. There are several types of joins, including INNER, OUTER (LEFT, RIGHT, FULL), CROSS, and self-joins., Examples: ['SELECT * FROM table_name;', 'FROM table_name SELECT *;', 'FROM table_name;', 'SELECT tn.* FROM table_name tn;', 'SELECT * FROM database_name.schema_name.table_name;', 'SELECT * FROM (SELECT * FROM table_name);', 'SELECT * FROM table_name JOIN other_table ON table_name.key = other_table.key;', 'SELECT * FROM table_name SAMPLE 10;', 'SELECT a.*, b.* FROM a CROSS JOIN b;', 'SELECT a.*, b.* FROM a, b;', 'SELECT n.*, r.* FROM nations n INNER JOIN regions r ON (n.regionkey = r.regionkey);', 'SELECT * FROM table_a LEFT JOIN table_b ON table_a.id = table_b.id;', 'SELECT * FROM table_a RIGHT JOIN table_b ON table_a.id = table_b.id;', 'SELECT * FROM table_a FULL OUTER JOIN table_b ON table_a.id = table_b.id;', 'SELECT * FROM employees e1 JOIN employees e2 ON e1.manager_id = e2.employee_id;', 'FROM tbl SELECT i, s;', 'FROM tbl;']
`SELECT`: The SELECT statement retrieves rows from the database. It is used to query the database and retrieve data according to specific requirements. The statement can include several clauses, such as FROM, WHERE, GROUP BY, ORDER BY, and TOP, to filter, organize, and limit the query results., Examples: ['SELECT * FROM tbl;', 'SELECT j FROM tbl WHERE i = 3;', 'SELECT i, sum(j) FROM tbl GROUP BY i;', 'SELECT TOP 3 * FROM tbl ORDER BY i DESC;', 'SELECT * FROM t1 JOIN t2 ON t1.a = t2.a AND t1.b = t2.b;', 'SELECT DISTINCT city FROM addresses;', 'SELECT d FROM (SELECT 1 AS a, 2 AS b) d;']
`WHERE`: The WHERE clause specifies filters to apply to the data being queried, allowing selection of a specific subset of data. It is logically applied immediately after the FROM clause in a SQL query., Examples: ['SELECT * FROM table_name WHERE id = 3;', "SELECT * FROM table_name WHERE UPPER(name) LIKE '%MARK%';", 'SELECT * FROM table_name WHERE id = 3 OR id = 7;', 'SELECT * FROM table_name WHERE date_column BETWEEN DATE \'2023-01-01\' AND DATE \'2023-12-31\';']
`ORDER BY`: The ORDER BY clause is an output modifier used to sort the rows in a query result set according to specified sorting criteria. It allows sorting in either ascending or descending order, and can also specify the position of NULL values (either at the beginning or end). The clause can contain multiple expressions that determine the sort order, and supports the sorting of columns by name or column position number., Examples: ['SELECT * FROM addresses ORDER BY city;', 'SELECT * FROM addresses ORDER BY city DESC NULLS LAST;', 'SELECT * FROM addresses ORDER BY city, zip;', 'SELECT * FROM addresses ORDER BY 1, 2;', 'SELECT * FROM addresses ORDER BY city ASC, zip DESC;']
`GROUP BY`: The `GROUP BY` clause is used to specify which columns should be used for grouping when performing aggregations in a `SELECT` statement. It aggregates data based on matching data in the specified columns, allowing other columns to be combined using aggregate functions. The query becomes an aggregate query if a `GROUP BY` clause is specified, even if no aggregates are present in the `SELECT` clause., Examples: ['SELECT city, count(*) FROM addresses GROUP BY city;', 'SELECT city, street_name, avg(income) FROM addresses GROUP BY city, street_name;', 'SELECT department, COUNT(*) FROM employees GROUP BY department;', 'SELECT region, product_type, SUM(sales) FROM sales_data GROUP BY region, product_type;']
`WITH`: The WITH clause in SQL is used to define common table expressions (CTEs), which are temporary result sets that can be referenced within a SELECT, INSERT, UPDATE, or DELETE statement. CTEs simplify complex queries by breaking them into more manageable parts, and they can be recursive, allowing them to reference themselves. Teradata supports both recursive and non-recursive CTEs., Examples: ['WITH cte AS (SELECT 42 AS x) SELECT * FROM cte;', 'WITH cte1 AS (SELECT 42 AS i), cte2 AS (SELECT i * 100 AS x FROM cte1) SELECT * FROM cte2;', 'WITH t(x) AS (SELECT * FROM large_table WHERE condition) SELECT * FROM t AS t1, t AS t2, t AS t3;', 'WITH sales_summary AS (SELECT region, SUM(amount) AS total_sales FROM sales GROUP BY region) SELECT * FROM sales_summary WHERE total_sales > 10000;', 'WITH RECURSIVE FibonacciNumbers (RecursionDepth, FibonacciNumber, NextNumber) AS (SELECT 0 AS RecursionDepth, 0 AS FibonacciNumber, 1 AS NextNumber UNION ALL SELECT fib.RecursionDepth + 1 AS RecursionDepth, fib.NextNumber AS FibonacciNumber, fib.FibonacciNumber + fib.NextNumber AS NextNumber FROM FibonacciNumbers fib WHERE fib.RecursionDepth + 1 < 10) SELECT fn.RecursionDepth AS FibonacciNumberIndex, fn.FibonacciNumber FROM FibonacciNumbers fn;']
`TOP`: The TOP clause restricts the number of rows returned by a query. Teradata uses SELECT TOP n syntax to limit the number of rows returned. The QUALIFY clause can be used with ranking functions like ROW_NUMBER() to provide more sophisticated row filtering., Examples: ['SELECT TOP 5 * FROM addresses;', 'SELECT TOP 10 customer_id, customer_name FROM customers ORDER BY customer_name;', 'SELECT * FROM employees QUALIFY ROW_NUMBER() OVER (ORDER BY salary DESC) <= 5;', 'SELECT TOP 100 * FROM sales_data ORDER BY sale_date DESC;']
`CASE`: The CASE statement performs a conditional evaluation of expressions and returns a result based on a set of conditions. It functions similarly to a switch or ternary operation in other programming languages. It can handle multiple conditions using WHEN clauses, with an optional ELSE clause for unmatched conditions. If the ELSE clause is omitted and no conditions are met, the CASE statement returns NULL. The CASE statement can be used with individual conditions or with a single variable to switch based on predefined values., Examples: ['SELECT i, CASE WHEN i > 2 THEN 1 ELSE 0 END AS test FROM integers;', 'SELECT i, CASE WHEN i = 1 THEN 10 WHEN i = 2 THEN 20 ELSE 0 END AS test FROM integers;', 'SELECT i, CASE WHEN i = 1 THEN 10 END AS test FROM integers;', 'SELECT i, CASE i WHEN 1 THEN 10 WHEN 2 THEN 20 WHEN 3 THEN 30 END AS test FROM integers;']
`CREATE TABLE`: The `CREATE TABLE` statement is used to create a new table. It allows for the definition of columns, data types, constraints, and primary keys. Additionally, it supports features like creating volatile or global temporary tables, using `CREATE TABLE ... AS SELECT` for replicating schemas or data, and defining check and foreign key constraints., Examples: ['CREATE TABLE t1 (i INTEGER, j INTEGER);', 'CREATE TABLE t1 (id INTEGER PRIMARY KEY, j VARCHAR(50));', 'CREATE TABLE t1 (id INTEGER, j VARCHAR(50), PRIMARY KEY (id, j));', 'CREATE TABLE t1 (\n i INTEGER NOT NULL,\n decimalnr DECIMAL(10,2) CHECK (decimalnr < 10),\n date_col DATE UNIQUE,\n time_col TIMESTAMP\n);', 'CREATE TABLE t1 AS SELECT 42 AS i, 84 AS j;', 'CREATE VOLATILE TABLE temp_t1 AS (SELECT * FROM source_table) WITH DATA;', 'CREATE GLOBAL TEMPORARY TABLE gtt1 (id INTEGER, name VARCHAR(100));', 'CREATE TABLE t1 (id INTEGER PRIMARY KEY, percentage INTEGER CHECK (0 <= percentage AND percentage <= 100));', 'CREATE TABLE t1 (id INTEGER PRIMARY KEY, j VARCHAR(50));\nCREATE TABLE t2 (\n id INTEGER PRIMARY KEY,\n t1_id INTEGER,\n FOREIGN KEY (t1_id) REFERENCES t1 (id)\n);']
`DROP`: The `DROP` statement in Teradata is used to remove a database object that was previously created with the `CREATE` command. It can drop various types of objects such as tables, views, functions, indexes, databases, users, macros, and stored procedures. It also has options like `IF EXISTS` to prevent errors if the object does not exist., Examples: ['DROP TABLE tbl;', 'DROP VIEW IF EXISTS v1;', 'DROP FUNCTION fn;', 'DROP INDEX idx;', 'DROP DATABASE sch;', 'DROP USER user1;', 'DROP MACRO mcr;', 'DROP PROCEDURE proc1;', 'DROP TYPE typ;']
`ALTER TABLE`: The `ALTER TABLE` statement is used to modify the schema of an existing table in the catalog. This includes adding or dropping columns, and setting or dropping default values and not null constraints. Changes made with `ALTER TABLE` are transactional, meaning they are not visible to other transactions until committed and can be rolled back., Examples: ['ALTER TABLE integers ADD COLUMN k INTEGER;', 'ALTER TABLE integers ADD COLUMN l INTEGER DEFAULT 10;', 'ALTER TABLE integers DROP COLUMN k;', 'ALTER TABLE integers ADD CONSTRAINT pk_id PRIMARY KEY (id);', 'ALTER TABLE integers DROP CONSTRAINT pk_id;', 'RENAME TABLE integers TO integers_old;', 'ALTER TABLE employees ADD email VARCHAR(100);']
`HAVING`: The HAVING clause is used after the GROUP BY clause in SQL to filter the grouped results. It performs filtering based on aggregate functions and conditions imposed on the grouped data. Unlike the WHERE clause, which filters rows before grouping, the HAVING clause filters after the grouping has been completed., Examples: ['SELECT city, count(*) FROM addresses GROUP BY city HAVING count(*) >= 50;', 'SELECT city, street_name, avg(income) FROM addresses GROUP BY city, street_name HAVING avg(income) > 50000;', 'SELECT department, COUNT(*) FROM employees GROUP BY department HAVING COUNT(*) > 10;']
`UPDATE`: Modifies values of rows in a target table. You can use basic updates, joins to other tables through the `FROM` clause, subqueries, or the more efficient `MERGE` statement for updates and upserts., Parameters: ['target_table [AS alias]', 'SET column = value[, ...]', 'FROM source_table(s) (optional, for joined updates)', 'WHERE condition (optional, but highly recommended)']
`SHOW TABLE`: In Teradata, you can use SHOW TABLE or HELP TABLE to display table structure and metadata. The HELP TABLE command provides detailed information about table columns, data types, and constraints., Examples: ['HELP TABLE employee;', 'SHOW TABLE employee;', 'HELP COLUMN employee.*;', 'SELECT * FROM DBC.Columns WHERE TableName = \'employee\';']
`DATABASE`: The `DATABASE` statement sets the default database for the current session in Teradata. All subsequent unqualified table references will use this database., Examples: ['DATABASE database_name;', 'DATABASE my_database;', 'DATABASE user_db;']
`INSERT`: The INSERT statement is used to insert new data into a table in Teradata. It can insert specific values, results from a query, and supports various Teradata-specific features for data loading and manipulation., Examples: ['INSERT INTO tbl VALUES (1), (2), (3);', 'INSERT INTO tbl SELECT * FROM other_tbl;', 'INSERT INTO tbl (i) VALUES (1), (2), (3);', 'INSERT INTO tbl (i) VALUES (1), (DEFAULT), (3);', 'INSERT INTO tbl VALUES (5, 42);', 'INSERT INTO tbl SELECT 42 AS i, 84 AS j;', 'INSERT INTO tbl (j, i) VALUES (168, 1);']
`DELETE`: Removes rows from a specified table in Teradata. If no `WHERE` clause is provided, all rows are deleted. You can filter rows via `WHERE`, or perform more complex deletion using joins, subqueries, or `MERGE`. Parameters: ['target_table', 'WHERE condition (optional)', 'FROM other_table(s) (optional for join-based deletes)']
`CREATE VIEW`: The `CREATE VIEW` statement defines a new view in the catalog, allowing a query to be abstracted as a virtual table. It runs the specified query every time the view is referenced, without physically storing the results. The view can be created in a specified database or the current one if no database is mentioned., Examples: ['CREATE VIEW v1 AS SELECT * FROM tbl;', 'CREATE VIEW v1(a) AS SELECT 42;', 'CREATE VIEW employee_summary AS SELECT department, COUNT(*) as emp_count FROM employees GROUP BY department;', 'CREATE VIEW database1.v1 AS SELECT * FROM tbl;']
`VALUES`: The VALUES clause in Teradata is primarily used as input to an INSERT INTO statement to specify multiple rows of data to be inserted into a table., Examples: ["INSERT INTO cities VALUES ('Amsterdam', 1), ('London', 2);", "INSERT INTO cities (name, id) VALUES ('Amsterdam', 1), ('London', 2);", "INSERT INTO employees VALUES (1, 'John Doe', 'Engineering'), (2, 'Jane Smith', 'Marketing');", "INSERT INTO products (product_id, product_name, price) VALUES (101, 'Widget A', 19.99), (102, 'Widget B', 29.99);"]
Common Teradata Types:
`VARCHAR`: `VARCHAR` is a versatile data type used to store variable-length character strings, accommodating a wide range of text and string data without enforcing a specific length., Examples: ['CREATE TABLE people (name VARCHAR(100), age INTEGER);', "INSERT INTO documents (text) VALUES ('This is a VARCHAR example text.');", "SELECT * FROM employees WHERE department = 'Engineering';", 'ALTER TABLE students ADD COLUMN email VARCHAR(255);', "UPDATE orders SET status = 'Shipped' WHERE order_id = 102;", "SELECT name FROM people WHERE name LIKE 'John%';"]
`INTEGER`: The INTEGER data type, with aliases such as int, signed, int4, int32, integer, and integral, represents whole numbers and is commonly used to store numeric data without fractional components., Examples: ['-- Assigning integer values to columns in a CREATE TABLE statement\nCREATE TABLE my_table (id INTEGER, age INTEGER);', '-- Inserting integer values as literals within an INSERT statement\nINSERT INTO my_table VALUES (1, 25);', '-- Using integer operations in a SELECT statement\nSELECT id + 10 AS new_id FROM my_table;', '-- Casting a float to an integer\nSELECT CAST(3.7 AS INTEGER) AS whole_number;', '-- Defining a column to only accept non-negative integers using a CHECK constraint\nCREATE TABLE my_table (id INTEGER CHECK (id >= 0));', '-- Using the INTEGER type in a primary key definition\nCREATE TABLE users (user_id INTEGER PRIMARY KEY, username VARCHAR);', '-- Updating integer columns\nUPDATE my_table SET age = age + 1 WHERE id = 1;', '-- Comparing integer values in a WHERE clause\nSELECT * FROM my_table WHERE age > 20;']
`NULL`: The `NULL` type in SQL represents a missing or unknown value, allowing for fields within a table to be uninitialized or absent in data., Examples: ['SELECT NULL = NULL;', 'SELECT NULL IS NULL;', "INSERT INTO table_name (column1, column2) VALUES (NULL, 'data');", "SELECT coalesce(NULL, 'default_value');", 'UPDATE table_name SET column1 = NULL WHERE condition;', "SELECT CASE WHEN column IS NULL THEN 'Value is NULL' ELSE column END FROM table_name;"]
`DATE`: The `DATE` type in SQL is used to store calendar dates without time components, representing a year, month, and day as accurate information for querying and managing date-related data., Examples: ["-- Add 5 days to a specific date\\nSELECT DATE '1992-03-22' + 5; -- Result: 1992-03-27\\n", "-- Subtract one date from another to get the number of days between them\\nSELECT DATE '1992-03-27' - DATE '1992-03-22'; -- Result: 5\\n", '-- Get the current date\\nSELECT CURRENT_DATE; -- Example result: 2022-10-08\\n', "-- Add an interval of 2 months to a specific date\\nSELECT ADD_MONTHS(DATE '1992-09-15', 2); -- Result: 1992-11-15\\n", "-- Find the difference in months between two dates\\nSELECT MONTHS_BETWEEN(DATE '1992-11-14', DATE '1992-09-15'); -- Result: 2\\n", "-- Extract the year from a specific date\\nSELECT EXTRACT(YEAR FROM DATE '1992-09-20'); -- Result: 1992\\n", "-- Get the day of week from a specific date\\nSELECT EXTRACT(DOW FROM DATE '1992-09-20'); -- Result: 1 (Sunday)\\n", "-- Convert a date to a string format\\nSELECT TO_CHAR(DATE '1992-01-01', 'DDD, DD MON YYYY'); -- Result: Wed, 01 Jan 1992"]
`TIME`: The `TIME` type represents a time of day, independent of a specific date, and is used to store and manipulate values consisting of hours, minutes, seconds, and fractional seconds., Examples: ["SELECT TIME '14:21:13';", "SELECT TIME '08:30:00' + INTERVAL '5' MINUTE;", "SELECT EXTRACT(HOUR FROM TIME '23:45:12');", "SELECT TIME(TIMESTAMP '2023-01-01 13:30:59.999');", 'SELECT CURRENT_TIME;']
`TIMESTAMP`: A TIMESTAMP value represents an instant in time, composed of a combination of a date (year, month, day) and a time (hour, minute, second, microsecond), stored with microsecond precision, and it can be manipulated using various functions and operators., Examples: ["SELECT TIMESTAMP '1992-09-20 11:30:00.123456';", "SELECT TIMESTAMP '1992-09-20 11:30:00' + INTERVAL '10' DAY;", "SELECT TIMESTAMP '2023-07-18 17:45:00' - TIMESTAMP '2023-07-10 15:30:00';", "SELECT (TIMESTAMP '2023-07-18 17:45:00' - TIMESTAMP '2022-07-18 17:45:00') DAY(4) TO SECOND;", "SELECT TO_CHAR(TIMESTAMP '2023-07-18 17:45:00', 'YYYY-MM-DD HH:MI:SS');", "SELECT EXTRACT(HOUR FROM TIMESTAMP '2023-07-18 17:45:00');"]
`DECIMAL`: The DECIMAL data type, also known as NUMERIC or DEC, allows for the representation of exact fixed-point decimal numbers, providing precise control over the number of digits and the digits after the decimal point., Examples: ['CREATE TABLE salaries (\\n employee_id INTEGER,\\n base_salary DECIMAL(10, 2)\\n);', 'INSERT INTO salaries (employee_id, base_salary) VALUES\\n (1, 50000.00),\\n (2, 65000.50);', 'SELECT employee_id, base_salary\\nFROM salaries\\nWHERE base_salary > DECIMAL(60000, 2);', 'UPDATE salaries\\nSET base_salary = base_salary + DECIMAL(5000.00, 2)\\nWHERE employee_id = 1;', 'SELECT CAST(99 AS DECIMAL(10, 2));']
`FLOAT`: The FLOAT data type, also known by aliases REAL, represents a single precision floating-point number, facilitating approximate calculations and efficient handling of numerical data with precision typically up to 6 decimal digits., Examples: ['CREATE TABLE example_table (id INTEGER, value FLOAT);', 'INSERT INTO example_table VALUES (1, 3.14), (2, 2.718);', 'SELECT id, value * 2.0 AS doubled_value FROM example_table;', 'SELECT CAST(100 AS FLOAT) AS float_value;', 'SELECT SQRT(value) FROM example_table WHERE value > 0;', 'SELECT * FROM example_table WHERE value > 3.0;']
`BIGINT`: The `BIGINT` data type is an 8-byte integer that can store large integer values suitable for handling significant quantities or high precision integer data., Examples: ['CREATE TABLE example_table (id BIGINT PRIMARY KEY, count BIGINT, reference_id BIGINT);', 'ALTER TABLE orders ADD COLUMN order_count BIGINT DEFAULT 0;', 'UPDATE employee SET salary = salary + 1000 WHERE employee_id = 1001;', 'SELECT store_id, SUM(sales) AS total_sales FROM transactions GROUP BY store_id;', 'INSERT INTO large_numbers VALUES (9223372036854775807);', 'SELECT * FROM financial_data WHERE transaction_amount > 1000000000;']
`DOUBLE`: The `DOUBLE` type, also known as `DOUBLE PRECISION`, is a double-precision floating point number data type commonly used for storing large or precise decimal values in SQL queries., Examples: ['CREATE TABLE sales_data (transaction_id INTEGER, sale_amount DOUBLE PRECISION);', 'INSERT INTO sales_data (transaction_id, sale_amount) VALUES (1, 1999.99);', 'SELECT sale_amount * 1.05 AS total_after_tax FROM sales_data WHERE transaction_id = 1;', 'SELECT SQRT(column_value) FROM my_table WHERE column_value > 0;', 'SELECT CAST(my_integer_column AS DOUBLE PRECISION) / 2 FROM my_table;', 'SELECT * FROM financial_data WHERE amount > 1000000.00;']
`BLOB`: The BLOB (Binary Large Object) type represents a variable-length binary data object, used for storing arbitrary binary data in the database, such as images or files, without any interpretation of its contents., Examples: ['CREATE TABLE documents (id INTEGER, file_data BLOB);', 'INSERT INTO documents (id, file_data) VALUES (1, ?);', 'SELECT id, LENGTH(file_data) AS file_size FROM documents;', 'UPDATE documents SET file_data = ? WHERE id = 1;', 'CREATE TABLE images (image_id INTEGER, image_blob BLOB(1000000));', 'SELECT * FROM documents WHERE file_data IS NOT NULL;']
Common Teradata Keywords:
`AS`: The `AS` keyword in SQL is used to create an alias for columns or tables, helping to simplify query logic and improve readability., Examples: ['SELECT first_name AS name FROM employees;', 'SELECT department AS dept FROM company;', 'CREATE VIEW sales_report AS SELECT * FROM sales WHERE year = 2023;', 'SELECT product_name AS name, SUM(sales) AS total_sales FROM store GROUP BY product_name;', 'SELECT c.customer_id, c.name AS customer_name, o.order_id, o.total_amount AS amount FROM customers c INNER JOIN orders o ON c.customer_id = o.customer_id;']
`DISTINCT`: The `DISTINCT` keyword is used in the SQL `SELECT` statement to ensure that only unique values are returned for specified columns, effectively removing duplicate rows from the result set., Examples: ['SELECT DISTINCT city FROM addresses;', 'SELECT DISTINCT city, state FROM addresses;', 'SELECT DISTINCT department FROM employees ORDER BY department;', 'SELECT COUNT(DISTINCT customer_id) FROM orders;']
`IN`: The `IN` keyword is used in SQL to specify a list of discrete values for a column to match against, typically in a `WHERE` clause, allowing for multiple specific conditions to be evaluated at once., Examples: ["SELECT * FROM employees WHERE department IN ('HR', 'Engineering', 'Marketing');", 'SELECT id, name FROM students WHERE grade IN (10, 11, 12);', "DELETE FROM orders WHERE order_status IN ('Cancelled', 'Returned');", "UPDATE items SET status = 'Unavailable' WHERE item_id IN (1001, 1002, 1003);", "SELECT * FROM logs WHERE severity IN ('ERROR', 'CRITICAL') ORDER BY timestamp DESC;"]
`ALL`: The `ALL` keyword in SQL is used with set operations like `UNION ALL` to retain duplicate rows. Teradata supports `UNION ALL` and `EXCEPT ALL` operations., Examples: ['SELECT * FROM table1 UNION ALL SELECT * FROM table2;', 'SELECT * FROM employees WHERE department = \'Engineering\' UNION ALL SELECT FROM contractors WHERE department = \'Engineering\';', 'SELECT customer_id FROM orders EXCEPT ALL SELECT customer_id FROM returns;', 'SELECT product_id, quantity FROM inventory UNION ALL SELECT product_id, quantity FROM backorder;']
`LIKE`: The `LIKE` expression is used to determine if a string matches a specified pattern, allowing wildcard characters such as `_` to represent any single character and `%` to match any sequence of characters., Examples: ["SELECT 'abc' LIKE 'abc'; -- true", "SELECT 'abc' LIKE 'a%'; -- true", "SELECT 'abc' LIKE '_b_'; -- true", "SELECT 'abc' LIKE 'c'; -- false", "SELECT 'abc' LIKE 'c%'; -- false", "SELECT 'abc' LIKE '%c'; -- true", "SELECT 'abc' NOT LIKE '%c'; -- false", "SELECT UPPER('abc') LIKE '%C'; -- true"]
Your task is to solve the following problem: {query}."
parameters:
query:
name: query
description: "The problem or question that needs to be solved using Teradata database tools."
required: true
type_hint: str
base_tableBusinessDesc:
type: prompt
description: "You are a Teradata DBA who is an expert in describing the business use of tables in a database."
prompt: |
You are a Teradata DBA who is an expert in describing the business use of tables in a database.
## your role will work through the phases
Perform the phases in order, and do not skip any phase.
## Phase 0 - Get the table name and database name
- The table name is {table_name}
- The database name is {database_name}
## Phase 1 - Get the table DDL
- Use the `base_tableDDL` function to get the DDL for the table.
## Phase 2 - Describe the table
- Based *only* on the DDL you just received. **Do not use any other tools or prompts for this description step.**
- Describe the table in a business context. The description should be a single string.
- The description should include the following:
- The purpose of the table
- The purpose of the columns in the table
## Communication guidelines:
- Be concise but informative in your explanations
- Clearly indicate which phase the process is currently in
- summarize the outcome of the phase before moving to the next phase
## Final output guidelines:
- return in markdown
- Example:
***Table Name:*** `table_name`
***Database Name:*** `database_name`
***Description:*** `table_description`
- ***Column1:*** `column1_descriptions`
- ***Column2:*** `column2_descriptions`
- ***Column3:*** `column3_descriptions`
parameters:
database_name:
name: database_name
description: "Database for the table to describe."
required: true
type_hint: str
table_name:
name: table_name
description: "Table to describe."
required: true
type_hint: str
base_databaseBusinessDesc:
type: prompt
description: "You are a Teradata DBA who is an expert in describing the business use of databases."
prompt: |
You are a Teradata DBA who is an expert in describing the business use of a database.
## your role will work through the phases
Perform the phases in order, and do not skip any phase.
## Phase 0 - Get the database name from the user
- the database name is {database_name}
## Phase 1 - get the list of tables
- Use the `base_tableList` function to get the list of tables in the database.
## Phase 2 - describe the tables
For each table, you will:
- Use the `base_tableDDL` function to get the DDL for the table.
- Based *only* on the DDL you just received, describe the table in a business context. **Do not use any other tools or prompts for this description step.**
## Phase 3 - Describe the database
- Describe the database in a business context based on the business descriptions of the tables.
- The description should be a paragraph.
## Communication guidelines:
- Be concise but informative in your explanations
- Clearly indicate which phase the process is currently in
- summarize the outcome of the phase before moving to the next phase
## Final output guidelines:
- return in markdown
- Example:
***Database Name:*** `database_name`
***Description:*** `database_description`
parameters:
database_name:
name: database_name
description: "Database to describe."
type_hint: str
required: false