Skip to content

branch-4.1: [Feature](multimodal_embed) Support multimodal(file) embed - #66461

Merged
yiguolei merged 2 commits into
apache:branch-4.1from
linrrzqqq:pick-62147-branch-4.1
Aug 7, 2026
Merged

branch-4.1: [Feature](multimodal_embed) Support multimodal(file) embed#66461
yiguolei merged 2 commits into
apache:branch-4.1from
linrrzqqq:pick-62147-branch-4.1

Conversation

@linrrzqqq

Copy link
Copy Markdown
Collaborator

pick: #62147 and #66242

@linrrzqqq
linrrzqqq requested a review from yiguolei as a code owner August 5, 2026 03:21
@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

Copy link
Copy Markdown
Collaborator Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 77.62% (1904/2453)
Line Coverage 64.47% (34021/52774)
Region Coverage 64.47% (17210/26694)
Branch Coverage 53.96% (9207/17064)

)

Support image/video/audio embedding from json.

Supported multimodal_embed AI provider : Gemini(image, video, audio),
Qwen(image, video), Voyage(image, video), Jina(image)

Supported authentication methods include IAM + EXTERNAL_ID / AK + SK
```text
-- ima role, video
mysql> SELECT ARRAY_SIZE(
    ->     EMBED(
    ->     'qwen_mul_embed',
    ->     CAST('{
    '>         "uri": "s3://selectdb-qa-test-3/lzq-multimodal-test/video/45944deac7d96c872f559f2ef94ea0a9.mp4",
    '>             "content_type": "video/mp4",
    '>             "provider": "AWS",
    '>             "endpoint": "s3.us-east-1.amazonaws.com",
    '>             "region": "us-east-1",
    '>             "role_arn": "arn:aws:iam::447051187841:role/lzq-role-test",
    '>             "external_id": "1001"
    '>         }' AS JSON)
    ->     )
    -> ) AS video_embed_size;
+------------------+
| video_embed_size |
+------------------+
|             2560 |
+------------------+

-- ima role, video
mysql> SELECT ARRAY_SIZE(
    ->     EMBED(
    ->         'qwen_mul_embed',
    ->         CAST('{
    '>             "uri": "s3://selectdb-qa-test-3/lzq-multimodal-test/image/ai-agg.png",
    '>             "content_type": "image/png",
    '>             "provider": "AWS",
    '>             "endpoint": "s3.us-east-1.amazonaws.com",
    '>             "region": "us-east-1",
    '>             "role_arn": "arn:aws:iam::447051187841:role/lzq-role-test",
    '>              "external_id": "1001"
    '>         }' AS JSON)
    ->     )
    -> ) AS img_embed_size;
+----------------+
| img_embed_size |
+----------------+
|           2560 |
+----------------+

-- gemini multimodal embed
mysql> SELECT ARRAY_SIZE(
    ->     EMBED(
    ->         'gemini_mul_embed',
    ->         CAST('{
    '>             "uri": "s3://selectdb-qa-test-3/lzq-multimodal-test/image/ai-agg.png",
    '>             "content_type": "image/png",
    '>             "provider": "AWS",
    '>             "endpoint": "s3.us-east-1.amazonaws.com",
    '>             "region": "us-east-1",
    '>             "role_arn": "arn:aws:iam::447051187841:role/lzq-role-test",
    '>              "external_id": "1001"
    '>         }' AS JSON)
    ->     )
    -> ) AS img_embed_size;
+----------------+
| img_embed_size |
+----------------+
|           3072 |
+----------------+

-- ak, sk
Doris> SELECT ARRAY_SIZE(
    ->     EMBED(
    ->         'qwen_mul_embed',
    ->         CAST('{
    '>             "uri": "s3://<bucket>/<key>/test_img.png",
    '>             "content_type": "image/png",
    '>             "endpoint": "cos.ap-hongkong.myqcloud.com",
    '>             "region": "ap-hongkong",
    '>             "ak": "<ak>",
    '>             "sk": "<sk>"
    '>         }' AS JSON)
    ->     )
    -> ) AS img_embed_size_ak_sk;
+----------------------+
| img_embed_size_ak_sk |
+----------------------+
|                 2560 |
+----------------------+
```
@linrrzqqq
linrrzqqq force-pushed the pick-62147-branch-4.1 branch from fc4f189 to 85ee3c6 Compare August 5, 2026 12:23
@linrrzqqq

Copy link
Copy Markdown
Collaborator Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 49.38% (40/81) 🎉
Increment coverage report
Complete coverage report

Problem Summary:

The framework's default NULL implementation unwraps Nullable arguments
and executes AI functions for every input row. For partially NULL
inputs, the nested placeholder values of NULL rows are still included in
prompts and sent to external AI providers.

This causes unnecessary remote requests and token consumption. It also
requires special handling for embedding results to preserve the original
row order without duplicating large embedding vectors.

This PR:

- Disables the framework's default NULL implementation for all
`AIFunction` subclasses.
- Determines the Nullable return type in the `AIFunction` base class.
- Extracts nested prompt columns and merges argument null maps in the
common AI execution path.
- Skips NULL rows before building prompts or sending requests.
- Restores NULL rows in the final result while preserving the original
row order.
- Handles both text and multimodal Nullable inputs for `EMBED`.
- Expands embedding array offsets in place, avoiding a copy of the
nested Float32 embedding data.
- Returns a constant NULL column when all input rows are NULL.

### Release note

Fix AI scalar functions to skip NULL input rows instead of sending their
placeholder values to external AI providers.
@linrrzqqq
linrrzqqq force-pushed the pick-62147-branch-4.1 branch from 85ee3c6 to 66f1783 Compare August 6, 2026 02:09
@linrrzqqq

Copy link
Copy Markdown
Collaborator Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 91.37% (593/649) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.64% (30464/41369)
Line Coverage 57.62% (335182/581673)
Region Coverage 54.42% (278508/511810)
Branch Coverage 55.40% (124869/225389)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 50.63% (40/79) 🎉
Increment coverage report
Complete coverage report

@yiguolei
yiguolei merged commit 895c293 into apache:branch-4.1 Aug 7, 2026
28 of 31 checks passed
@linrrzqqq
linrrzqqq deleted the pick-62147-branch-4.1 branch August 7, 2026 06:32
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