PROMPT_FIX_LINE
Fix your query line-by-line
You can ask MotherDuck AI to correct and fix up your query line-by-line using the prompt_fix_line
table function. This feature is especially useful for syntax or spelling errors in large queries, as only the erroneous line will be rewritten, which is faster and more precise than the prompt_fixup
method.
Syntax
CALL prompt_fix_line('<SQL query>', error='<Error message>', [include_tables=['<table_name>', '<table_name>']]);
Example usage
We use MotherDuck's sample Hacker News dataset from MotherDuck's sample data database.
CALL prompt_fix_line('SEELECT COUNT(*) as domain_count FROM hn.hackers', error='
Parser Error: syntax error at or near "SEELECT"
LINE 1: SEELECT COUNT(*) as domain_count FROM h...
^', [include_tables=['<table_name>', '<table_name>']);
Output of this SQL statement is a two column table with the following content:
line_number | line_content |
---|---|
1 | SELECT COUNT(*) as domain_count FROM hn.hackers |
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