PROMPT_FIXUP
Fix up your query
You can ask MotherDuck AI to correct and fix up your query using the prompt_fixup
table function. This feature is especially useful to fix SQL statements that have logical or severe syntactical issues, because the query gets rewritten from scratch. For small errors, consider using the prompt_fix_line
method, which is faster and more precise.
Syntax
CALL prompt_fixup('<SQL query>', [include_tables=['<table_name>', '<table_name>']);
Example usage
We use MotherDuck's sample Hacker News dataset from MotherDuck's sample data database.
CALL prompt_fixup('SEELECT COUNT(*) as domain_count FROM hn.hackers');
Output of this SQL statement is a single column table with the following content:
query |
---|
SELECT COUNT(*) as domain_count FROM hn.hacker_news |
Notes
MotherDuck AI operates on your current database by evaluating the schemas and contents of the database. You can specify which tables and columns should be considered, using the optional include_tables
parameter. By default, all tables in the current database are considered.
To point MotherDuck AI at a specific database, execute the use database
command (learn more about switching databases).
These capabilities are provided by MotherDuck's integration with OpenAI. For availability and pricing, see MotherDuck's Pricing Model