Note: SQL Writer is a Benchling AI feature. See the AI at Benchling page for information on how to enable it and other AI-based features.
Running into an error with a query you are working on? Need help modifying an existing query to bring in some additional data? Having trouble getting started creating a new insights block for your team? Let the SQL Writer give you a hand by including special --! comments that explain what you are looking for or need help with directly in your SQL. The SQL Writer will analyze your SQL, comments, in relation to your warehouse setup to suggest an update to your SQL that hopefully matches your intentions.
Using the SQL Writer
Once you have the SQL Writer feature enabled, you will get a new purple sparkle button above your SQL in the Insights editor.
To distinguish between standard SQL comments -- and comments that you want directed towards the SQL Writer for help, use the --! comment format to explain what you are looking for or need help with. The SQL Writer will only run if at least one of these comments is found.
After clicking the SQL Writer button, the system will process your request in the context of your warehouse setup to come up with a suggestion. Because this feature relies on AI it can not be guaranteed to output SQL that perfectly matches your intent, or possibly even perfectly valid SQL. In the case the suggestion is determined to be invalid, the error will be inserted into the SQL. Often, just clicking "Generate" and letting it try to fix the error itself is sufficient to fix it.
When the SQL Writer generates a valid SQL suggestion, you will automatically get a preview of the results that you can use to help validate that the query is behaving as you expect.
To help understand what changes are being made, you can toggle on the "Compare to original" mode where you will see the original query in your Insights dashboard block on the left, and the latest suggestion on the right. The suggestion is fully editable. You may update it or add new --! comments and retry the suggestion but now with this as the starting point. We find that if the SQL Writer provides invalid SQL, a single retry is generally sufficient to fix the issue and get to working, valid SQL.
When you are ready, clicking the Accept SQL button will replace your original SQL with the suggestion and automatically run the query, showing you the results.
Limitations
- The system is currently optimized around
$rawtables and doesn't understand the corresponding views well. We recommend not mixing views and$rawtables in your queries to the SQL Writer. - Retrying the suggestion does not have the context of prior attempts, so you may need to re-add comments to get it to do what you want.
- The amount of detail the SQL Writer gets about your warehouse decreases somewhat as the size of your warehouse increases (number of tables), so for best performance especially in particularly large warehouses (thousands of tables) we recommend explicitly mentioning or including the tables you know you will need in your initial query or comments.
- Always validate both the SQL suggestion as well as the resulting output to ensure it matches your expectations. AI based systems, much like humans, are prone to errors, misunderstandings, and ambiguities.
Feedback
We value your feedback to help us improve this new tool. Using the thumbs up/down buttons helps us get a sense of if the tool is being found useful. You can also click the Tell us more button after that to provide us with an explanation or more detail.
Security and privacy
For more information about the privacy and security for AI-powered features, please see Data protection and security for AI at Benchling.