All Products
Search
Document Center

MaxCompute:Process Unstructured Data with AI Functions and BLOBs

Last Updated:Jul 01, 2026

This tutorial demonstrates how to use the MaxCompute AI_GENERATE function to call a multimodal model deployed on PAI EAS, read unstructured data from a BLOB column, and process images directly with SQL. The workflow reads image data from OSS through an object table, writes it to a MaxCompute BLOB column for higher I/O bandwidth on repeated computation, and then invokes the multimodal model via SQL AI Functions.

Prerequisites

  1. Activate MaxCompute and Create a MaxCompute project. Skip if already done.

  2. PAI-EAS (Elastic Algorithm Service) is activated. Skip if already done.

  3. OSS is activated. Skip if already done.

Step 1: Create an OSS bucket and upload data

  1. Log in to the OSS console.

    Create a bucket named ot-demo in OSS. OSS console quick start.

  2. Create the directory /object_table/image_demo/ in the bucket and upload the image data image_demo.zip.

Step 2: Create and deploy a PAI EAS model service

  1. Log on to the PAI console, select a region in the upper-left corner, and create a workspace.

  2. Go to the workspace details page, click Model Gallery on the left, select Qwen2.5-Omni-3B, and click Deploy.

  3. Select an instance type with an L20 GPU (48 GB VRAM) and click Deploy. Check the deployment status in Task Management. The status shows Running when deployment completes.

  4. In the left-side navigation pane, click Model Deployment to open EAS. Locate the deployed service, click View Call Information, and note the endpoint and token.

    -- The following information is required for creating the remote model in Step 3.
    Model name (subject to the actual EAS service name):quickstart_deploy_*****_apdf
    Endpoint (VPC address):http://*****.cn-beijing.pai-eas.aliyuncs.com (use only the part before
      aliyuncs.com)
    apikey(Token):****************************************==

Step 3: Create an object table

Create an object table and view its metadata.

SET odps.namespace.schema=true; -- Enable tenant-level schema syntax

CREATE OBJECT TABLE IF NOT EXISTS image_demo
WITH SERDEPROPERTIES ('odps.properties.rolearn'='acs:ram::<uid>:role/aliyunodpsdefaultrole')
LOCATION 'oss://oss-cn-<region>-internal.aliyuncs.com/object_table/image_demo/';

-- Refresh metadata
ALTER TABLE image_demo REFRESH METADATA;

-- Query image count
SET odps.namespace.schema=true;
SELECT COUNT(*) AS ROW_COUNT FROM image_demo;

-- Sample output:
+------------+
| row_count  |
+------------+
| 10         |
+------------+

Step 4: Create a table with a BLOB column and insert data

-- Create a table with a BLOB column
CREATE TABLE IF NOT EXISTS speech_segments_table (
    image_name STRING COMMENT 'Image identifier',
    image_desc blob COMMENT 'Image data'
)
COMMENT 'SQL image data table'
TBLPROPERTIES (
  "table.format.version"="2"
);

-- Insert data
SET odps.namespace.schema=true;  
INSERT INTO speech_segments_table
SELECT 
    t.key AS image_name,
    to_blob(image_binary) AS image_desc
FROM (
    SELECT key, GET_DATA_FROM_OSS('<project_name>.<schema>.image_demo', key) AS image_binary
    FROM <project_name>.<schema>.image_demo
) t;

SELECT * FROM speech_segments_table;
-- Sample output:
+------------+------------+
| image_name | image_desc |
+------------+------------+
| test01.png | CAEQ**Mg== |
| test02.png | CAEQ**Mg== |
| test03.png | CAEQ**Mg== |
| test04.png | CAEQ**Mg== |
| test05.png | CAEQ**Mg== |
| test06.png | CAEQ**Mg== |
| test07.png | CAEQ**Mg== |
| test08.png | CAEQ**Mg== |
| test09.png | CAEQ**Mg== |
| test10.png | CAEQ**Mg== |
+------------+------------+

Step 5: Create a VPC network connection

  1. Log in to the MaxCompute console and select a region in the upper-left corner.

  2. In the left-side navigation pane, choose Manage Configurations > Network Connection .

  3. Create a network connection between MaxCompute and the target VPC. The VPC ID can be any VPC, and the vSwitch can be in any zone.

Step 6: Register the Omni multimodal remote model

SET odps.namespace.schema=true;
SET odps.session.networklink=<your vpc name>;

CREATE MODEL PAI_EAS_Qwen25_Omni_3B_blob_image WITH VERSION v1 
INPUT(data BINARY, promt STRING) 
OPTIONS(
    MODEL_SOURCE_TYPE = 'REMOTE',
    MODEL_TYPE = 'MLLM',
    TASKS = 'text-generation',
    PAI_EAS_MODEL_NAME = 'Qwen2.5-Omni-3B',
    PAI_EAS_SERVICE_NAME = 'quickstart_deploy_*****', 
    ENDPOINT = 'http://*****.vpc.cn-<region>.pai-eas.aliyuncs.com',
    APIKEY = '*****',
    PAI_EAS_SYNC_MODE = 'true'
)
COMMENT "PAI EAS remote model";

View remote model details

-- View the remote model.
SET odps.namespace.schema=true;
SET odps.session.networklink=<your vpc name>;
DESC model PAI_EAS_Qwen25_Omni_3B_blob_image;

-- Sample output.
+------------------------------------------------------------------------------------+
|                  Model Information                                                 |
+------------------------------------------------------------------------------------+
| Owner:                    ***********                                              |
| Project:                  ***********                                              |
| Schema:                   default                                                  |
| Model Name:               pai_eas_qwen25_omni_3b_blob_image                        |
| Model Type:               MLLM                                                     |
| Source Type:              REMOTE                                                   |
| Default Version:          v1                                                       |
| CreateTime:               2026-04-16 17:25:54                                      |
| LastModifiedTime:         2026-04-16 17:25:54                                      |
| Model ID:                 8e6203294ba24c73bfe1a8ac0********                        |
| Comment:                  PAI EAS remote model                                     |
+------------------------------------------------------------------------------------+
|                Version Information                                                 |
+------------------------------------------------------------------------------------+
| Owner:                    ***********                                              |
| Project:                  ***********                                              |
| Schema:                   default                                                  |
| Model Name:               pai_eas_qwen25_omni_3b_blob_image                        |
| Model Type:               MLLM                                                     |
| Source Type:              REMOTE                                                   |
| Version Name:             v1                                                       |
| Version ID:               08fae3f0a4674f9f9b03b82e2***********                     |
| Path:                                                                              |
| CreateTime:               2026-04-16 17:25:54                                      |
| LastModifiedTime:         2026-04-16 17:25:54                                      |
| apikey:                   ***************************                              |
| endpoint:                 http://*****.vpc.cn-beijing.pai-eas.aliyuncs.com         |
| pai_eas_model_name:       Qwen2.5-Omni-3B                                          |
| pai_eas_service_name:     quickstart_deploy_*****                                  |
| pai_eas_sync_mode:        true                                                     |
| remote_service_type:      PAI-EAS                                                  |
+------------------------------------------------------------------------------------+
| Input           | Type       | Comment                                             |
+------------------------------------------------------------------------------------+
| data            | binary     |                                                     |
| promt           | string     |                                                     |
+------------------------------------------------------------------------------------+

Step 7: Process image data with the AI_GENERATE function

SET odps.namespace.schema=true; 
SET odps.mcqa.disable=true; -- Disable Query Acceleration mode. AI Functions do not support Query Acceleration mode.
SET odps.session.networklink=<your vpc name>;
SELECT
  image_name,
  AI_GENERATE(
    PAI_EAS_Qwen25_Omni_3B_blob_image, DEFAULT_VERSION, speech_data,
    "Extract all text from the image. Output only the text content, with no introduction,explanation, Markdown formatting, or additional comments."
  ) AS sql_dml
  FROM (
    SELECT image_name, read_blob(image_desc) AS speech_data
    FROM <project name>.<schema>.speech_segments_table 
) ;

Sample output

SET odps.mcqa.disable=true; disables Query Acceleration mode. AI Functions do not support Query Acceleration mode.

-- Sample output:

+------------+---------+
| image_name | sql_dml |
+------------+---------+
| test01.png | -- 创建包含blob列的表(Delta Table)CREATE TABLE IF NOT EXISTS `speech_segments_table` (`video_name` STRING COMMENT '视频唯一标识',`segment_index` BIGINT COMMENT '片段序号',`speech_data` BLOB COMMENT '语音片段WAV数据',`start_time` DOUBLE COMMENT '开始时间(秒)',`end_time` DOUBLE COMMENT '结束时间(秒)',`duration` DOUBLE COMMENT '时长(秒)')COMMENT '语音片段表'TBLPROPERTIES ("table.format.version"="2");|
| test02.png | -- 读取视频元信息SET odps.namespace.schema=true;SELECT * FROM video_demo;SELECT COUNT(*) AS ROW_COUNT FROM video_demo; |
| test03.png | -- 创建视频提取语音的udtf CREATE_FUNCTION `mp4_extract_speech`AS 'mp4_extract_speech.Mp4ExtractSpeech USING 'mp4_extract_speech.py, moviepy_deps_py3.zip, ffmpeg_linux.zip' ;|
| test04.png | -- 查看远程模型。SET odps.namespace.schema=true;SET odps.session.networklink=ot_demo; desc model PAI_EAS_Qwen25_Omni_3B_blob; |
| test05.png | -- 周期性刷新历史 show refresh task history for object table ot_demo_day03;ALTER TABLE ot_demo_day03 REFRESH Metadata; |
| test06.png | -- 刷新表缓存 alter table test_ot1 refresh metadata;set odps.mcqa.disable=true;set odps.namespace.schema=true;select * from testOt1; |
| test07.png | -- 通过data列查询文件内容 set odps.mcqa.disable=true;set odps.namespace.schema=true;select data from test_ot_data; |
| test08.png | -- 通过函数查文件内容 set odps.mcqa.disable=TRUE;set odps.namespace.schema=true;select * from test_ot_data_catalog; |
| test09.png | -- 查询0T表中的元信息数据,但不会下载数据 set odps.namespace.schema=true;select * from test_get_signed_url_from_oss2; 未读条目个数 |
| test10.png | add py binary_pdf2png.py -f;  add py binary_pdf2text.py -f;  add archive pdf_tools_cp37.tar.gz -f; |
+------------+---------+