About Alibaba Cloud E-MapReduce (EMR), an open-source big data platform, is a fully managed cloud-native big data platform built on the open-source ecosystem. It is deeply compatible with Hadoop, Spark, StarRocks, Presto, Hudi, Iceberg, and Paimon, and provides three flexible deployment models: Serverless, on ECS, and on ACK.
About Alibaba Cloud E-MapReduce: Serverless Open-Source Big Data Platform
EMR Serverless Spark natively supports hybrid scalar-vector retrieval through DLF Global Index, enabling multi-dimensional queries in a single SQL statement. By combining the vector_search UDF with standard WHERE filters, Spark can jointly use the Lumina vector index and B-tree scalar index for efficient execution.
This approach makes access simple, removes index operations overhead, and supports serverless pay-as-you-go billing with no idle cost. Built-in Celeborn and the Fusion engine also deliver up to 3x better performance than open-source Spark. It enables in-lake search with strong consistency and low latency, and is well suited for autonomous driving, multimodal e-commerce search, RAG knowledge bases, and offline vector batch processing.
Traditionally, semantic search and structured filtering required separate systems, leading to data movement, higher cost, and consistency challenges. With EMR Serverless Spark, both can be done in one SQL query.
Traditional data retrieval faces a dilemma:
WHERE weather='heavy_rain' AND speed>80): precise, but unable to find semantically similar scenariosTake autonomous driving as an example. Engineers often need queries like:
"From historical data, find the Top-10 most similar cases where the weather is heavy rain and the road type is urban road."
Under a traditional architecture, this requires two steps: first retrieve Top-K candidates from the vector database, then filter them again in the business database. That means two queries, data movement, and possibly fewer than K valid results.
The value of hybrid retrieval is that it adds scalar filters while performing vector nearest-neighbor search, delivering results that are both similar and compliant in one step.
Alibaba Cloud EMR Serverless Spark leverages the Global Index capability of DLF Paimon tables in the data lake to unify vector indexes and B-tree indexes within Spark SQL’s query execution framework, enabling joint execution of scalar filtering and vector nearest-neighbor retrieval.
Both types of indexes can be created on the same Paimon table. When Spark executes a query, it automatically coordinates both index paths without requiring users to manage the underlying scheduling.

To enable a vector index on a Paimon table, you only need to specify table properties during table creation. After Spark writes data, the index becomes effective automatically:
CREATE TABLE ai_dataset.scene_vectors (
id BIGINT,
path STRING,
weather STRING,
road_type STRING,
speed_range STRING,
embedding ARRAY<FLOAT>
) USING paimon
TBLPROPERTIES (
'row-tracking.enabled' = 'true',
'data-evolution.enabled' = 'true',
'morax.lumina-index.enabled' = 'true',
'global-index.lumina.index-column' = 'embedding',
'lumina.index.dimension' = '1152'
);
morax.* parameters are declared in TBLPROPERTIES, DLF automatically schedules index building based on the vector column in the table.morax.* parameters were not declared during table creation, you can manually trigger index construction.vector_search: The Vector Retrieval Function in Spark SQLSpark SQL introduces the vector_search table function, allowing vector nearest-neighbor retrieval directly in SQL:
SELECT * FROM vector_search(
'ai_dataset.scene_vectors',
'embedding',
array(0.12F, 0.34F, ...),
10
);
This query finds the Top-K records most similar to the input query vector.
By combining the results of vector_search with scalar WHERE conditions, you can perform hybrid retrieval:
SELECT id, path, weather, road_type, speed_range
FROM vector_search(
'ai_dataset.scene_vectors',
'embedding',
array(0.12F, 0.34F, ...),
10
)
WHERE weather = 'heavy_rain'
AND road_type = 'urban';
Spark uses the vector index to retrieve nearest-neighbor candidates and the B-tree index to filter scalar conditions, completing both steps collaboratively without cross-system data movement.
Perception models often perform poorly in adverse weather conditions and need a large amount of scenario-specific data for retraining and fine-tuning. However, such scenarios make up only a tiny fraction of road-collected data, and manual frame-by-frame filtering is highly inefficient.
The following example shows how EMR Serverless Spark SQL can support the full workflow of data ingestion into the lake → hybrid retrieval → training set export.
A road-test vehicle generates large numbers of video frames every day, stored in OSS. With Alibaba Cloud EMR Serverless Spark AI Function, a single SQL statement can read images, extract labels, and generate embeddings:
CREATE TABLE IF NOT EXISTS ad_dataset.driving_scenes (
id BIGINT,
path STRING,
weather STRING,
lighting STRING,
road_type STRING,
objects ARRAY<STRING>,
risks ARRAY<STRING>,
scene_tag STRING,
sensor_type STRING,
embedding ARRAY<FLOAT>
) USING paimon
TBLPROPERTIES (
'row-tracking.enabled' = 'true',
'data-evolution.enabled' = 'true',
'morax.lumina-index.enabled' = 'true',
'global-index.lumina.index-column' = 'embedding',
'lumina.index.dimension' = '1152',
'global-index.btree.index-columns' = 'weather,road_type,lighting,objects,risks,scene_tag'
);
WITH raw AS (
SELECT
monotonically_increasing_id() AS id,
path,
ai_query(
'You are an autonomous driving data analysis assistant. '
|| 'Based on the input road scene image, output a JSON object with the following structure: '
|| '{"weather": "sunny/cloudy/rainy/snowy/foggy/other", '
|| '"lighting": "daytime/nighttime/dusk/tunnel/other", '
|| '"road_type": "urban/expressway/rural/intersection/ramp/parking_lot/other", '
|| '"objects": ["car", "pedestrian", "bicycle", "motorcycle", "bus", "truck", '
|| '"traffic_light", "traffic_sign", "cone", "construction_equipment"], '
|| '"risks": ["construction", "congestion", "occlusion", "accident_signs", '
|| '"wrong_way", "illegal_parking", "water_logging", "ice", "other"]}. '
|| 'All field values must exactly match the enum options above (case-sensitive). '
|| 'objects and risks must be arrays of strings; use empty array [ ] if none. '
|| 'Do not output any extra text, explanation, Markdown, or code block. '
|| 'Output only valid JSON.',
data => content
) AS scene_json,
ai_embedding_multimodal(content) AS embedding
FROM read_files(
'oss://ad-team-raw/camera_front/2025-*/',
suffix => 'jpg,png'
)
)
INSERT INTO ad_dataset.driving_scenes
SELECT
id,
path,
get_json_object(scene_json, '$.weather') AS weather,
get_json_object(scene_json, '$.lighting') AS lighting,
get_json_object(scene_json, '$.road_type') AS road_type,
from_json(get_json_object(scene_json, '$.objects'), 'ARRAY<STRING>') AS objects,
from_json(get_json_object(scene_json, '$.risks'), 'ARRAY<STRING>') AS risks,
'normal' AS scene_tag,
'camera_front' AS sensor_type,
embedding
FROM raw;
One INSERT statement completes three tasks: reading OSS images, automatically labeling and vectorizing them through AI functions, and writing them into a Paimon table with dual indexes. Subsequent queries can then benefit from vector and B-tree acceleration.
If the perception model has a high error rate in "heavy rain + urban road" scenarios, we can retrieve similar historical cases for retraining:
# Use the embedding of a typical misjudged scene as the query vector
query_vec = spark.sql("""
SELECT embedding
FROM ad_dataset.driving_scenes
WHERE path = 'oss://ad-team-raw/camera_front/2025-10-15/frame_CF_003812.jpg'
""").collect()[0]["embedding"]
vec_literal = "array(" + ",".join(f"{v}f" for v in query_vec) + ")"
# Retrieve historical cases most similar to a typical misjudged scene under rainy urban road conditions
result = spark.sql(f"""
SELECT id, path, weather, road_type, lighting, objects, risks
FROM vector_search(
'ad_dataset.driving_scenes',
'embedding',
{vec_literal},
500
)
WHERE weather = 'rainy'
AND road_type = 'urban'
AND lighting = 'nighttime'
""")
result.show(truncate=False)
The advantage of hybrid retrieval is that vector search first finds semantically similar scenes from massive data, and then B-tree indexes accurately filter by weather, road type, and time of day. The two paths work together in a single step. Traditional solutions require retrieving candidates from a vector store first and then filtering again in the business database, while also failing to guarantee the final result count.
Training does not require just one type of scenario. With Spark SQL batch processing, you can recall multiple adverse scenarios in one job and write them directly into the training dataset:
from functools import reduce
from pyspark.sql import DataFrame
SCENES = [
(
"oss://ad-team-raw/camera_front/2025-10-15/frame_CF_003812.jpg",
{"weather": "rainy", "road_type": "urban"},
500,
"rainy_urban",
),
(
"oss://ad-team-raw/camera_front/2025-11-02/frame_CF_001547.jpg",
{"weather": "foggy", "road_type": "expressway"},
500,
"foggy_expressway",
),
(
"oss://ad-team-raw/camera_front/2025-12-08/frame_CF_000923.jpg",
{"weather": "snowy", "road_type": "rural", "lighting": "nighttime"},
300,
"snowy_rural_nighttime",
),
]
def recall_scene(anchor_path: str, filters: dict, top_k: int, source_label: str) -> DataFrame:
vec = spark.sql(f"""
SELECT embedding FROM ad_dataset.driving_scenes
WHERE path = '{anchor_path}'
""").collect()[0]["embedding"]
vec_literal = "array(" + ",".join(f"{v}f" for v in query_vec) + ")"
where_clause = " AND ".join(f"{col} = '{val}'" for col, val in filters.items())
return spark.sql(f"""
SELECT
id, path, weather, lighting, road_type,
objects, risks, scene_tag, sensor_type,
'{source_label}' AS source_query
FROM vector_search(
'ad_dataset.driving_scenes',
'embedding',
{vec_literal},
{top_k}
)
WHERE {where_clause}
""")
frames = [recall_scene(*scene) for scene in SCENES]
result = reduce(DataFrame.unionByName, frames)
spark.sql("""
CREATE TABLE IF NOT EXISTS ad_dataset.training_set_corner_cases (
id BIGINT,
path STRING,
weather STRING,
lighting STRING,
road_type STRING,
objects ARRAY<STRING>,
risks ARRAY<STRING>,
scene_tag STRING,
sensor_type STRING,
source_query STRING
) USING paimon
""")
result.writeTo("ad_dataset.training_set_corner_cases").append()
print(f"Total records written: {result.count()}")
Key value: one SQL workflow completes multiple scenario recalls and merges them, while the source_query field records the recall condition for each sample, making it easier to apply weighted sampling during training.
After retrieval, the training set distribution needs to be analyzed and duplicates removed — all of this can be done directly in Spark SQL:
-- Analyze the distribution of recalled samples by scenario
SELECT source_query, COUNT(*) AS sample_count
FROM ad_dataset.training_set_corner_cases
GROUP BY source_query
ORDER BY sample_count ASC;
-- Join with a dimension table to count coverage by city
SELECT
t.source_query,
r.city,
COUNT(*) AS sample_count
FROM ad_dataset.training_set_corner_cases t
JOIN dim_road_info r ON t.path = r.image_path
GROUP BY t.source_query, r.city
HAVING COUNT(*) > 5
ORDER BY t.source_query, sample_count DESC;

The core challenge in autonomous driving iteration is that long-tail scenarios are difficult to mine efficiently. Traditional solutions depend on manual annotation and frame-by-frame labeling, which is slow and costly.
Spark hybrid retrieval approach:
ai_embedding_multimodal to match similar driving scenarios semanticallyai_query to extract labels such as weather and road type, and filter by vehicle speed range, sensor type, and moreWhen robots face new tasks, they need to retrieve the most relevant operational strategies from their historical experience base.
Spark hybrid retrieval approach:
When users search for products by uploading images, both visual similarity and business rules must be considered.
Spark hybrid retrieval approach:
Once a piece of violating content is found, similar historical content must be located quickly.
Spark hybrid retrieval approach:
Doctors need to retrieve similar cases from historical imaging libraries while considering patient characteristics.
Spark hybrid retrieval approach:
Vector data and scalar data are stored in the same Paimon table. Spark performs hybrid retrieval directly in the lake without syncing to external systems. Data never leaves the lake, which avoids operational overhead and data consistency risks from synchronization pipelines, while also eliminating latency and bandwidth costs caused by cross-system data transfer.
vector_search returns a standard Spark DataFrame, which can be directly joined with other warehouse tables, used in window functions, aggregated, nested into subqueries, and more. In one SQL statement, hybrid retrieval and downstream analysis can be completed together — something standalone vector retrieval systems cannot provide.
Spark is naturally suited for large-scale offline batch processing, from embedding generation and similarity calculation to batch scenario deduplication, all in the data lake. No extra compute engine is required; one Spark job can cover the full pipeline of data ingestion, vector generation, index building, and batch retrieval.
ai_embedding_multimodal generates vectors, ai_query extracts scalar labels, and vector_search performs hybrid retrieval — all three functions run inside Spark SQL. From data ingestion to retrieval and analysis, users never leave the SQL environment, making it easy for data engineers to adopt.
Indexes are automatically built and updated by DLF and stored on OSS, while Spark compute resources scale elastically according to actual job usage. No compute cost is incurred when there are no jobs, and no fixed resources need to be reserved for index clusters. Data engineers only need to focus on SQL logic; index operations are fully transparent.
Alibaba Cloud EMR Serverless Spark’s hybrid scalar-vector retrieval capability brings three key benefits to the data lake:
vector_search + AI Function + standard WHERE clauses let data engineers work without learning a new interface.When the data lake gains "understanding," retrieval is no longer just exact matching — it becomes intelligent search that combines intent understanding with condition satisfaction.
Q1: How is the performance of EMR Serverless Spark hybrid retrieval? A: Thanks to the compute-storage-separated architecture of DLF Global Index, indexes are stored on OSS and loaded on demand during queries. For billion-row datasets, hybrid retrieval typically completes in seconds, and compared with full table scans, it delivers orders-of-magnitude performance gains as data volume grows.
Q2: What vector distance metrics are supported? A: Currently, mainstream metrics such as Cosine similarity and Euclidean distance are supported. You can specify the metric type in the lumina.index.metric-type table property.
Q3: Does index building affect data write performance? A: No. Index construction is triggered asynchronously by DLF in the background and is decoupled from Spark write jobs. After writes complete, DLF automatically schedules resources to build the index, transparently to users.
Want to see how EMR powers elastic, fully managed big data analytics with Spark, StarRocks, and lakehouse-native AI? 👉 Try EMR on Alibaba Cloud or talk to our solution architect to explore how you can build data lakes, real-time warehouses, and Data + AI workflows with seamless scalability.
More Resources:
E-MapReduce Serverless Spark Free Trial:1000 CU*H 3 months !
Stop Treating Your AI Like a Hard Drive: Why Your Team Needs a Persistent Context Layer in 2026
Alibaba Cloud EMR Serverless Spark AI Function Multimodal & Autonomous Driving Practice
22 posts | 0 followers
FollowAlibaba Cloud Big Data and AI - July 6, 2026
Alibaba Cloud Big Data and AI - April 13, 2026
Alibaba EMR - May 8, 2021
Alibaba EMR - May 11, 2021
Alibaba Cloud Big Data and AI - May 15, 2026
Alibaba EMR - November 22, 2024
22 posts | 0 followers
Follow
Big Data Consulting for Data Technology Solution
Alibaba Cloud provides big data consulting services to help enterprises leverage advanced data technology.
Learn More
Big Data Consulting Services for Retail Solution
Alibaba Cloud experts provide retailers with a lightweight and customized big data consulting service to help you assess your big data maturity and plan your big data journey.
Learn More
Realtime Compute for Apache Flink
Realtime Compute for Apache Flink offers a highly integrated platform for real-time data processing, which optimizes the computing of Apache Flink.
Learn More
Financial Services Solutions
Alibaba Cloud equips financial services providers with professional solutions with high scalability and high availability features.
Learn MoreMore Posts by Alibaba Cloud Big Data and AI