All Products
Search
Document Center

ApsaraDB for SelectDB:AI_FIXGRAMMAR

Last Updated:Mar 28, 2026

Corrects syntax errors in a text string using a Large Language Model (LLM).

Syntax

AI_FIXGRAMMAR([<resource_name>], <text>)

Parameters

ParameterDescription
<resource_name>(Optional) The specified resource name.
<text>The text to correct.

Return value

  • Returns the corrected text string.

  • Returns NULL if any input value is NULL.

  • Because the result is generated by an LLM, the output may vary.

Examples

Example 1: Use the default AI resource

Set the default AI resource, then call AI_FIXGRAMMAR without specifying a resource name.

SET default_ai_resource = 'resource_name';
SELECT AI_FIXGRAMMAR('SelectDB a great system DB') AS Result;

Output:

+------------------------------------------+
| Result                                   |
+------------------------------------------+
| SelectDB is a great database system.     |
+------------------------------------------+

Example 2: Specify an AI resource

Pass the resource name as the first argument to override the default.

SELECT AI_FIXGRAMMAR('resource_name', 'I am like to using SelectDB') AS Result;

Output:

+-----------------------+
| Result                |
+-----------------------+
| I like using SelectDB |
+-----------------------+