Skip to content

branch-4.1: [Enhance](ai_func) Support dedicate embed properties in AI RESOURCE (#67673) - #68384

Merged
yiguolei merged 1 commit into
apache:branch-4.1from
linrrzqqq:pick-67673-branch-4.1
Sep 23, 2026
Merged

yiguolei merged 1 commit into
apache:branch-4.1from
linrrzqqq:pick-67673-branch-4.1

Conversation

@linrrzqqq

Copy link
Copy Markdown
Collaborator

pick: #67673

…pache#67673)

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

- Add dedicated embedding properties to AI resources:
  - `ai.embed.endpoint`
  - `ai.embed.provider_type`
  - `ai.embed.model_name`
  - `ai.embed.api_key`
- Require at least one complete property group when creating an AI
resource:
  - the general `ai.*` group, or
  - the `ai.embed.*` group
- Use `ai.embed.*` when executing the `EMBED` function if the embed
property group is configured.
- Fall back to the general `ai.*` properties otherwise.
- Mask `ai.embed.api_key` when displaying resource properties.
- Keep other AI functions using the general `ai.*` properties.

```text
Doris> CREATE RESOURCE 'default_combine_resource'
    -> PROPERTIES (
    ->     'type' = 'ai',
    ->
    ->     'ai.provider_type' = 'QWEN',
    ->     'ai.endpoint' = 'https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions',
    ->     'ai.model_name' = 'qwen-plus',
    ->     'ai.api_key' = '<general-api-key>',
    ->     'ai.effort' = 'high',
    ->
    ->     'ai.embed.provider_type' = 'QWEN',
    ->     'ai.embed.endpoint' = 'https://dashscope.aliyuncs.com/compatible-mode/v1/embeddings',
    ->     'ai.embed.model_name' = 'text-embedding-v4',
    ->     'ai.embed.api_key' = '<embedding-api-key>',
    ->
    ->     'ai.embed.mm.provider_type' = 'QWEN',
    ->     'ai.embed.mm.endpoint' = 'https://dashscope.aliyuncs.com/api/v1/services/embeddings/multimodal-embedding/multimodal-embedding',
    ->     'ai.embed.mm.model_name' = 'qwen3-vl-embedding',
    ->     'ai.embed.mm.api_key' = '<multimodal-api-key>',
    ->
    ->     'ai.dimensions' = '1024'
    -> );
Query OK, 0 rows affected (0.026 sec)

Doris> set default_ai_resource = 'default_combine_resource';
Query OK, 0 rows affected (0.009 sec)

Doris> SELECT array_size(EMBED('this is a test'));
+-------------------------------------+
| array_size(EMBED('this is a test')) |
+-------------------------------------+
|                                1024 |
+-------------------------------------+
1 row in set (1.729 sec)

Doris> EXPLAIN SELECT array_size(EMBED('this is a test'));
+---------------------------------------------------------------------------+
| Explain String(Nereids Planner)                                           |
+---------------------------------------------------------------------------+
| PLAN FRAGMENT 0                                                           |
|   OUTPUT EXPRS:                                                           |
|     array_size(EMBED('this is a test'))[#0]                               |
|   PARTITION: UNPARTITIONED                                                |
|                                                                           |
|   HAS_COLO_PLAN_NODE: false                                               |
|                                                                           |
|   VRESULT SINK                                                            |
|      MYSQL_PROTOCOL                                                       |
|                                                                           |
|   0:VUNION(11)                                                            |
|      constant exprs:                                                      |
|          cardinality(embed('default_combine_resource', 'this is a test')) |
|                                                                           |
|                                                                           |
|                                                                           |
| ========== STATISTICS ==========                                          |
+---------------------------------------------------------------------------+
17 rows in set (0.030 sec)

Doris> SELECT AI_TRANSLATE('this is a test', 'chinese');
+-------------------------------------------+
| AI_TRANSLATE('this is a test', 'chinese') |
+-------------------------------------------+
| 这是一个测试                              |
+-------------------------------------------+
1 row in set (1.269 sec)

Doris> EXPLAIN SELECT AI_TRANSLATE('this is a test', 'chinese');
+--------------------------------------------------------------------------------+
| Explain String(Nereids Planner)                                                |
+--------------------------------------------------------------------------------+
| PLAN FRAGMENT 0                                                                |
|   OUTPUT EXPRS:                                                                |
|     AI_TRANSLATE('this is a test', 'chinese')[#0]                              |
|   PARTITION: UNPARTITIONED                                                     |
|                                                                                |
|   HAS_COLO_PLAN_NODE: false                                                    |
|                                                                                |
|   VRESULT SINK                                                                 |
|      MYSQL_PROTOCOL                                                            |
|                                                                                |
|   0:VUNION(11)                                                                 |
|      constant exprs:                                                           |
|          ai_translate('default_combine_resource', 'this is a test', 'chinese') |
|                                                                                |
|                                                                                |
|                                                                                |
| ========== STATISTICS ==========                                               |
+--------------------------------------------------------------------------------+
17 rows in set (0.010 sec)

Doris> EXPLAIN SELECT EMBED(
    ->     CAST(
    ->         '{"content_type":"image/png","uri":"https://example.com/image.png"}'
    ->         AS JSON
    ->     )
    -> );
+--------------------------------------------------------------------------------------------------------------------------------+
| Explain String(Nereids Planner)                                                                                                |
+--------------------------------------------------------------------------------------------------------------------------------+
| PLAN FRAGMENT 0                                                                                                                |
|   OUTPUT EXPRS:                                                                                                                |
|     EMBED(                                                                                                                     |
|     CAST(                                                                                                                      |
|         '{"content_type":"image/png","uri":"https://example.com/image.png"}'                                                   |
|         AS JSON                                                                                                                |
|     )                                                                                                                          |
| )[#0]                                                                                                                          |
|   PARTITION: UNPARTITIONED                                                                                                     |
|                                                                                                                                |
|   HAS_COLO_PLAN_NODE: false                                                                                                    |
|                                                                                                                                |
|   VRESULT SINK                                                                                                                 |
|      MYSQL_PROTOCOL                                                                                                            |
|                                                                                                                                |
|   0:VUNION(11)                                                                                                                 |
|      constant exprs:                                                                                                           |
|          embed('default_combine_resource', CAST('{"content_type":"image/png","uri":"https://example.com/image.png"}' AS json)) |
|                                                                                                                                |
|                                                                                                                                |
|                                                                                                                                |
| ========== STATISTICS ==========                                                                                               |
+--------------------------------------------------------------------------------------------------------------------------------+
```

None
@linrrzqqq
linrrzqqq requested a review from yiguolei as a code owner September 22, 2026 08:56
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@linrrzqqq linrrzqqq changed the title [Enhance](ai_func) Support dedicate embed properties in AI RESOURCE (#67673) branch-4.1: [Enhance](ai_func) Support dedicate embed properties in AI RESOURCE (#67673) Sep 22, 2026
@linrrzqqq

Copy link
Copy Markdown
Collaborator Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 90.27% (102/113) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 95.12% (78/82) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 60.18% (26150/43456)
Line Coverage 44.85% (270227/602489)
Region Coverage 40.66% (214262/526999)
Branch Coverage 42.15% (99084/235054)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 95.06% (77/81) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 74.54% (31517/42281)
Line Coverage 58.75% (351172/597698)
Region Coverage 55.44% (292811/528183)
Branch Coverage 56.31% (132215/234791)

@yiguolei

Copy link
Copy Markdown
Contributor

skip buildall

@yiguolei
yiguolei merged commit 2eb1ec3 into apache:branch-4.1 Sep 23, 2026
39 of 40 checks passed
@linrrzqqq
linrrzqqq deleted the pick-67673-branch-4.1 branch September 23, 2026 00:54
yiguolei pushed a commit that referenced this pull request Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants