Skip to content

Instantly share code, notes, and snippets.

@jeanmidevacc
Created August 23, 2025 15:21
Show Gist options
  • Save jeanmidevacc/3b65780548ecaf2e1479beae63514570 to your computer and use it in GitHub Desktop.
Save jeanmidevacc/3b65780548ecaf2e1479beae63514570 to your computer and use it in GitHub Desktop.
snapshot from the dfatabricks documentation to build function on top of ai_query https://docs.databricks.com/aws/en/sql/language-manual/functions/ai_query
CREATE FUNCTION correct_grammar(text STRING)
RETURNS STRING
RETURN ai_query(
'databricks-meta-llama-3-3-70b-instruct',
CONCAT('Correct this to standard English:\n', text));
> GRANT EXECUTE ON correct_grammar TO ds;
- DS fixes grammar issues in a batch.
> SELECT
* EXCEPT text,
correct_grammar(text) AS text
FROM articles;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment