Skip to main content
Last updated on

AI_FILTER

Description​

Filters text based on given conditions.

Syntax​

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

Parameters​

ParameterDescription
<resource_name>The specified resource name, optional
<text>The information to be evaluated

Return Value​

Returns a boolean value.

If any input is NULL, returns NULL.

The result is generated by the large language model, so the output may not be fixed.

Example​

Suppose you have the following table representing comments received by a courier company:

CREATE TABLE user_comments (
id INT,
comment VARCHAR(500)
) DUPLICATE KEY(id)
DISTRIBUTED BY HASH(id) BUCKETS 10
PROPERTIES (
"replication_num" = "1"
);

If you want to query the positive comments, you can use:

SELECT id, comment FROM user_comments
WHERE AI_FILTER('resource_name', CONCAT('This is a positive comment: ', comment));

The result may look like:

+------+--------------------------------------------+
| id | comment |
+------+--------------------------------------------+
| 1 | Absolutely fantastic, highly recommend it. |
| 3 | This product is amazing and I love it. |
+------+--------------------------------------------+