<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>Apache Doris Blog</title>
        <link>https://doris.apache.org/blog/</link>
        <description>Apache Doris Blog</description>
        <lastBuildDate>Tue, 24 Nov 2026 00:00:00 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <item>
            <title><![CDATA[How Apache Doris optimizes Apache Fluss reads: from JNI conversion to native Arrow batches]]></title>
            <link>https://doris.apache.org/blog/apache-doris-fluss-native-arrow-reader/</link>
            <guid>https://doris.apache.org/blog/apache-doris-fluss-native-arrow-reader/</guid>
            <pubDate>Tue, 24 Nov 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[Doris Summit 2026 profiling of Apache Fluss reads in Apache Doris, with prototype results for native Arrow batches, filter pushdown, and key lookups.]]></description>
            <content:encoded><![CDATA[<header><div class="text-center mb-4"><a class="cursor-pointer hover:no-underline" lang="en" href="https://doris.apache.org/blog/">Blog</a><span class="px-2 text-[#8592A6]">/</span><span><span class="s-tags" lang="en"><span class="s-tag">Tech Sharing</span></span></span></div><h1 lang="en" class="blog-post-title text-[2rem] leading-normal lg:!text-[2.5rem] text-center" itemprop="headline">How Apache Doris optimizes Apache Fluss reads: from JNI conversion to native Arrow batches</h1><div class="blog-info text-center flex justify-center text-sm text-black"><span class="authors"><span class="s-author text-black">Apache Fluss &#xB7; Anton Borisov</span></span><time datetime="2026-11-24T00:00:00.000Z" itemprop="datePublished" class="text-black ml-4">November 24, 2026</time></div></header><div id="__blog-post-container" class="markdown" itemprop="articleBody"><figure class="doris-youtube"><div class="doris-youtube__frame"><button type="button" class="doris-youtube__preview" aria-label="Play video: How Apache Doris optimizes Apache Fluss reads"><img class="doris-youtube__poster" src="https://doris.apache.org/images/blogs/apache-doris-fluss-native-arrow-reader/video-poster.jpg" alt width="1920" height="1080" loading="lazy" decoding="async"><span class="doris-youtube__play" aria-hidden="true"><svg width="28" height="28" viewBox="0 0 24 24" fill="currentColor"><path d="M8 5v14l11-7z"/></svg></span></button></div><figcaption class="doris-youtube__caption"><span>How Apache Doris optimizes Apache Fluss reads</span><a href="https://www.youtube.com/watch?v=f0iRSrWUo1k" target="_blank" rel="noopener noreferrer">Watch on YouTube<!-- --> <span aria-hidden="true">&#x2197;</span></a></figcaption></figure>
<blockquote>
<p>This article draws on <em>Building a Real-Time Streaming Lakehouse with Apache Fluss and Apache Doris</em>, presented by Apache Fluss PMC member Anton Borisov at Doris Summit 2026. <a href="https://fluss.apache.org/" target="_blank" rel="noopener noreferrer">Fluss</a> provides streaming storage for real-time analytics, and <a href="https://doris.apache.org/">Doris</a> runs SQL queries and analytics. The Fluss Catalog lets Doris read historical data in the lake together with the latest log records. Anton profiled CPU costs along this read path and described prototypes for native Arrow batch transfer and primary key lookup planning. All figures come from his presentation slides.</p>
</blockquote>
<p>Scanning 20 million Fluss log rows consumed about 15.5 CPU-seconds across the Doris backend. <strong>Java decoding and cell-by-cell copying accounted for about 12 CPU-seconds, or 78% of that work.</strong></p>
<p>Fluss already stores and serves logs in columnar <a href="https://arrow.apache.org/" target="_blank" rel="noopener noreferrer">Arrow</a> batches, and Doris uses columnar execution. Why did moving data between them require so much CPU time for conversion?</p>
<p><strong>The native reader and lookup planning discussed below are prototypes Anton presented in the talk. All performance figures come from tests of those prototypes.</strong></p>
<figure class="doris-youtube"><div class="doris-youtube__frame"><button type="button" class="doris-youtube__preview" aria-label="Play video: Building a Real-Time Streaming Lakehouse with Apache Fluss and Apache Doris"><img class="doris-youtube__poster" src="https://doris.apache.org/images/blogs/apache-doris-fluss-native-arrow-reader/talk-video-poster.jpg" alt width="1920" height="1080" loading="lazy" decoding="async"><span class="doris-youtube__play" aria-hidden="true"><svg width="28" height="28" viewBox="0 0 24 24" fill="currentColor"><path d="M8 5v14l11-7z"/></svg></span></button></div><figcaption class="doris-youtube__caption"><span>Building a Real-Time Streaming Lakehouse with Apache Fluss and Apache Doris</span><a href="https://www.youtube.com/watch?v=huTlmR7XXJk" target="_blank" rel="noopener noreferrer">Watch on YouTube<!-- --> <span aria-hidden="true">&#x2197;</span></a></figcaption></figure>
<p><a href="https://apache-doris-summit.org/watch/fluss-streaming-lakehouse" target="_blank" rel="noopener noreferrer">View this session on the Doris Summit 2026 website</a>.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="reading-the-stream-and-the-lake-as-one-table">Reading the stream and the lake as one table<a href="https://doris.apache.org/blog/apache-doris-fluss-native-arrow-reader/#reading-the-stream-and-the-lake-as-one-table" class="hash-link" aria-label="Direct link to Reading the stream and the lake as one table" title="Direct link to Reading the stream and the lake as one table">&#x200B;</a></h2>
<p>Real-time dashboards need to show what just happened and compare the latest changes with historical data. Fluss holds the latest events, while a tiering service continuously writes historical data to <a href="https://paimon.apache.org/" target="_blank" rel="noopener noreferrer">Paimon</a>. Tiering takes time, so the query engine needs to know which records it can read from the lake and which it must still read from the live log.</p>
<p>Fluss divides a table into buckets. Each bucket contains an ordered log, and an offset identifies a record&apos;s position within it. When the tiering service commits a Paimon lake snapshot, it also records the offset up to which each bucket&apos;s data has reached the lake.</p>
<p>Doris uses the lake snapshot and its associated offset boundaries together. It reads the history covered by the snapshot from Paimon and the records beyond each boundary from the Fluss log. This is <a href="https://doris.apache.org/docs/dev/lakehouse/catalogs/fluss-catalog/#tiered-lake-tables-and-union-read">Union Read</a>. The three buckets in Figure 1 have different tiering boundaries. Within each bucket, the two sources meet at that bucket&apos;s boundary: <strong>Doris avoids reading tiered records twice and includes records that have not yet reached the lake.</strong></p>
<p><img decoding="async" loading="lazy" alt="Union Read combines a Paimon lake snapshot with live Fluss logs at each bucket&amp;#39;s offset boundary." src="https://assets-cdn.selectdb.com/site/assets/shared/5a1947412280aec644b5870affa36ab1.png" width="2560" height="1440" class="img_ev3q"></p>
<p><em>Figure 1: The lake snapshot and live logs use the same offset boundaries. Original slide 7.</em></p>
<p>For an append-only Log Table, a query reads the log records in the relevant range. For a PrimaryKey Table, it must also apply changes to the base data to obtain the latest state for each primary key. If order 101 has status NEW in the lake snapshot and a later log record changes it to PAID, the result should retain PAID. If order 102 is deleted, it should no longer appear in the result.</p>
<p>The read path handles these details, so applications can query one logical table. In the talk, Anton used Wikipedia edit events to count edits by wiki over the past hour:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> wiki</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token function" style="color:hsl(221, 87%, 60%)">COUNT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token operator" style="color:hsl(221, 87%, 60%)">*</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> edits</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> fluss</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">wiki</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">edits</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">WHERE</span><span class="token plain"> ts </span><span class="token operator" style="color:hsl(221, 87%, 60%)">&gt;=</span><span class="token plain"> </span><span class="token function" style="color:hsl(221, 87%, 60%)">NOW</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">-</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INTERVAL</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">1</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">HOUR</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">GROUP</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> wiki</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ORDER</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> edits </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DESC</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">LIMIT</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">5</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>In this integration, Doris frontend nodes (FE) select the lake snapshot and read boundaries. Backend execution nodes (BE) read lake files and Fluss logs, then perform filtering, aggregation, and other computation. The cost examined here is the work of bringing those log records into the BE.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="where-the-jni-path-spends-cpu-time">Where the JNI path spends CPU time<a href="https://doris.apache.org/blog/apache-doris-fluss-native-arrow-reader/#where-the-jni-path-spends-cpu-time" class="hash-link" aria-label="Direct link to Where the JNI path spends CPU time" title="Direct link to Where the JNI path spends CPU time">&#x200B;</a></h2>
<p>Anton first profiled the baseline path, which calls the Fluss Java client through <a href="https://docs.oracle.com/en/java/javase/25/docs/specs/jni/intro.html" target="_blank" rel="noopener noreferrer">JNI</a>. The Fluss server returns compressed Arrow batches. The Java client decompresses them and converts the data into Java row objects. The JNI scanner then copies each value into Doris columns for filtering and aggregation in the BE.</p>
<p>Figure 2 shows this path and the backend CPU breakdown for a scan of 20 million log rows.</p>
<p><img decoding="async" loading="lazy" alt="The JNI path converts Arrow batches into Java row objects, then copies values into Doris columns. Decoding and copying account for about 78% of backend CPU work." src="https://assets-cdn.selectdb.com/site/assets/shared/60fc6d46e9ea81e1a556c83cff920c04.png" width="2560" height="1440" class="img_ev3q"></p>
<p><em>Figure 2: The JNI read path and backend CPU breakdown. Values are rounded. Original slide 10.</em></p>
<p>Of approximately 15.5 CPU-seconds, zstd decompression accounted for about 2.1, Java decoding and cell-by-cell copying for about 12.0, and Doris plus kernel work for about 1.3. CPU-seconds measure cumulative CPU time across execution threads. The query durations reported later measure elapsed time from start to finish. Parallel execution can make these measures differ substantially.</p>
<p><strong>Both ends use columnar data, yet the read path converts columns to rows and back to columns.</strong> For every batch, it constructs row objects, extracts fields, and writes values into destination columns. This intermediate work was the largest CPU cost in the measurement.</p>
<p>The optimization target was the object construction and per-value copying before data entered Doris. Decompression would still be necessary.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="passing-arrow-batches-directly-to-the-doris-be">Passing Arrow batches directly to the Doris BE<a href="https://doris.apache.org/blog/apache-doris-fluss-native-arrow-reader/#passing-arrow-batches-directly-to-the-doris-be" class="hash-link" aria-label="Direct link to Passing Arrow batches directly to the Doris BE" title="Direct link to Passing Arrow batches directly to the Doris BE">&#x200B;</a></h2>
<p>The prototype loads the <a href="https://clients.fluss.apache.org/" target="_blank" rel="noopener noreferrer">fluss-rust</a> client into the BE. After decompression, the client produces Arrow arrays and passes them to C++ through a small C ABI and the <a href="https://arrow.apache.org/docs/format/CDataInterface.html" target="_blank" rel="noopener noreferrer">Arrow C Data Interface</a>. Doris then imports the data by column.</p>
<p><strong>The new handoff passes whole arrays, bypassing Java row objects and the JNI scanner&apos;s cell-by-cell copying.</strong> The prototype still receives, decompresses, and processes data, but reduces the conversion work when columnar data crosses the language boundary.</p>
<p>Figure 3 shows the native reader&apos;s main path alongside the other optimizations.</p>
<p><img decoding="async" loading="lazy" alt="The native path uses fluss-rust to decompress data into Arrow arrays and passes them to the Doris BE through a C ABI and the Arrow C Data Interface. It also supports filter pushdown and primary key access." src="https://assets-cdn.selectdb.com/site/assets/shared/6ec3c46e3ead682c727994cd19fd66f1.png" width="2560" height="1440" class="img_ev3q"></p>
<p><em>Figure 3: Native reader batch transfer, filter pushdown, and primary key access paths. Original slide 11.</em></p>
<p>The prototype also adds range filter pushdown. Fluss can use column statistics to skip irrelevant batches. For a query over a time window, for example, it can skip any batch whose entire timestamp range falls outside that window.</p>
<p>These changes address different costs. <strong>Batch transfer reduces conversion overhead for each batch read. Pruning with column statistics reduces how many batches need to be read and processed.</strong> Narrow filters can therefore reduce the work further.</p>
<p>Primary key table reads must preserve their existing semantics. Whether the base data comes from a KV snapshot or a Paimon lake snapshot, the reader must merge subsequent changelog updates and deletes by primary key. The new handoff must return the same current state.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="scan-results-conversion-overhead-and-batch-pruning">Scan results: conversion overhead and batch pruning<a href="https://doris.apache.org/blog/apache-doris-fluss-native-arrow-reader/#scan-results-conversion-overhead-and-batch-pruning" class="hash-link" aria-label="Direct link to Scan results: conversion overhead and batch pruning" title="Direct link to Scan results: conversion overhead and batch pruning">&#x200B;</a></h2>
<p>Anton compared the paths on a 16-core machine shared by Doris and Fluss. The scan results report median elapsed time for a single query. He said all paths and runs returned the same results. Figure 4 shows scan times on the left and point-lookup throughput on the right.</p>
<p><img decoding="async" loading="lazy" alt="Scan time and point-lookup throughput for JNI and native readers. The slide notes that the tests used a shared 16-core machine and prototype implementations." src="https://assets-cdn.selectdb.com/site/assets/shared/250f680a53b0f5fe9a0c0be5a8c2ac7e.png" width="2560" height="1440" class="img_ev3q"></p>
<p><em>Figure 4: Prototype test results. The left chart reports seconds; the right chart reports point lookups per second with eight clients. Original slide 12.</em></p>
<p>The scan measurements were:</p>
<table><thead><tr><th>Test scenario</th><th style="text-align:right">JNI elapsed time</th><th style="text-align:right">Native reader elapsed time</th><th style="text-align:right">Speedup</th></tr></thead><tbody><tr><td>Scan of 20 million log rows</td><td style="text-align:right">2.59 s</td><td style="text-align:right">0.81 s</td><td style="text-align:right">3.2x</td></tr><tr><td>5% time window, native reader uses column statistics to skip batches</td><td style="text-align:right">1.57 s</td><td style="text-align:right">0.06 s</td><td style="text-align:right">26x</td></tr><tr><td>5% time window, without batch skipping based on column statistics</td><td style="text-align:right">1.48 s</td><td style="text-align:right">0.33 s</td><td style="text-align:right">4.5x</td></tr><tr><td>Primary key table, lake + log</td><td style="text-align:right">1.51 s</td><td style="text-align:right">0.88 s</td><td style="text-align:right">1.7x</td></tr><tr><td>Primary key table, KV snapshot</td><td style="text-align:right">0.42 s</td><td style="text-align:right">0.33 s</td><td style="text-align:right">1.3x</td></tr></tbody></table>
<p><strong>The full log scan fell from 2.59 seconds to 0.81 seconds</strong>, showing the overall effect of the new read path on this dataset. The time-window tests show the additional effect of batch skipping: the native reader took 0.33 seconds without column statistics and 0.06 seconds in the test that used them.</p>
<p><strong>The 26x speedup includes both native reading and pruning with column statistics.</strong> Skipping unnecessary data at the source reduced the work further than the conversion changes alone. Each result needs to be read alongside the mechanism that produced it to understand the contribution of each change.</p>
<p>The two primary key table scans improved by approximately 1.7x and 1.3x. Their smaller gains reflect different costs along those read paths. All these figures describe the prototype on the specified machine, queries, and data. Other workloads need measurements of their own read paths.</p>
<p>Primary key queries also exposed a separate problem. The underlying store supported access by key, but the query plan did not necessarily use it.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="using-key-lookups-for-primary-key-queries">Using key lookups for primary key queries<a href="https://doris.apache.org/blog/apache-doris-fluss-native-arrow-reader/#using-key-lookups-for-primary-key-queries" class="hash-link" aria-label="Direct link to Using key lookups for primary key queries" title="Direct link to Using key lookups for primary key queries">&#x200B;</a></h2>
<p>Anton demonstrated the problem with a query against a primary key table. <strong>The SQL supplied a complete key predicate, yet the execution plan read the entire table before filtering for the target record.</strong> Faster reads still left a large amount of avoidable work.</p>
<p>The prototype adds lookup planning: it recognizes predicates that identify a primary key and lets the reader access the Fluss key store directly. The eight-client test in Figure 4 compares three paths:</p>
<table><thead><tr><th>Point-lookup path</th><th style="text-align:right">Throughput</th></tr></thead><tbody><tr><td>Original Doris 5.0 JNI path, full table scan for each lookup</td><td style="text-align:right">About 4 lookups/s</td></tr><tr><td>JNI path with lookup planning</td><td style="text-align:right">About 1,836 lookups/s</td></tr><tr><td>Native reader with direct key store access</td><td style="text-align:right">About 1,943 lookups/s</td></tr></tbody></table>
<p>The JNI path also improved substantially once it used lookup planning. <strong>Switching from a full table scan to a key lookup accounted for much of the gain in this test.</strong> The increase from 4 to 1,943 lookups per second reflects both the planning changes and the reader changes.</p>
<p>For a separate sample table containing lake data, Figure 4 reports about 74 lookups per second for JNI and about 1,845 for the native reader. Lookup costs depend on where the data resides and how the reader accesses it. These samples need to be compared within their own read paths.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="looking-up-records-in-historical-partitions">Looking up records in historical partitions<a href="https://doris.apache.org/blog/apache-doris-fluss-native-arrow-reader/#looking-up-records-in-historical-partitions" class="hash-link" aria-label="Direct link to Looking up records in historical partitions" title="Direct link to Looking up records in historical partitions">&#x200B;</a></h3>
<p>A primary key table&apos;s retention policy can expire older partitions from live storage while keeping their data in the lake. Applications may still query those records by primary key, so the reader needs an access path that works after the live partition expires.</p>
<p>Anton also described prototype support for historical partition lookups, which brings Fluss 1.0&apos;s <a href="https://fluss.apache.org/docs/table-design/data-distribution/partitioning/#historical-partition-access" target="_blank" rel="noopener noreferrer">historical partition lookup</a> into fluss-rust. For active partitions, the reader accesses the Fluss key store. For expired partitions, it sends the key to the table&apos;s <code>__historical__</code> partition, where the Fluss service queries Paimon&apos;s local lookup files. Figure 5 shows the two paths.</p>
<p><img decoding="async" loading="lazy" alt="Active partitions use the Fluss key store. Expired partitions use the __historical__ partition and Paimon&amp;#39;s local lookup files." src="https://assets-cdn.selectdb.com/site/assets/shared/ebfab48a32e9828305310fbf844ddf55.png" width="2560" height="1440" class="img_ev3q"></p>
<p><em>Figure 5: Primary key access after partition expiration, with the corresponding test results. Original slide 13.</em></p>
<p>In this separate eight-client test, the original path planned a Union Read and scanned lake data, reaching about 56 lookups per second. The prototype reached about 1,934 lookups per second for active partitions and about 1,957 for expired partitions. The results show room to improve historical primary key lookups: <strong>a dedicated lookup path can still access records after their partitions leave live storage.</strong></p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="planning-and-scheduling-become-the-next-bottleneck">Planning and scheduling become the next bottleneck<a href="https://doris.apache.org/blog/apache-doris-fluss-native-arrow-reader/#planning-and-scheduling-become-the-next-bottleneck" class="hash-link" aria-label="Direct link to Planning and scheduling become the next bottleneck" title="Direct link to Planning and scheduling become the next bottleneck">&#x200B;</a></h2>
<p>As the cost of finding a record fell, Doris&apos;s query preparation accounted for more of the remaining work. Anton profiled the native reader in the eight-client point-lookup test. Each lookup consumed about 5.2 ms of cumulative CPU time, distributed as shown in Figure 6.</p>
<p><img decoding="async" loading="lazy" alt="Each point lookup consumes about 5.2 ms of cumulative CPU time, mostly in Doris FE parsing, planning, and scheduling, and BE execution preparation." src="https://assets-cdn.selectdb.com/site/assets/shared/587d54640ebc3875f46f41320361c652.png" width="2560" height="1440" class="img_ev3q"></p>
<p><em>Figure 6: Cumulative CPU cost per point lookup. The values represent CPU time. Original slide 14.</em></p>
<p>FE parsing, planning, and scheduling accounted for about 3.07 ms. BE fragment setup and execution accounted for about 1.88 ms. By comparison, the Fluss server used about 0.10 ms and the client about 0.15 ms. The 5.2 ms is cumulative CPU cost across these components; measuring end-to-end response latency requires separate timing.</p>
<p><strong>Fetching one row still incurs general query planning and execution setup.</strong> Anton proposed a shorter execution path for Fluss point lookups to reduce this overhead for requests already identified as key lookups. Caching partition lists and avoiding repeated metadata access could also lower the fixed cost of each query.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="further-work-on-the-fluss-read-path">Further work on the Fluss read path<a href="https://doris.apache.org/blog/apache-doris-fluss-native-arrow-reader/#further-work-on-the-fluss-read-path" class="hash-link" aria-label="Direct link to Further work on the Fluss read path" title="Direct link to Further work on the Fluss read path">&#x200B;</a></h2>
<p>The Fluss and Doris integration lets applications query live logs and lake history through one SQL interface. Improving its performance means examining the work at each step: <strong>preserving columnar batches reduces format conversion, source statistics help skip irrelevant data, and lookup planning routes primary key queries to key-based access.</strong> Each round of changes needs fresh measurements to find the largest remaining cost.</p>
<p>The Apache Doris community has already merged some of the prototype optimizations. The Fluss Catalog will be officially released in Apache Doris 5.0. Once the Fluss Native Reader is ready, the community will follow up promptly with further integration and performance work. Thanks to Anton for his profiling, prototype implementation, and work across the two communities to improve this read path.</p>
<p>The prototype code is available on the <a href="https://github.com/fresh-borzoni/doris/commits/fluss-native-reader/" target="_blank" rel="noopener noreferrer">fluss-native-reader branch in fresh-borzoni/doris</a>, including changes for the Fluss Rust reader, Arrow column imports, and metadata caching. To try it, check out the branch in a test environment and run your own log scans, time-window filters, and primary key point lookups. Share the test conditions, query profiles, and any issues with the Doris and Fluss communities to help improve the reader.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="related-links">Related links<a href="https://doris.apache.org/blog/apache-doris-fluss-native-arrow-reader/#related-links" class="hash-link" aria-label="Direct link to Related links" title="Direct link to Related links">&#x200B;</a></h2>
<ul>
<li><a href="https://fluss.apache.org/blog/apache-doris-fluss-stream-lake-analytics/" target="_blank" rel="noopener noreferrer">Fluss blog: Apache Doris x Fluss: Unified Queries Across Stream and Lake</a></li>
<li><a href="https://doris.apache.org/docs/dev/lakehouse/catalogs/fluss-catalog/">Apache Doris Fluss Catalog documentation</a></li>
<li><a href="https://doris.apache.org/slack/">Join the Apache Doris Slack community</a></li>
</ul></div>]]></content:encoded>
            <category>Tech Sharing</category>
        </item>
        <item>
            <title><![CDATA[One Engine for Search and Analytical Queries: How HubSpot Runs Apache Doris Across 33 Clusters]]></title>
            <link>https://doris.apache.org/blog/hubspot-apache-doris-search-analytics/</link>
            <guid>https://doris.apache.org/blog/hubspot-apache-doris-search-analytics/</guid>
            <pubDate>Fri, 20 Nov 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[How HubSpot uses Apache Doris for CRM object analytics across 33 clusters, with typed VARIANT columns, inverted indexes, controlled query fan-out, cell-based deployment, and prioritized ingestion.]]></description>
            <content:encoded><![CDATA[<header><div class="text-center mb-4"><a class="cursor-pointer hover:no-underline" lang="en" href="https://doris.apache.org/blog/">Blog</a><span class="px-2 text-[#8592A6]">/</span><span><span class="s-tags" lang="en"><span class="s-tag">Best Practice</span></span></span></div><h1 lang="en" class="blog-post-title text-[2rem] leading-normal lg:!text-[2.5rem] text-center" itemprop="headline">One Engine for Search and Analytical Queries: How HubSpot Runs Apache Doris Across 33 Clusters</h1><div class="blog-info text-center flex justify-center text-sm text-black"><span class="authors"><span class="s-author text-black">HubSpot &#xB7; Alvaro Tuso</span></span><time datetime="2026-11-20T00:00:00.000Z" itemprop="datePublished" class="text-black ml-4">November 20, 2026</time></div></header><div id="__blog-post-container" class="markdown" itemprop="articleBody"><figure class="doris-youtube"><div class="doris-youtube__frame"><button type="button" class="doris-youtube__preview" aria-label="Play video: How HubSpot Runs Apache Doris Across 33 Clusters"><img class="doris-youtube__poster" src="https://doris.apache.org/images/blogs/hubspot-apache-doris-search-analytics/video-poster.jpg" alt width="1920" height="1080" loading="lazy" decoding="async"><span class="doris-youtube__play" aria-hidden="true"><svg width="28" height="28" viewBox="0 0 24 24" fill="currentColor"><path d="M8 5v14l11-7z"/></svg></span></button></div><figcaption class="doris-youtube__caption"><span>How HubSpot Runs Apache Doris Across 33 Clusters</span><a href="https://www.youtube.com/watch?v=aP76bXhZ32Q" target="_blank" rel="noopener noreferrer">Watch on YouTube<!-- --> <span aria-hidden="true">&#x2197;</span></a></figcaption></figure>
<p><em>Queries on HubSpot&apos;s CRM data have to filter on any property and match text like a search engine, then join across many-to-many associations and aggregate like an analytical database. HubSpot needed one engine for both search and analytical queries, and chose Apache Doris, a real-time analytical and search database. Analytical queries on CRM objects now run on 33 Doris clusters worldwide, and P50 backend latency has dropped from about 1.8 seconds to about 500 milliseconds.</em></p>
<div class="theme-admonition theme-admonition-tip admonition_Gfwi alert alert--success"><div class="admonitionHeading_f1Ed">tip</div><div class="admonitionContent_UjKb"><p>This article is based on Evolving Semi-Structured Search &amp; Analytical Queries at HubSpot, an Apache Doris Summit 2026 talk by HubSpot Staff Software Engineer Alvaro Tuso. A big thank-you to Alvaro for generously sharing his experience and insights with the Apache Doris community! The full recording is available on demand.</p></div></div>
<p>Imagine a HubSpot user who wants to know which industries employ the contacts whose text property contains the word &quot;acme&quot;, how many of those contacts each industry has, and what one of their numeric properties adds up to. The question needs both search and analytics: it matches text on contacts, joins them to companies through an association table, and then groups and aggregates by industry. Writing it in SQL is straightforward. The hard part is the data itself. Customers define most of these properties themselves, so every customer&apos;s properties are different, some customers have thousands of properties on a single object type, and the data changes constantly.</p>
<p>HubSpot moved this workload to Apache Doris. <strong>After analytical queries on CRM objects switched to Doris, P50 backend latency dropped from about 1.8 seconds to about 500 milliseconds, and the end-to-end time users experience fell from about 2 seconds to about 1 second.</strong> These queries now run on 33 Doris clusters worldwide. Search, built on the same data model, is under way.</p>
<p>This article covers what makes HubSpot&apos;s data hard, why HubSpot chose Doris, the designs it built on top of Doris, and how it scaled from one cluster to a global deployment. It closes with the next steps for search and events.</p>
<figure class="doris-youtube"><div class="doris-youtube__frame"><button type="button" class="doris-youtube__preview" aria-label="Play video: Evolving Semi-Structured Search &amp; Analytical Queries at HubSpot"><img class="doris-youtube__poster" src="https://doris.apache.org/images/blogs/hubspot-apache-doris-search-analytics/talk-video-poster.jpg" alt width="1920" height="1080" loading="lazy" decoding="async"><span class="doris-youtube__play" aria-hidden="true"><svg width="28" height="28" viewBox="0 0 24 24" fill="currentColor"><path d="M8 5v14l11-7z"/></svg></span></button></div><figcaption class="doris-youtube__caption"><span>Evolving Semi-Structured Search &amp; Analytical Queries at HubSpot</span><a href="https://www.youtube.com/watch?v=knADAP8z_Wc" target="_blank" rel="noopener noreferrer">Watch on YouTube<!-- --> <span aria-hidden="true">&#x2197;</span></a></figcaption></figure>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="the-problem-every-customer-has-its-own-schema">The Problem: Every Customer Has Its Own Schema<a href="https://doris.apache.org/blog/hubspot-apache-doris-search-analytics/#the-problem-every-customer-has-its-own-schema" class="hash-link" aria-label="Direct link to The Problem: Every Customer Has Its Own Schema" title="Direct link to The Problem: Every Customer Has Its Own Schema">&#x200B;</a></h2>
<p>HubSpot&apos;s CRM can be viewed as a schema that each tenant defines for itself (Figure 1). Internally, HubSpot calls a tenant a portal. Objects are the main entities. An object type works like a table, such as contacts, companies, or deals, and customers can create their own object types. Properties work like columns: each has a type, and customers can define their own. Associations are many-to-many relationship tables between objects. They link a contact to the company where the contact works, for example, and customers use them to model the relationships in their business. A list is a set of objects that match certain conditions. Events are the largest dataset, orders of magnitude larger than objects. An event is also a set of custom properties, carries a timestamp, and can be associated with an object. The queries in this article mainly serve HubSpot&apos;s Smart CRM and Data Hub.</p>
<p><img decoding="async" loading="lazy" alt="HubSpot&amp;#39;s CRM data model: one portal, which is one customer with its own schema, holds object-type tables such as Contacts, Companies, and a custom object, whose columns are properties. Lines marked M link rows across tables, a List tags a subset of contacts, and a dense stream of time-stamped events runs along the bottom." src="https://assets-cdn.selectdb.com/site/assets/shared/05195082244c474cf7d62a2328855778.jpg" width="1600" height="900" class="img_ev3q"></p>
<p><em>Figure 1: How HubSpot&apos;s CRM data is organized.</em></p>
<p>The scale is substantial. Object data is less than 1 PB, and event data is larger still. Ingestion runs at about 120,000 requests per second, and about 90% of those requests update existing records. Search runs at about 20,000 QPS. The traffic comes from users querying in the product UI, agents calling the API, HubSpot&apos;s AI assistant Breeze, and other HubSpot systems that need to look up objects.</p>
<p>Two kinds of queries run on this data. Search filters on arbitrary properties and adds text matching, sorting, and limits. Each search query is simple, but QPS is high and latency targets are strict. Analytical queries run at much lower QPS and filter in a similar way, but they also join up to five object types and then aggregate. Every additional object type adds another hop through a many-to-many relationship table, so real queries often contain around 10 joins and are expensive in both compute and I/O.</p>
<p><img decoding="async" loading="lazy" alt="Four icons labeled Schema (arbitrary and different for each tenant), Joins (up to 5 hops through a relationship table), Ingestion (massive update volume), and Search (text search, with scoring and semantic search later)." src="https://assets-cdn.selectdb.com/site/assets/shared/73cd7ccfd6968a57d787324ae01a2625.jpg" width="1600" height="476" class="img_ev3q"></p>
<p><em>Figure 2: The four challenges HubSpot faced.</em></p>
<p>The challenges come down to four (Figure 2):</p>
<ol>
<li>The schema differs by tenant. Some customers have thousands of properties on a single object type. A system with a fixed schema can materialize only some of them and has to put the rest into a JSON map.</li>
<li>Joins. Analytical databases handle joins well, and search engines usually do not. Few systems do both.</li>
<li>Ingestion is dominated by updates. The faster data is written, the more files a query has to read and the harder it becomes to keep query latency low, so data freshness and query latency pull against each other.</li>
<li>Search. HubSpot needs text search today, and scoring and semantic search later.</li>
</ol>
<p><strong>HubSpot was looking for a database that could put search and analytical queries in the same engine.</strong></p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="why-apache-doris">Why Apache Doris<a href="https://doris.apache.org/blog/hubspot-apache-doris-search-analytics/#why-apache-doris" class="hash-link" aria-label="Direct link to Why Apache Doris" title="Direct link to Why Apache Doris">&#x200B;</a></h2>
<p>That is exactly how Apache Doris is positioned: as a real-time analytical and search database. Alongside the joins and aggregations of an analytical database, Doris has built-in <a href="https://doris.apache.org/docs/dev/table-design/index/inverted-index/overview/">inverted indexes and full-text search</a>. During its evaluation, HubSpot contacted VeloDB and ran a set of analytical and search queries on a small sample of its data in VeloDB Cloud, VeloDB&apos;s managed service. The results were strong. The two companies then formed a formal partnership and have worked closely together ever since, doing joint R&amp;D to bring the project into production.</p>
<p><img decoding="async" loading="lazy" alt="A honeycomb of four Doris capabilities: Variant (typed, materialized sub-paths with inverted indexes), Merge-on-Write (a massive update cadence with lower query-time overhead), decoupled mode (compute-storage separation), and Fast (strong ingestion and query performance)." src="https://assets-cdn.selectdb.com/site/assets/shared/5c758f8a5f4d273eb2cdc807bb4ae268.jpg" width="1600" height="643" class="img_ev3q"></p>
<p><em>Figure 3: The four Doris capabilities behind the choice.</em></p>
<p>Four Doris capabilities drove the decision (Figure 3):</p>
<ul>
<li><a href="https://doris.apache.org/docs/dev/sql-manual/basic-element/sql-data-types/semi-structured/VARIANT/">VARIANT</a>: This was the most important capability. VARIANT can match column names by pattern, assign types to the matched sub-paths, and materialize those sub-paths in the backend as regular columns, which can also carry inverted indexes. <strong>As a result, HubSpot can model every customer-defined object type and property as a real column, without having to choose between materializing only some properties and pushing the rest into JSON.</strong></li>
<li><a href="https://doris.apache.org/docs/dev/table-design/data-model/unique/">Unique Key model</a>: HubSpot&apos;s objects, associations, and events all have idempotent IDs, which map naturally onto the Unique Key model. When a write commits, Doris marks the old row as deleted and skips it at query time, which removes most of the merge work at read time.</li>
<li><a href="https://doris.apache.org/docs/dev/features-architecture/system-architecture/">Compute-storage decoupling</a>: HubSpot&apos;s customers vary widely in size. Decoupling compute from storage makes it easier to isolate customers from one another and to limit the impact of any failure.</li>
<li>Performance: Ingestion and query latency both stay low, even while data is written continuously.</li>
</ul>
<p>These capabilities made the approach possible. The final results depended on the designs HubSpot built on top of Doris.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="a-deep-dive-into-doris-at-hubspot">A Deep Dive into Doris at HubSpot<a href="https://doris.apache.org/blog/hubspot-apache-doris-search-analytics/#a-deep-dive-into-doris-at-hubspot" class="hash-link" aria-label="Direct link to A Deep Dive into Doris at HubSpot" title="Direct link to A Deep Dive into Doris at HubSpot">&#x200B;</a></h2>
<p>Each of the four designs below builds on a Doris capability and adds a layer of HubSpot&apos;s own engineering.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="turning-arbitrary-properties-into-typed-columns">Turning Arbitrary Properties into Typed Columns<a href="https://doris.apache.org/blog/hubspot-apache-doris-search-analytics/#turning-arbitrary-properties-into-typed-columns" class="hash-link" aria-label="Direct link to Turning Arbitrary Properties into Typed Columns" title="Direct link to Turning Arbitrary Properties into Typed Columns">&#x200B;</a></h3>
<p>Customers&apos; raw property names cannot serve directly as column names. Contacts have a first name, companies may only have a name, and every custom object names things its own way. Across all customers, there are millions of distinct property names or more, and no database can materialize all of them.</p>
<p>HubSpot reused an approach it originally designed for Elasticsearch: it groups properties by type and numbers them within each object type. A contact&apos;s first name might map to <code>string_1</code>, and a company&apos;s name can also be <code>string_1</code>. This sharply reduces the number of distinct sub-path names in the VARIANT column, to a few hundred in one table and a few thousand in the other. HubSpot also split the object table in two by column count, one table with few columns and one with many, so that the two do not interfere with each other.</p>
<p>On top of these slots, HubSpot uses VARIANT type patterns (<code>MATCH_NAME_GLOB</code>) to assign a type by prefix. The patterns cover Booleans, datetimes, enums, numbers, number arrays, text, and phone numbers. Phone numbers get their own prefix because they are searched differently from regular text. HubSpot sets <code>variant_max_subcolumns_count</code> to 50,000. This deliberately high limit is never reached in practice; its purpose is to ensure that every sub-path is materialized as a column (Figure 4).</p>
<p><img decoding="async" loading="lazy" alt="Customer property names such as Contact &#xB7; First name and Company &#xB7; Name map to typed slots such as string_1, number_12, and phone_1. MATCH_NAME_GLOB turns each slot into a typed sub-column of the VARIANT column named properties, and some sub-columns carry inverted indexes." src="https://assets-cdn.selectdb.com/site/assets/shared/04c5908dd6ce1000cf2bb92e9898c7ed.jpg" width="1600" height="800" class="img_ev3q"></p>
<p><em>Figure 4: From customer property names to typed sub-columns in VARIANT.</em></p>
<p>HubSpot also defines inverted indexes by field pattern (<code>field_pattern</code>). Normalized strings, phone numbers, and number arrays each get their own kind of index, paired with HubSpot&apos;s custom analyzers, such as <code>standard_normalized</code> and <code>normalized_edge_ngram_phone_number</code> below. The approach resembles dynamic templates in Elasticsearch. Some HubSpot products use Elasticsearch, so HubSpot worked with VeloDB to make text matching in Doris behave the same way as in those products.</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token comment" style="color:hsl(230, 4%, 64%)">-- VARIANT column in the object table</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token identifier punctuation" style="color:hsl(119, 34%, 47%)">`</span><span class="token identifier">properties</span><span class="token identifier punctuation" style="color:hsl(119, 34%, 47%)">`</span><span class="token plain"> variant</span><span class="token operator" style="color:hsl(221, 87%, 60%)">&lt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  MATCH_NAME_GLOB </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;boolean_*&apos;</span><span class="token plain">:</span><span class="token keyword" style="color:hsl(301, 63%, 40%)">boolean</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  MATCH_NAME_GLOB </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;datetime_*&apos;</span><span class="token plain">:</span><span class="token keyword" style="color:hsl(301, 63%, 40%)">bigint</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  MATCH_NAME_GLOB </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;enum_*_raw&apos;</span><span class="token plain">:array</span><span class="token operator" style="color:hsl(221, 87%, 60%)">&lt;</span><span class="token keyword" style="color:hsl(301, 63%, 40%)">text</span><span class="token operator" style="color:hsl(221, 87%, 60%)">&gt;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  MATCH_NAME_GLOB </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;number_*&apos;</span><span class="token plain">:</span><span class="token keyword" style="color:hsl(301, 63%, 40%)">decimal</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">38</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token number" style="color:hsl(35, 99%, 36%)">10</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  MATCH_NAME_GLOB </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;numberArray_*&apos;</span><span class="token plain">:array</span><span class="token operator" style="color:hsl(221, 87%, 60%)">&lt;</span><span class="token keyword" style="color:hsl(301, 63%, 40%)">decimal</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">38</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token number" style="color:hsl(35, 99%, 36%)">10</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token operator" style="color:hsl(221, 87%, 60%)">&gt;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  MATCH_NAME_GLOB </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;string_*_raw&apos;</span><span class="token plain">:</span><span class="token keyword" style="color:hsl(301, 63%, 40%)">text</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  MATCH_NAME_GLOB </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;phone_*&apos;</span><span class="token plain">:</span><span class="token keyword" style="color:hsl(301, 63%, 40%)">text</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  PROPERTIES</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;variant_max_subcolumns_count&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;50000&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;variant_enable_typed_paths_to_sparse&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;false&apos;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token operator" style="color:hsl(221, 87%, 60%)">&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- Inverted indexes defined by field pattern</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INDEX</span><span class="token plain"> idx_string_norm_standard </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token identifier punctuation" style="color:hsl(119, 34%, 47%)">`</span><span class="token identifier">properties</span><span class="token identifier punctuation" style="color:hsl(119, 34%, 47%)">`</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">USING</span><span class="token plain"> INVERTED PROPERTIES</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;support_phrase&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;field_pattern&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;string_*_norm&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;analyzer&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;standard_normalized&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INDEX</span><span class="token plain"> idx_phone_ngram </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token identifier punctuation" style="color:hsl(119, 34%, 47%)">`</span><span class="token identifier">properties</span><span class="token identifier punctuation" style="color:hsl(119, 34%, 47%)">`</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">USING</span><span class="token plain"> INVERTED PROPERTIES</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;support_phrase&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;field_pattern&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;phone_*&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;analyzer&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;normalized_edge_ngram_phone_number&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INDEX</span><span class="token plain"> idx_numberArray </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token identifier punctuation" style="color:hsl(119, 34%, 47%)">`</span><span class="token identifier">properties</span><span class="token identifier punctuation" style="color:hsl(119, 34%, 47%)">`</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">USING</span><span class="token plain"> INVERTED PROPERTIES</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;field_pattern&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;numberArray_*&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>To learn how VARIANT works internally, see the <a href="https://doris.apache.org/blog/variant-tech-deepdive-202601/">VARIANT deep dive</a> on the Apache Doris website.</p>
<p><strong>Lesson: normalize property names into a bounded set of typed slots in the application layer, then let VARIANT materialize them.</strong></p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="controlling-query-fan-out">Controlling Query Fan-Out<a href="https://doris.apache.org/blog/hubspot-apache-doris-search-analytics/#controlling-query-fan-out" class="hash-link" aria-label="Direct link to Controlling Query Fan-Out" title="Direct link to Controlling Query Fan-Out">&#x200B;</a></h3>
<p>The object table defines its key and data distribution as follows. <code>portalId</code> is the tenant ID, <code>objectTypeId</code> identifies the object type (that is, a table in the CRM), and <code>objectId</code> is the ID of the object itself.</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">UNIQUE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">KEY</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token identifier punctuation" style="color:hsl(119, 34%, 47%)">`</span><span class="token identifier">portalId</span><span class="token identifier punctuation" style="color:hsl(119, 34%, 47%)">`</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token identifier punctuation" style="color:hsl(119, 34%, 47%)">`</span><span class="token identifier">objectTypeId</span><span class="token identifier punctuation" style="color:hsl(119, 34%, 47%)">`</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token identifier punctuation" style="color:hsl(119, 34%, 47%)">`</span><span class="token identifier">objectIdHash</span><span class="token identifier punctuation" style="color:hsl(119, 34%, 47%)">`</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token identifier punctuation" style="color:hsl(119, 34%, 47%)">`</span><span class="token identifier">objectId</span><span class="token identifier punctuation" style="color:hsl(119, 34%, 47%)">`</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DISTRIBUTED</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">HASH</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token identifier punctuation" style="color:hsl(119, 34%, 47%)">`</span><span class="token identifier">portalId</span><span class="token identifier punctuation" style="color:hsl(119, 34%, 47%)">`</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token identifier punctuation" style="color:hsl(119, 34%, 47%)">`</span><span class="token identifier">objectTypeId</span><span class="token identifier punctuation" style="color:hsl(119, 34%, 47%)">`</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token identifier punctuation" style="color:hsl(119, 34%, 47%)">`</span><span class="token identifier">objectIdHash</span><span class="token identifier punctuation" style="color:hsl(119, 34%, 47%)">`</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> BUCKETS </span><span class="token number" style="color:hsl(35, 99%, 36%)">256</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>The important part is the extra <code>objectIdHash</code> column. Within a single customer, object types can differ enormously in size: a customer might have a million contacts but only ten companies. If Doris distributed data only by tenant and object type, all one million contacts would land in a single tablet (a Doris data shard) on a single BE (backend node). If Doris spread the data across every BE instead, even a query for ten rows would have to touch every BE.</p>
<p><code>objectIdHash</code> is a hash computed from the object ID. Because it appears in both the key and the distribution key, HubSpot can control from the application side how many tablets each object type is split into. HubSpot knows each customer&apos;s write rate and the data volume of each object type, and decides the split accordingly: a single tablet for a small object type, for example, and ten for a medium one. This takes a fair amount of application-side work. At query time, the application passes the assigned hash values as a filter, and Doris sends execution fragments only to the BEs that hold the relevant tablets. The other BEs do not participate (Figure 5). This matters most for search: <strong>search runs at about 20,000 QPS, so the CPU, RPC, and memory saved on each query add up to a substantial amount.</strong></p>
<p><img decoding="async" loading="lazy" alt="Three panels, each with six BEs. Hashing by portal and object type puts one million contacts on one BE. Spreading data across all BEs makes a 10-row query touch every BE. Adding objectIdHash lets the query reach only the BE that holds the rows." src="https://assets-cdn.selectdb.com/site/assets/shared/a3be6ebfe157ba08944419fa4d339b50.jpg" width="1600" height="790" class="img_ev3q"></p>
<p><em>Figure 5: Tablet placement and query fan-out under three distribution schemes.</em></p>
<p>Putting these designs together gives the example analytical query below, which answers the question at the beginning of this article. It filters contacts on a text property, joins them to companies through the association table, groups by company industry, and then counts contacts and sums a numeric property. The query first casts VARIANT sub-paths to concrete types, because the FE (frontend node) does not know the type of a sub-path; once the type is declared, the query can use the indexes and the matching functions. <code>objectidhash IN (0)</code> limits the contacts to a single tablet, and <code>MATCH_PHRASE</code> uses the inverted index for phrase matching. This version is heavily simplified; real queries usually contain around 10 joins.</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  CAST</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">co</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">properties</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">[</span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;string_4_raw&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">]</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">TEXT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> industry</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  </span><span class="token function" style="color:hsl(221, 87%, 60%)">COUNT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DISTINCT</span><span class="token plain"> c</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">objectid</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> contacts</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  </span><span class="token function" style="color:hsl(221, 87%, 60%)">SUM</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">CAST</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">c</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">properties</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">[</span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;number_12&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">]</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DECIMAL</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">38</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">10</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> total_value</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> objects c</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">JOIN</span><span class="token plain"> associations a</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ON</span><span class="token plain"> a</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">portalid </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> c</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">portalid</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  </span><span class="token operator" style="color:hsl(221, 87%, 60%)">AND</span><span class="token plain"> a</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">fromobjectid </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> c</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">objectid</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">JOIN</span><span class="token plain"> objects co</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ON</span><span class="token plain"> co</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">portalid </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> a</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">portalid</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  </span><span class="token operator" style="color:hsl(221, 87%, 60%)">AND</span><span class="token plain"> co</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">objectid </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> a</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">toobjectid</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">WHERE</span><span class="token plain"> c</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">portalid </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">1</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  </span><span class="token operator" style="color:hsl(221, 87%, 60%)">AND</span><span class="token plain"> c</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">objecttypeid </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;0-1&apos;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  </span><span class="token operator" style="color:hsl(221, 87%, 60%)">AND</span><span class="token plain"> c</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">objectidhash </span><span class="token operator" style="color:hsl(221, 87%, 60%)">IN</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">0</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  </span><span class="token operator" style="color:hsl(221, 87%, 60%)">AND</span><span class="token plain"> CAST</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">c</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">properties</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">[</span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;string_8_norm&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">]</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">TEXT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> MATCH_PHRASE </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;acme&apos;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">GROUP</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> industry</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ORDER</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> contacts </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DESC</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">LIMIT</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">100</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p><strong>Lesson: use a power of two for the bucket count.</strong> HubSpot studied and tested the hash function that Doris uses and found that powers of two produce fewer collisions and spread data more evenly across buckets.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="many-small-clusters-instead-of-one-big-one">Many Small Clusters Instead of One Big One<a href="https://doris.apache.org/blog/hubspot-apache-doris-search-analytics/#many-small-clusters-instead-of-one-big-one" class="hash-link" aria-label="Direct link to Many Small Clusters Instead of One Big One" title="Direct link to Many Small Clusters Instead of One Big One">&#x200B;</a></h3>
<p>HubSpot runs as many services as possible on Kubernetes, with a single Kubernetes cluster per data center, and Doris is no exception. Doris runs in Kubernetes on AWS EC2, in compute-storage decoupled mode with FoundationDB, entirely on ARM64 Graviton instances. HubSpot also tried mixing in AMD instances and found that Doris performs much better on ARM64.</p>
<p>The pods use the Kubernetes Burstable QoS class. CPU requests match the steady load of ingestion and queries, while CPU limits leave generous headroom. As a result, pods from several Doris clusters can share a node, and a query can briefly use extra CPU when it needs to. These bursts are infrequent and barely visible in node metrics, yet they noticeably cut tail latency, which helps analytical queries in particular. To make this work, HubSpot tuned Doris and proposed a change to how cgroup memory is accounted.</p>
<p>The bigger question was how to divide the clusters. From the start, HubSpot did not aim for one giant cluster per data center that held every customer&apos;s data. Growing a small experiment straight to that scale would have wasted significant resources and caused repeated rework. The cell-based architecture that HubSpot is adopting also calls for small clusters with a small blast radius.</p>
<p><img decoding="async" loading="lazy" alt="Customers of different sizes are scored by load, split into groups of about 5%, and routed by the application to identical small clusters, with HubSpot&amp;#39;s own portal in a separate cluster. Along the bottom are the benefits: a simpler schema, small tablets, and a small blast radius." src="https://assets-cdn.selectdb.com/site/assets/shared/a5f60f889710fa9230deb209f24afd48.jpg" width="1600" height="900" class="img_ev3q"></p>
<p><em>Figure 6: Customers grouped by load, with one identically configured small cluster per group.</em></p>
<p>In practice, HubSpot computes a composite load score for each customer from data volume, write volume, search volume, analytical query volume, and latency. It then splits all customers into groups that each account for about 5% of the total load. Each group gets its own identically configured small cluster, and the application layer handles routing. HubSpot&apos;s own account carries a particularly heavy load, so it runs in a separate cluster. As Figure 6 shows, small clusters bring three benefits. Each cluster has a simpler schema. Tablets stay small enough that compaction does not become a problem, which is the first thing to watch when running heavy ingestion on Doris. And a failure in one cluster affects only a small share of customers.</p>
<p>HubSpot has strict security requirements for its data stores. Doris provides audit logging by default. To trace which system each query comes from, HubSpot created a separate database user for each infrastructure component. HubSpot also worked with VeloDB to implement mTLS for all traffic within a cluster in VeloDB Enterprise, along with database user authentication based on certificate SANs (Subject Alternative Names): only a system that holds the matching certificate can connect as that user.</p>
<p><strong>Lesson: when every cluster is configured the same way, results on a 5% sample predict the full rollout.</strong> After analytical queries went live on the first cluster, HubSpot was confident that it could scale to 100% quickly. Its method for measuring customer load was reliable, and the results were consistently reproducible. The rollout described in the next section bore this out.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="fresh-data-without-slower-queries">Fresh Data Without Slower Queries<a href="https://doris.apache.org/blog/hubspot-apache-doris-search-analytics/#fresh-data-without-slower-queries" class="hash-link" aria-label="Direct link to Fresh Data Without Slower Queries" title="Direct link to Fresh Data Without Slower Queries">&#x200B;</a></h3>
<p>Most of the work during the scale-up went into ingestion.</p>
<p><img decoding="async" loading="lazy" alt="CRM updates are prioritized and debounced into Kafka lanes for user edits, automations, and backfill. Java workers send user edits through synchronous Stream Load and everything else through Group Commit, throttle backfill based on compaction score and CPU, and publish transaction labels to track when data becomes visible." src="https://assets-cdn.selectdb.com/site/assets/shared/f40d630ce3112a15668ad92c6240043b.jpg" width="1600" height="760" class="img_ev3q"></p>
<p><em>Figure 7: The ingestion pipeline, with lanes separated by priority.</em></p>
<p>HubSpot first prioritizes ingestion traffic by its source (Figure 7). A user who edits a record by hand expects to see the change immediately, while an automation can usually take effect a few minutes later. High-priority writes target visibility within 5 seconds; lower priorities can take a few minutes.</p>
<p>Upstream CRM updates go through prioritization and debouncing, then into Kafka topics partitioned by cluster &#xD7; table &#xD7; priority. Each topic acts as a lane. HubSpot&apos;s own Java workers consume the lanes and write to the corresponding cluster through <a href="https://doris.apache.org/docs/dev/data-operate/import/import-way/stream-load-manual/">Stream Load</a>. The highest priority uses synchronous Stream Load and commits immediately. All other traffic uses <a href="https://doris.apache.org/docs/dev/data-operate/import/load-best-practices/group-commit-manual/">Group Commit</a>, which Doris batches on the server side about every 5 seconds. Writes that users are waiting for become visible right away, and the workers do not need to build large batches to protect the database, so HubSpot gets the best of both. The workers also check each cluster&apos;s compaction score and CPU usage and throttle backfill lanes when necessary. Each write returns a transaction label, which the workers publish to another topic; HubSpot uses that topic to determine when data becomes visible.</p>
<p>Together with the Unique Key model described earlier, this design keeps frequent updates from turning into merge costs at query time.</p>
<p><strong>Lesson: reserve synchronous Stream Load for the writes users are waiting on, and let Group Commit batch everything else.</strong></p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="rollout-and-results">Rollout and Results<a href="https://doris.apache.org/blog/hubspot-apache-doris-search-analytics/#rollout-and-results" class="hash-link" aria-label="Direct link to Rollout and Results" title="Direct link to Rollout and Results">&#x200B;</a></h2>
<p>With customers grouped into identically configured small clusters, HubSpot rolled out analytical queries in four steps (Figure 8). It started with one cluster in the NA1 data center, serving a sample of about 5% of customers. It then expanded to three clusters and about 15% of customers, then to all 21 clusters in NA1, and finally to the global deployment of 33 clusters.</p>
<p><img decoding="async" loading="lazy" alt="Four steps: 5% Sample Testing (1 cluster in the NA1 data center), 15% Sample Testing (3 clusters in NA1), 100% NA1 (21 clusters), and Global (33 clusters in total)." src="https://assets-cdn.selectdb.com/site/assets/shared/c3b1b529d911c27eee57f22c92fdc96f.jpg" width="1600" height="433" class="img_ev3q"></p>
<p><em>Figure 8: Analytical queries scaled from a 5% sample to 33 clusters worldwide.</em></p>
<p><strong>Going from the validated three-cluster stage to the global deployment took only about three weeks.</strong> Two things made the rollout smooth: the way HubSpot grouped customers into clusters, and Doris itself.</p>
<p>Figure 9 shows about two hours of monitoring around the switch. The yellow line is the backend execution time of analytical queries. It drops sharply at the switch to Doris and keeps falling over the following hour or so, <strong>with P50 going from about 1.8 seconds to about 500 milliseconds</strong>. The green line is the end-to-end time that users experience, which falls from about 2 seconds to about 1 second. The lower latency has also led to higher customer satisfaction.</p>
<p><img decoding="async" loading="lazy" alt="Monitoring chart from about 14:30 to 16:25. Backend latency (yellow) drops sharply from about 1.8 seconds around 15:24 and settles near 0.5 seconds, while end-to-end latency perceived by users (green) falls from about 2 seconds to about 1 second." src="https://assets-cdn.selectdb.com/site/assets/shared/a2fe4af04c26d0920d66c8d06fef79ac.jpg" width="1600" height="953" class="img_ev3q"></p>
<p><em>Figure 9: P50 query latency over about two hours around the switch. Yellow is backend latency; green is the end-to-end time that users experience.</em></p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="whats-next-search-and-events">What&apos;s Next: Search and Events<a href="https://doris.apache.org/blog/hubspot-apache-doris-search-analytics/#whats-next-search-and-events" class="hash-link" aria-label="Direct link to What&apos;s Next: Search and Events" title="Direct link to What&apos;s Next: Search and Events">&#x200B;</a></h2>
<p>HubSpot&apos;s next step is to run search on Doris as well. Search and analytical queries share the same data model. Through the partnership, HubSpot and VeloDB have already made several improvements for search: a query function used much like the Elasticsearch query string, inverted index predicate pushdown in certain joins, better concurrency, and smooth rolling restarts. The two teams have also delivered fixes for cgroup memory accounting, concurrent cumulative compaction, and other areas, along with many smaller improvements.</p>
<p>The main challenges now are high concurrency and cache availability. The cache holds only one copy of the data, so losing a single node noticeably hurts workloads with strict latency requirements. Newer Doris releases already address this with <a href="https://doris.apache.org/docs/dev/compute-storage-decoupled/file-cache/file-cache-peer-read/">Peer Read</a>. High QPS is a challenge for most databases, but the results so far are very good. Next, HubSpot plans to upgrade to a newer release and start testing scoring and semantic search.</p>
<p>Events are another direction. Today, only object queries run on Doris, and HubSpot wants to run analytical queries on events next. Event data is orders of magnitude larger than object data and already lives entirely in Iceberg, so HubSpot plans to start by querying Iceberg directly through Doris. Because event data does not fit in the cache, object data will need to be pinned in the cache. If performance falls short, HubSpot will consider a hybrid architecture.</p>
<p>Further out, HubSpot plans to consolidate more datasets into Doris and evaluate capabilities such as federated queries, which would give other teams more flexible options.</p>
<hr>
<p>This article is based on <a href="https://apache-doris-summit.org/watch/hubspot" target="_blank" rel="noopener noreferrer"><em>Evolving Semi-Structured Search &amp; Analytical Queries at HubSpot</em></a>, a Doris Summit 2026 talk by HubSpot Staff Software Engineer Alvaro Tuso. The full recording is available on demand. Figures 2, 3, 8, and 9 come from the talk&apos;s slides; the other figures were created for this article based on the talk. This article is part of the Doris Summit 2026 series. The <a href="https://doris.apache.org/blog/doris-summit-2026-recap/">Doris Summit 2026 Recap</a> covers the main themes of the conference, and the next article covers Apache Fluss.</p>
<p>Get involved with the community:</p>
<ul>
<li>Website: <a href="https://doris.apache.org/">https://doris.apache.org</a></li>
<li>Contribute: <a href="https://doris.apache.org/community/how-to-contribute/contribute-to-doris/">https://doris.apache.org/community/how-to-contribute/contribute-to-doris</a></li>
<li>GitHub: <a href="https://github.com/apache/doris" target="_blank" rel="noopener noreferrer">github.com/apache/doris</a></li>
<li>Slack: <a href="https://doris.apache.org/slack/">doris.apache.org/slack</a></li>
</ul></div>]]></content:encoded>
            <category>Best Practice</category>
        </item>
        <item>
            <title><![CDATA[Streaming Changes out of Doris: CDC and Incremental Computing in Apache Doris 5.0]]></title>
            <link>https://doris.apache.org/blog/apache-doris-5-cdc-changelog/</link>
            <guid>https://doris.apache.org/blog/apache-doris-5-cdc-changelog/</guid>
            <pubDate>Thu, 12 Nov 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[A technical preview of Apache Doris 5.0 CDC: Changelog read modes, atomic writes, TSO ordering, retention, Flink recovery and delivery semantics, with advertising and product-price examples.]]></description>
            <content:encoded><![CDATA[<header><div class="text-center mb-4"><a class="cursor-pointer hover:no-underline" lang="en" href="https://doris.apache.org/blog/">Blog</a><span class="px-2 text-[#8592A6]">/</span><span><span class="s-tags" lang="en"><span class="s-tag">Tech Sharing</span></span></span></div><h1 lang="en" class="blog-post-title text-[2rem] leading-normal lg:!text-[2.5rem] text-center" itemprop="headline">Streaming Changes out of Doris: CDC and Incremental Computing in Apache Doris 5.0</h1><div class="blog-info text-center flex justify-center text-sm text-black"><span class="authors"><span class="s-author text-black">Apache Doris &#xB7; Mingyu Chen</span></span><time datetime="2026-11-12T00:00:00.000Z" itemprop="datePublished" class="text-black ml-4">November 12, 2026</time></div></header><div id="__blog-post-container" class="markdown" itemprop="articleBody"><p><em>By Mingyu Chen, Apache Doris PMC Chair. Adapted from the <a href="https://selectdb.com/blog/doris-apache-doris-5-0-cdc" target="_blank" rel="noopener noreferrer">original article</a>, published on November 12, 2026.</em></p>
<blockquote>
<p>This is the second article in the Apache Doris 5.0 incremental computing preview. The <a href="https://doris.apache.org/blog/apache-doris-5-incremental-computing/">first article</a> introduced the framework through business scenarios. This article examines how Changelog captures changes and how Flink Doris Connector delivers them downstream, then shows how IVM and Table Stream can prepare those changes inside Doris.</p>
</blockquote>
<p><strong>These capabilities are a preview of Doris 5.0.</strong> Changelog, Table Stream, and IVM are experimental and require explicit configuration. The examples target Doris 5.0.0+ and Flink Doris Connector 26.4.0+; preview use requires builds containing the relevant changes.</p>
<p>Doris has often been the last stop in a real-time warehouse pipeline. Changes from operational databases arrive through Flink CDC, Routine Load, or Stream Load, become metrics and denormalized tables, and serve reports and applications.</p>
<p>Increasingly, teams use Doris as an intermediate computation engine. An advertising platform aggregates campaign spend in Doris and sends the results to its serving system for budget control. An e-commerce platform merges product data from several pipelines and synchronizes prices to a search engine. Data teams share processed tables and metrics with other business systems and data lakes. <strong>Downstream systems need timely, accurate changes to the results computed in Doris.</strong></p>
<p>Previously, teams had three common approaches:</p>
<ul>
<li>Periodically export the entire result and compare it, with high latency and cost.</li>
<li>Export rows by an <code>update_time</code> column, which misses deletes.</li>
<li>Reimplement the processing in Flink, maintaining the same logic in two systems.</li>
</ul>
<p>Doris 5.0 introduces Changelog into its storage format to record inserts, updates, and deletes as data is written, with optional before images. Interfaces expose those changes for further processing and downstream consumption. This article explains the implementation and its tradeoffs.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="1-changelog-recording-changes-in-a-distributed-column-store">1. Changelog: recording changes in a distributed column store<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#1-changelog-recording-changes-in-a-distributed-column-store" class="hash-link" aria-label="Direct link to 1. Changelog: recording changes in a distributed column store" title="Direct link to 1. Changelog: recording changes in a distributed column store">&#x200B;</a></h2>
<p>A single-node database such as MySQL can append its binlog on one machine in commit order. Doris distributes data across many tablets on many machines, with several replicas per tablet and high write throughput. Its change log must answer three questions:</p>
<ul>
<li>How do change records stay consistent with the data?</li>
<li>How is change order represented across a distributed system?</li>
<li>How can changes be recorded and read efficiently?</li>
</ul>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="11-three-read-modes-detail-min_delta-and-append_only">1.1 Three read modes: DETAIL, MIN_DELTA, and APPEND_ONLY<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#11-three-read-modes-detail-min_delta-and-append_only" class="hash-link" aria-label="Direct link to 1.1 Three read modes: DETAIL, MIN_DELTA, and APPEND_ONLY" title="Direct link to 1.1 Three read modes: DETAIL, MIN_DELTA, and APPEND_ONLY">&#x200B;</a></h3>
<p>Enable Changelog with the table property <code>changelog.enable</code> when creating a table. Duplicate Key tables and Unique Key Merge-on-Write tables support it. A Unique Key table can also enable <code>changelog.need_historical_value</code> to retain the old row, or <strong>before image</strong>, for an update. An update can then become a pair of Flink change events: <code>-U</code> and <code>+U</code>.</p>
<p>Before trying the examples, set <code>enable_feature_changelog = true</code> in <code>fe.conf</code> on every FE and restart the FEs. Set the same option in <code>be.conf</code> and restart the BEs for automatic cleanup. For Table Stream and IVM, also set <code>enable_table_stream = true</code> on every FE. See the <a href="https://doris.apache.org/docs/dev/data-operate/incremental/changelog/">Changelog prerequisites and limitations</a>.</p>
<p>The order examples use a table with before images enabled:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DATABASE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">IF</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">NOT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">EXISTS</span><span class="token plain"> shop</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">USE</span><span class="token plain"> shop</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">TABLE</span><span class="token plain"> orders </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    order_id </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BIGINT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">status</span><span class="token plain">   </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VARCHAR</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">16</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">UNIQUE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">KEY</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">order_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DISTRIBUTED</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">HASH</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">order_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> BUCKETS </span><span class="token number" style="color:hsl(35, 99%, 36%)">1</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">PROPERTIES </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;replication_num&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;1&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;enable_unique_key_merge_on_write&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;changelog.enable&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;changelog.need_historical_value&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>Append <code>@incr</code> to the table name and specify a time window and read mode to query changes like a table. The examples below illustrate a historical five-minute window; when experimenting, substitute recent timestamps and writes within your Changelog retention period. Windows are <strong>start-inclusive and end-exclusive</strong>.</p>
<p>Assume that between 10:00 and 10:05:</p>
<ul>
<li>Order 1000, shipped before 10:00, is confirmed delivered.</li>
<li>Order 1001 is created and then paid.</li>
<li>Order 1002 is inserted as a duplicate order and then deleted.</li>
</ul>
<p><img decoding="async" loading="lazy" alt="The same change window produces every change in DETAIL, net changes in MIN_DELTA, or insert events in APPEND_ONLY" src="https://assets-cdn.selectdb.com/site/assets/shared/90dc420497ea174909a74c81cbf9fcc6.jpg" width="1200" height="630" class="img_ev3q"></p>
<p><em>Figure 1. DETAIL suits auditing and risk analysis; MIN_DELTA suits state synchronization; APPEND_ONLY suits logs and event streams.</em></p>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="detail-keep-every-change">DETAIL: keep every change<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#detail-keep-every-change" class="hash-link" aria-label="Direct link to DETAIL: keep every change" title="Direct link to DETAIL: keep every change">&#x200B;</a></h4>
<p>Auditing, risk analysis, and order lifecycle analysis need individual transitions. Read the window in <code>DETAIL</code> mode:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> __DORIS_CHANGELOG_OP__ </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> op</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> order_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">status</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> orders</span><span class="token variable" style="color:hsl(221, 87%, 60%)">@incr</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;startTimestamp&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;2026-11-11 10:00:00&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;endTimestamp&apos;</span><span class="token plain">   </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;2026-11-11 10:05:00&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;incrementType&apos;</span><span class="token plain">  </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;DETAIL&apos;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ORDER</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> __DORIS_CHANGELOG_TSO__</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> __DORIS_CHANGELOG_LSN__</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> op</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>The window contains seven records. The following table groups them by order for readability:</p>













































<table><thead><tr><th>op</th><th>order_id</th><th>status</th></tr></thead><tbody><tr><td>-U</td><td>1000</td><td>shipped</td></tr><tr><td>+U</td><td>1000</td><td>delivered</td></tr><tr><td>+I</td><td>1001</td><td>pending</td></tr><tr><td>-U</td><td>1001</td><td>pending</td></tr><tr><td>+U</td><td>1001</td><td>paid</td></tr><tr><td>+I</td><td>1002</td><td>pending</td></tr><tr><td>-D</td><td>1002</td><td>pending</td></tr></tbody></table>
<p>The query returns numeric operation codes: <code>0</code> means insert (<code>+I</code>), <code>1</code> delete (<code>-D</code>), <code>2</code> update-before (<code>-U</code>), and <code>3</code> update-after (<code>+U</code>). Tables in this article use the symbolic forms. These are the codes exposed by <code>@incr</code>; the raw <code>changelog()</code> table function has a different operation-code mapping.</p>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="min_delta-keep-only-net-changes">MIN_DELTA: keep only net changes<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#min_delta-keep-only-net-changes" class="hash-link" aria-label="Direct link to MIN_DELTA: keep only net changes" title="Direct link to MIN_DELTA: keep only net changes">&#x200B;</a></h4>
<p>Some consumers need only final state. A support system or search index does not need order 1001&apos;s intermediate <code>pending</code> state. Order 1002 was both created and deleted, leaving no net change.</p>
<p>Changing <code>incrementType</code> to <code>MIN_DELTA</code> collapses multiple changes to a key within the window. The seven records become three:</p>

























<table><thead><tr><th>op</th><th>order_id</th><th>status</th></tr></thead><tbody><tr><td>-U</td><td>1000</td><td>shipped</td></tr><tr><td>+U</td><td>1000</td><td>delivered</td></tr><tr><td>+I</td><td>1001</td><td>paid</td></tr></tbody></table>
<ul>
<li>Order 1000 existed at the start, so its net change is an update.</li>
<li>Order 1001 did not exist at the start, so its net change is an insert with status <code>paid</code>.</li>
<li>Order 1002 exists at neither boundary, so it produces no output.</li>
</ul>
<p><strong>Doris performs this consolidation</strong>, reducing intermediate states and redundant updates sent downstream.</p>
<blockquote>
<p>MIN_DELTA requires before images on Unique Key tables because it needs the value at the start of the window. Section 1.5 explains why.</p>
</blockquote>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="append_only-read-insert-events">APPEND_ONLY: read insert events<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#append_only-read-insert-events" class="hash-link" aria-label="Direct link to APPEND_ONLY: read insert events" title="Direct link to APPEND_ONLY: read insert events">&#x200B;</a></h4>
<p>For logs, tracking events, or consumers interested only in newly inserted rows, use <code>APPEND_ONLY</code>:</p>




















<table><thead><tr><th>op</th><th>order_id</th><th>status</th></tr></thead><tbody><tr><td>+I</td><td>1001</td><td>pending</td></tr><tr><td>+I</td><td>1002</td><td>pending</td></tr></tbody></table>
<p>Order 1000 has only an update, so it produces no output. Order 1002&apos;s insert is still emitted even though the order is later deleted.</p>
<p>The differences among these modes apply to Unique Key tables. Duplicate Key tables record appended rows, so all three modes produce the same insert events. Deletes implemented through delete predicates on Duplicate Key tables do not produce Changelog events.</p>
<p>See <a href="https://doris.apache.org/docs/dev/data-operate/incremental/incremental-query/">Incremental Query</a> for the complete <code>@incr</code> syntax and output columns.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="12-generating-changelog-atomically-with-data">1.2 Generating Changelog atomically with data<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#12-generating-changelog-atomically-with-data" class="hash-link" aria-label="Direct link to 1.2 Generating Changelog atomically with data" title="Direct link to 1.2 Generating Changelog atomically with data">&#x200B;</a></h3>
<p><img decoding="async" loading="lazy" alt="Each replica writes a data tablet and companion Changelog tablet on the same local disk, making both visible through the load transaction" src="https://assets-cdn.selectdb.com/site/assets/shared/9641fa219597854fa8ff6d5b84f3e29f.jpg" width="1200" height="630" class="img_ev3q"></p>
<p><em>Figure 2. Data files and change records become visible together through the load transaction.</em></p>
<ul>
<li><strong>Companion tablets:</strong> Every data tablet has a Changelog tablet. Each replica writes data files and change records together. When before images are needed, the old row is looked up locally. The load transaction makes both sets of files visible together, or neither.</li>
<li><strong>Per-load consolidation:</strong> Unique Key tables record changes per key per load. If the same key is written several times within one load, Changelog records the final result. Duplicate Key tables record every inserted row.</li>
<li><strong>Concurrent writes:</strong> When several loads modify the same key, an earlier lookup may return an outdated old value. Changelog reuses the Unique Key table&apos;s write-conflict handling. If a conflict is detected at commit, affected records are corrected against the latest version so the before image matches the row&apos;s actual preceding version.</li>
</ul>
<blockquote>
<p>Operations that replace or remove whole datasets, such as <code>TRUNCATE</code>, dropping or replacing partitions, and <code>INSERT OVERWRITE</code>, do not emit a delete event for every removed row. Dependent materialized views may need rebuilding, and downstream replicas of current table state need a new full synchronization. Append-only processing, such as the Table Stream example in Section 3.1, intentionally accumulates arrivals independently of later base-table removal.</p>
</blockquote>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="13-ordering-changes-with-tso-and-lsn">1.3 Ordering changes with TSO and LSN<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#13-ordering-changes-with-tso-and-lsn" class="hash-link" aria-label="Direct link to 1.3 Ordering changes with TSO and LSN" title="Direct link to 1.3 Ordering changes with TSO and LSN">&#x200B;</a></h3>
<p>Doris&apos;s original data versions increase independently within each partition. They cannot establish order across partitions or tables. Time-window reads need a shared clock: <strong>TSO, or Timestamp Oracle</strong>.</p>
<p><img decoding="async" loading="lazy" alt="The Master FE assigns increasing commit timestamps across tables and partitions, mapping adjacent time windows to contiguous TSO ranges" src="https://assets-cdn.selectdb.com/site/assets/shared/9e85d00f9a8a71e38f095c1a1cc77926.jpg" width="1200" height="630" class="img_ev3q"></p>
<p><em>Figure 3. The Master FE allocates TSO at commit. Adjacent time windows map to contiguous ranges without overlap or gaps.</em></p>
<ul>
<li><strong>One allocator, monotonically increasing values:</strong> The Master FE allocates TSO. High bits contain physical time in milliseconds; low bits count commits within the same millisecond. Values do not move backward after a master change or clock rollback. Physical time lets a window such as 10:00&#x2013;10:05 map to a TSO range.</li>
<li><strong>One TSO per transaction, allocated at commit:</strong> Allocating it at transaction start would misplace long-running loads. A transaction beginning at 10:00 and committing at 10:30 must not appear in a 10:00 window that consumers have already finished.</li>
<li><strong>Wait for visibility before reading:</strong> Receiving a TSO does not immediately make the data readable. A transaction committed at 10:04 belongs to <code>[10:00, 10:05)</code> even if publication finishes after 10:05. Reading too early would miss it, and the next window would exclude it. Doris therefore waits for the relevant transactions to become visible before reading. A timeout returns an error so the consumer can retry the same window.</li>
</ul>
<p><img decoding="async" loading="lazy" alt="Reading before a 10:04 commit becomes visible can lose it permanently; waiting for Publish allows the original time window to be read completely" src="https://assets-cdn.selectdb.com/site/assets/shared/bafb3fbce816889295d539022aade403.jpg" width="1200" height="630" class="img_ev3q"></p>
<p><em>Figure 4. Commit time determines the window; visibility determines when it is safe to read that window.</em></p>
<p>Rows changed in the same transaction share a TSO. LSN provides a sequence number to order those change records. A row carries the same LSN to every replica, so replicas record the same change order.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="14-retention-and-cleanup">1.4 Retention and cleanup<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#14-retention-and-cleanup" class="hash-link" aria-label="Direct link to 1.4 Retention and cleanup" title="Direct link to 1.4 Retention and cleanup">&#x200B;</a></h3>
<p>Changelog retains records for <strong>one day by default</strong>, controlled by <code>changelog.ttl_seconds</code>. Expired records become unavailable to queries immediately; background cleanup reclaims their storage later.</p>
<p>TTL depends on time, not consumer progress. Consumers do not need registration and do not block each other&apos;s retention. The tradeoff is that slow consumers can lose required history:</p>
<ul>
<li><code>DETAIL</code> and <code>APPEND_ONLY</code> skip expired portions of a requested window without reporting an expiration error.</li>
<li><code>MIN_DELTA</code> and IVM fail if the required starting history has expired, because they cannot compute a correct net change without it.</li>
</ul>
<p><strong>Retention must cover the initial snapshot duration, the longest expected outage, and catch-up time after recovery</strong>, with margin. Monitor consumer lag; a running job alone does not establish that no history has expired.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="15-reading-and-consolidating-changes">1.5 Reading and consolidating changes<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#15-reading-and-consolidating-changes" class="hash-link" aria-label="Direct link to 1.5 Reading and consolidating changes" title="Direct link to 1.5 Reading and consolidating changes">&#x200B;</a></h3>
<p><strong>Prune by time.</strong> Change files carry TSO ranges. Reads skip files outside the requested range rather than scanning the entire Changelog.</p>
<p><strong>Consolidate MIN_DELTA.</strong> For each key, Doris considers the first and last change within the window. The before image of the first record supplies the starting value; the after image of the last record supplies the ending value.</p>



































<table><thead><tr><th>State at start</th><th>State at end</th><th>Output</th></tr></thead><tbody><tr><td>Absent</td><td>Present</td><td>Insert (<code>+I</code>)</td></tr><tr><td>Present</td><td>Absent</td><td>Delete (<code>-D</code>)</td></tr><tr><td>Absent</td><td>Absent</td><td>None</td></tr><tr><td>Present</td><td>Present, different row</td><td>Update-before and update-after (<code>-U</code>, <code>+U</code>)</td></tr><tr><td>Present</td><td>Present, identical row</td><td>None</td></tr></tbody></table>
<p>Before images avoid a separate lookup of historical table data. This is why MIN_DELTA needs them. Comparison covers the <strong>whole row</strong>: a change in any column counts as an update.</p>
<p><strong>Track internal and external consumption differently.</strong> Table Stream and IVM maintain TSO positions for each base-table partition. Processing results and new positions commit in one Doris transaction and roll back together on failure. External systems cannot participate in that transaction; they read time windows and save their own progress. Flink Doris Connector is one such consumer.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="16-costs-and-limitations">1.6 Costs and limitations<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#16-costs-and-limitations" class="hash-link" aria-label="Direct link to 1.6 Costs and limitations" title="Direct link to 1.6 Costs and limitations">&#x200B;</a></h3>
<p>Changelog adds writes and storage. Enabling before images also adds old-row lookups, reducing ingestion throughput by an amount that depends on table structure and update frequency. Append-only workloads can avoid those lookups with Duplicate Key tables or without before images.</p>
<p>Changelog can currently be enabled only at table creation. Tables with it support only the permitted light schema changes, and do not support backup and restore. Evaluate these constraints before creating source tables.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="2-flink-doris-connector-delivering-changes-downstream">2. Flink Doris Connector: delivering changes downstream<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#2-flink-doris-connector-delivering-changes-downstream" class="hash-link" aria-label="Direct link to 2. Flink Doris Connector: delivering changes downstream" title="Direct link to 2. Flink Doris Connector: delivering changes downstream">&#x200B;</a></h2>
<p><img decoding="async" loading="lazy" alt="Changelog from Doris tables and materialized views becomes a Flink change stream that sinks write to Kafka, MySQL, lake tables, or another Doris cluster" src="https://assets-cdn.selectdb.com/site/assets/shared/42e2ad0f7b3bb206715d6967f28b083c.jpg" width="1200" height="630" class="img_ev3q"></p>
<p><em>Figure 5. Internal consumers and Flink can consume the same Changelog for different purposes.</em></p>
<p>Flink Doris Connector converts Doris changes into Flink insert, update-before, update-after, and delete events. Flink sinks can then send them to Kafka, MySQL, data lakes, or another Doris cluster.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="21-declare-a-doris-table-as-a-change-stream">2.1 Declare a Doris table as a change stream<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#21-declare-a-doris-table-as-a-change-stream" class="hash-link" aria-label="Direct link to 2.1 Declare a Doris table as a change stream" title="Direct link to 2.1 Declare a Doris table as a change stream">&#x200B;</a></h3>
<p>To synchronize order state to a customer-support system, declare the orders table in Flink SQL:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">SET</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;execution.checkpointing.interval&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;10s&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">TABLE</span><span class="token plain"> order_changes </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    order_id </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BIGINT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">status</span><span class="token plain">   STRING</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">PRIMARY</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">KEY</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">order_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">NOT</span><span class="token plain"> ENFORCED</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">WITH</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;connector&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;doris&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;fenodes&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;&lt;fe-host&gt;:8030&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;table.identifier&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;shop.orders&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;username&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;&lt;doris-user&gt;&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;password&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;&lt;doris-password&gt;&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;source.scan.mode&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;initial&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;source.changelog.increment-type&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;min_delta&apos;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>The source emits <code>+I</code>, <code>-U</code>, <code>+U</code>, and <code>-D</code> records. Connect it to a sink that supports the required updates and deletes, such as a primary-key MySQL table or upsert-kafka. Two options control how a new consumer starts and reads:</p>

















<table><thead><tr><th>Option</th><th>Values and behavior</th></tr></thead><tbody><tr><td><code>source.scan.mode</code></td><td><code>snapshot</code> (default): one full read; <code>initial</code>: snapshot then changes; <code>latest</code>: changes from startup; <code>from-timestamp</code>: changes from <code>source.scan.timestamp</code></td></tr><tr><td><code>source.changelog.increment-type</code></td><td><code>detail</code> (default), <code>min_delta</code>, or <code>append_only</code>. With <code>min_delta</code>, each poll&apos;s read window is the consolidation window.</td></tr></tbody></table>
<p>In <code>initial</code> mode, the connector saves the incremental starting position before reading the snapshot. Changes committed after that position are covered by the snapshot, the incremental stream, or both. This avoids omissions but can produce duplicates because the snapshot reads current data while the later incremental read also covers changes made during snapshot collection.</p>
<p>The connector therefore provides <strong>at-least-once source delivery</strong>. Downstream processing must handle duplicates to achieve exactly-once effects. Duplicate Key tables have no primary key to absorb repeated rows; <code>latest</code> or <code>from-timestamp</code>, with a separately managed initial load, is often more suitable for them.</p>
<p>See <a href="https://doris.apache.org/docs/dev/connection-integration/data-integration/flink-doris-connector/incremental-read/">Incremental Reading with Doris Changelog</a> for connector setup, options, and recovery rules.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="22-read-successive-time-windows">2.2 Read successive time windows<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#22-read-successive-time-windows" class="hash-link" aria-label="Direct link to 2.2 Read successive time windows" title="Direct link to 2.2 Read successive time windows">&#x200B;</a></h3>
<p><img decoding="async" loading="lazy" alt="An Enumerator plans time windows and assigns Changelog shards to parallel Readers using Arrow Flight SQL, with checkpoint state and an optional external offset table" src="https://assets-cdn.selectdb.com/site/assets/shared/3e036c80aca0ba572252c0033a343176.jpg" width="1200" height="630" class="img_ev3q"></p>
<p><em>Figure 6. Checkpoints record read progress. The optional external offset table advances after checkpoint completion and records only fully consumed windows.</em></p>
<p>Two roles cooperate:</p>
<ul>
<li>The <strong>Enumerator</strong> obtains the current TSO at each polling interval (<code>source.changelog.poll-interval</code>, default <code>10s</code>), creates a window such as <code>[10:00:00, 10:00:10)</code>, discovers the Changelog shards, and assigns read tasks.</li>
<li><strong>Readers</strong> read assigned shards in parallel through Arrow Flight SQL and convert records into Flink change events.</li>
</ul>
<p>The next window starts only after every shard in the current window has finished. Windows have second-level precision and the minimum poll interval is one second. The design targets latency from seconds to tens of seconds; actual end-to-end delay also depends on workload, backlog, and downstream processing.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="23-recover-from-checkpoints">2.3 Recover from checkpoints<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#23-recover-from-checkpoints" class="hash-link" aria-label="Direct link to 2.3 Recover from checkpoints" title="Direct link to 2.3 Recover from checkpoints">&#x200B;</a></h3>
<p>Checkpoints save the active window and unfinished shards. After failure, the job resumes from the latest completed checkpoint. Shards already marked complete there stay complete; unfinished shards restart from the beginning of that window. Some records can therefore arrive again.</p>
<p>Optionally, <code>source.changelog.offset-table</code> and <code>source.changelog.consumer-id</code> publish progress to a Doris table. This provides a restart position when a job is recreated without restoring Flink checkpoint state. The table updates after checkpoints complete and records only fully consumed windows, so restarting from it can replay a larger range.</p>
<p>Recovery still depends on retention. If the required start has expired, <code>detail</code> and <code>append_only</code> skip expired changes, while <code>min_delta</code> fails. Configure retention with enough margin and monitor consumption lag.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="24-end-to-end-exactly-once-effects">2.4 End-to-end exactly-once effects<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#24-end-to-end-exactly-once-effects" class="hash-link" aria-label="Direct link to 2.4 End-to-end exactly-once effects" title="Direct link to 2.4 End-to-end exactly-once effects">&#x200B;</a></h3>
<p>A cross-system pipeline cannot share one Doris transaction. The design combines <strong>at-least-once delivery from the source with duplicate-safe downstream application</strong>.</p>
<p><img decoding="async" loading="lazy" alt="At-least-once source delivery and applying repeated events at most once combine to provide exactly-once effects, with per-key ordering required for upserts" src="https://assets-cdn.selectdb.com/site/assets/shared/6441bc53e591419ea46757f31f65c8fe.jpg" width="1200" height="630" class="img_ev3q"></p>
<p><em>Figure 7. &#x201C;At-most-once&#x201D; here describes applying a repeated change at most once, not a delivery mode that permits data loss.</em></p>
<p>On the source side, waiting for transaction visibility closes the requested window before reading. Checkpoints and the optional offset table make progress recoverable. Replays can occur after checkpoint recovery, during the snapshot-to-incremental transition, or when restarting from the external offset table. These guarantees assume the needed records remain within retention.</p>
<p>Common downstream strategies include:</p>
<ul>
<li><strong>Primary-key upserts:</strong> A Doris Unique Key table or MySQL table can absorb repeated idempotent writes of the same row state.</li>
<li><strong>Further Flink aggregation or joins:</strong> Declare the source primary key and set <code>table.exec.source.cdc-events-duplicate</code> to <code>true</code> so Flink can absorb duplicate CDC events. This requires keeping the latest row for each key in state.</li>
<li><strong>Append-only destinations:</strong> Ordinary Kafka topics and files need event deduplication, for example by <code>(TSO, LSN, OP)</code> within the source table. Access to these metadata fields requires the DataStream API. An upsert-capable destination is another option.</li>
</ul>
<p>Primary-key upserts also need <strong>per-key order through the sink</strong>. If order 1001&apos;s <code>paid</code> update is applied before an older <code>pending</code> insert, the final state is wrong. Source ordering alone does not establish an end-to-end guarantee; downstream partitioning, deduplication, state recovery, and sink behavior must preserve the intended effects.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="25-read-shards-in-parallel">2.5 Read shards in parallel<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#25-read-shards-in-parallel" class="hash-link" aria-label="Direct link to 2.5 Read shards in parallel" title="Direct link to 2.5 Read shards in parallel">&#x200B;</a></h3>
<p><img decoding="async" loading="lazy" alt="Changelog shards distributed across Doris nodes are read by several Flink Readers in parallel" src="https://assets-cdn.selectdb.com/site/assets/shared/c72a07642909cb1a00a25b6233379673.jpg" width="1200" height="630" class="img_ev3q"></p>
<p><em>Figure 8. Sharding allows parallel consumption, with no global ordering across shards.</em></p>
<ul>
<li><strong>Assignment:</strong> The Enumerator hashes shard IDs to Readers. With unchanged parallelism, existing assignments remain stable as new shards appear. A small number of shards can produce uneven assignments.</li>
<li><strong>Ordering:</strong> Changes for a key stay in one shard and are read sequentially by one Reader. Windows are also processed in sequence. Different shards have no global output order.</li>
<li><strong>Synchronization:</strong> Every Reader must finish the current window before the next begins. The slowest shard sets the pace, especially under skew.</li>
<li><strong>Parallelism limit:</strong> Effective parallelism cannot exceed the number of Changelog shards, equal to the sum of bucket counts across partitions. Table bucketing therefore limits consumption parallelism.</li>
</ul>
<p>When a job is rescaled, it restores checkpoint state, replays unfinished shards for the window, and assigns work using the new parallelism.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="3-process-changes-inside-doris-before-delivery">3. Process changes inside Doris before delivery<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#3-process-changes-inside-doris-before-delivery" class="hash-link" aria-label="Direct link to 3. Process changes inside Doris before delivery" title="Direct link to 3. Process changes inside Doris before delivery">&#x200B;</a></h2>
<p>Downstream systems often need changes to derived results rather than raw source rows. Doris can prepare those results with two mechanisms:</p>
<ul>
<li><a href="https://doris.apache.org/docs/dev/query-acceleration/materialized-view/async-materialized-view/incremental-materialized-view/">Incremental view maintenance (IVM)</a> updates affected parts of a SQL-defined materialized view from base-table Changelog, avoiding full recomputation on each refresh.</li>
<li><a href="https://doris.apache.org/docs/dev/data-operate/incremental/table-stream/">Table Stream</a> exposes unconsumed table changes and tracks progress. Consuming it with <code>INSERT</code> commits the result write and progress advance in the same Doris transaction. Failure rolls both back.</li>
</ul>
<p>The result table or materialized view can enable its own Changelog. Its derived changes can then be consumed using <code>DETAIL</code> or <code>MIN_DELTA</code>, creating a multi-stage processing pipeline.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="31-deliver-changes-to-campaign-spend">3.1 Deliver changes to campaign spend<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#31-deliver-changes-to-campaign-spend" class="hash-link" aria-label="Direct link to 3.1 Deliver changes to campaign spend" title="Direct link to 3.1 Deliver changes to campaign spend">&#x200B;</a></h3>
<p>An advertising platform bills per click. Billing entries flow into Doris, while a serving system must track cumulative spend per campaign. It pauses a campaign when spend reaches its budget. Fraud detection can later insert negative reversal entries for invalid clicks, reducing spend and allowing the campaign to resume.</p>
<p>The serving system needs a result such as &#x201C;campaign A&apos;s spend changed from CNY 950 to CNY 1,000.&#x201D; Sending raw billing events would make it reimplement aggregation in Flink or repeatedly query Doris.</p>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="use-an-aggregate-materialized-view-and-its-changelog">Use an aggregate materialized view and its Changelog<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#use-an-aggregate-materialized-view-and-its-changelog" class="hash-link" aria-label="Direct link to Use an aggregate materialized view and its Changelog" title="Direct link to Use an aggregate materialized view and its Changelog">&#x200B;</a></h4>
<p>Define spend per campaign in SQL and incrementally refresh after base-table commits. Enable Changelog and before images on the view so every refresh can expose changes to cumulative spend.</p>
<p><img decoding="async" loading="lazy" alt="An aggregate materialized view turns click billing entries into spend changes, pausing a campaign at its budget and resuming it after a reversal" src="https://assets-cdn.selectdb.com/site/assets/shared/1cdc4c3f2d24897cd044481ac62df973.jpg" width="1200" height="630" class="img_ev3q"></p>
<p><em>Figure 9. With a CNY 1,000 budget, reaching the limit pauses serving; a reversal reducing spend to CNY 970 permits resumption.</em></p>
<p>Run the following in Doris. The examples use 16 buckets and the cluster&apos;s default replication; size both for your deployment.</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DATABASE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">IF</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">NOT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">EXISTS</span><span class="token plain"> ads</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">USE</span><span class="token plain"> ads</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- Append-only billing entries. Reversals use negative amounts.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">TABLE</span><span class="token plain"> click_billing </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    campaign_id  </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BIGINT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    billing_time </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DATETIME</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    amount       </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DECIMAL</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">18</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">2</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DUPLICATE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">KEY</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">campaign_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> billing_time</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DISTRIBUTED</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">HASH</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">campaign_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> BUCKETS </span><span class="token number" style="color:hsl(35, 99%, 36%)">16</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">PROPERTIES </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;changelog.enable&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- Incrementally refresh after commits and record changes to the result.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> MATERIALIZED </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VIEW</span><span class="token plain"> campaign_spend_mv</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">BUILD IMMEDIATE REFRESH INCREMENTAL </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ON</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">COMMIT</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">KEY</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">campaign_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DISTRIBUTED</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">HASH</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">campaign_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> BUCKETS </span><span class="token number" style="color:hsl(35, 99%, 36%)">16</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">PROPERTIES </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;changelog.enable&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;changelog.need_historical_value&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> campaign_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token function" style="color:hsl(221, 87%, 60%)">SUM</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">amount</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> spend</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> click_billing</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">GROUP</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> campaign_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p><code>ON COMMIT</code> triggers asynchronous refresh tasks. Wait for the initial build to succeed before relying on the view; later result changes become available after their refresh completes. The following timeline illustrates the resulting spend changes rather than guaranteeing a refresh at every wall-clock timestamp.</p>



































<table><thead><tr><th>Time</th><th>Event</th><th style="text-align:right">Cumulative spend (CNY)</th><th>View Changelog</th></tr></thead><tbody><tr><td>10:00:01</td><td>First billing batch</td><td style="text-align:right">800</td><td>+I 800</td></tr><tr><td>10:00:04</td><td>Further charges</td><td style="text-align:right">950</td><td>-U 800, +U 950</td></tr><tr><td>10:00:08</td><td>Charges reach the budget</td><td style="text-align:right">1,000</td><td>-U 950, +U 1,000</td></tr><tr><td>10:00:15</td><td>Reverse CNY 30 of invalid clicks</td><td style="text-align:right">970</td><td>-U 1,000, +U 970</td></tr></tbody></table>
<p>If the serving system needs only the latest spend, use <code>MIN_DELTA</code>. For example, the first ten-second window is:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> __DORIS_CHANGELOG_OP__ </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> op</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> campaign_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> spend</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> campaign_spend_mv</span><span class="token variable" style="color:hsl(221, 87%, 60%)">@incr</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;startTimestamp&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;2026-11-11 10:00:00&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;endTimestamp&apos;</span><span class="token plain">   </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;2026-11-11 10:00:10&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;incrementType&apos;</span><span class="token plain">  </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;MIN_DELTA&apos;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>In the illustrated window, campaign A moves from absent to 800, 950, and 1,000. Only <code>+I 1,000</code> is emitted, prompting a pause. The next window, <code>[10:00:10, 10:00:20)</code>, emits <code>-U 1,000</code> and <code>+U 970</code>, prompting resumption. Consolidation reduces messages during periods of frequent billing. Use <code>DETAIL</code> when every recorded transition is needed for reconciliation or spend curves.</p>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="use-table-stream-when-raw-and-result-retention-differ">Use Table Stream when raw and result retention differ<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#use-table-stream-when-raw-and-result-retention-differ" class="hash-link" aria-label="Direct link to Use Table Stream when raw and result retention differ" title="Direct link to Use Table Stream when raw and result retention differ">&#x200B;</a></h4>
<p>Large billing ledgers may retain only a few days of detail. A materialized view, however, represents a query over its retained base data: removing base data cannot also preserve an independent lifetime total without changing that meaning.</p>
<p><strong>Table Stream plus a scheduled job separates raw-data retention from cumulative results.</strong> The stream reads newly arrived billing entries. A job groups each batch by campaign and adds its delta to a result table with Changelog enabled.</p>
<p><img decoding="async" loading="lazy" alt="An append-only Table Stream and a minute-by-minute job accumulate campaign spend independently of three-day raw billing retention, committing results and offsets atomically" src="https://assets-cdn.selectdb.com/site/assets/shared/64a6dc3c4cca4631c3abc3f997f949be.jpg" width="1200" height="630" class="img_ev3q"></p>
<p><em>Figure 10. Raw entries can expire while the cumulative result remains. Retrying a failed stream-consuming write does not add the same batch twice.</em></p>
<p>In this alternative, the billing table can use daily partitions with three-day retention. The <code>click_billing</code> DDL above leaves that production partition policy to the deployment. Create the result table, stream, and <a href="https://doris.apache.org/docs/dev/admin-manual/workload-management/job-scheduler/">scheduled job</a> in the <code>ads</code> database:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">USE</span><span class="token plain"> ads</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">TABLE</span><span class="token plain"> campaign_spend </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    campaign_id </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BIGINT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    spend       </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DECIMAL</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">38</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">2</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">UNIQUE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">KEY</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">campaign_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DISTRIBUTED</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">HASH</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">campaign_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> BUCKETS </span><span class="token number" style="color:hsl(35, 99%, 36%)">16</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">PROPERTIES </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;enable_unique_key_merge_on_write&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;changelog.enable&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;changelog.need_historical_value&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- Consume only entries arriving after this stream is created.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> STREAM click_billing_stream </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ON</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">TABLE</span><span class="token plain"> click_billing</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">PROPERTIES </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;type&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;append_only&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;show_initial_rows&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;false&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> JOB campaign_spend_job</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ON</span><span class="token plain"> SCHEDULE EVERY </span><span class="token number" style="color:hsl(35, 99%, 36%)">1</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">MINUTE</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DO</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INSERT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INTO</span><span class="token plain"> ads</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">campaign_spend</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> d</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">campaign_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">COALESCE</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">s</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">spend</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">0</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">+</span><span class="token plain"> d</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">delta</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> campaign_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token function" style="color:hsl(221, 87%, 60%)">SUM</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">amount</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> delta</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> ads</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">click_billing_stream</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">GROUP</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> campaign_id</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> d</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">LEFT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">JOIN</span><span class="token plain"> ads</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">campaign_spend s </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ON</span><span class="token plain"> s</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">campaign_id </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> d</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">campaign_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>Each execution commits the result and stream position together. Failure rolls both back, so retrying does not double-count the batch. The result table&apos;s Changelog contains cumulative spend changes. Because <code>show_initial_rows</code> is <code>false</code>, this example starts accumulation only from new arrivals; any pre-existing billing data needs a separately coordinated baseline.</p>
<p>Both approaches expose a result Changelog that Flink Doris Connector can deliver to the serving system using the pattern in Section 2.1.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="32-merge-out-of-order-product-streams-and-suppress-irrelevant-changes">3.2 Merge out-of-order product streams and suppress irrelevant changes<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#32-merge-out-of-order-product-streams-and-suppress-irrelevant-changes" class="hash-link" aria-label="Direct link to 3.2 Merge out-of-order product streams and suppress irrelevant changes" title="Direct link to 3.2 Merge out-of-order product streams and suppress irrelevant changes">&#x200B;</a></h3>
<p>An e-commerce platform writes products to Doris through two pipelines. Real-time CDC captures operational database changes. A daily reconciliation pipeline reloads a full snapshot to repair potential gaps. Doris then synchronizes prices to a search engine, which needs price changes and product deletes.</p>
<p><img decoding="async" loading="lazy" alt="A sequence column resolves out-of-order product arrivals, while a price-only materialized view and MIN_DELTA remove version-only changes before search synchronization" src="https://assets-cdn.selectdb.com/site/assets/shared/2ac26baa055b6a68af1d1f19f655dbeb.jpg" width="1200" height="630" class="img_ev3q"></p>
<p><em>Figure 11. Keep version information in the base table for correctness, then exclude it from the downstream result before computing net changes.</em></p>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="use-a-sequence-column-to-handle-arrival-order">Use a sequence column to handle arrival order<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#use-a-sequence-column-to-handle-arrival-order" class="hash-link" aria-label="Direct link to Use a sequence column to handle arrival order" title="Direct link to Use a sequence column to handle arrival order">&#x200B;</a></h4>
<p>Events from the two pipelines can arrive out of order. The product table maps <code>ver</code> to a <a href="https://doris.apache.org/docs/dev/data-operate/update/unique-update-concurrent-control/">sequence column</a>. For the same key, the higher version wins regardless of arrival order; late lower-version writes are discarded.</p>
<p>In this scenario, the real-time pipeline derives <code>ver</code> from the source change&apos;s event time, while reconciliation uses the snapshot time. Both pipelines must use a comparable version convention.</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DATABASE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">IF</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">NOT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">EXISTS</span><span class="token plain"> shop</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">USE</span><span class="token plain"> shop</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">TABLE</span><span class="token plain"> product </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    product_id </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BIGINT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    price      </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DECIMAL</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">10</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">2</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    ver        </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BIGINT</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">UNIQUE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">KEY</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">product_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DISTRIBUTED</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">HASH</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">product_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> BUCKETS </span><span class="token number" style="color:hsl(35, 99%, 36%)">16</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">PROPERTIES </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;enable_unique_key_merge_on_write&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;function_column.sequence_col&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;ver&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;changelog.enable&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;changelog.need_historical_value&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>Suppose a product originally costs CNY 99 at version 100, drops to CNY 89 at version 150, and returns to CNY 99 at version 200. The version-150 event arrives last:</p>

























<table><thead><tr><th>Arrival</th><th>Incoming row</th><th>Stored result</th></tr></thead><tbody><tr><td>1</td><td>CNY 99, ver = 100</td><td>CNY 99, ver = 100</td></tr><tr><td>2</td><td>CNY 99, ver = 200</td><td>CNY 99, ver = 200</td></tr><tr><td>3</td><td>CNY 89, ver = 150</td><td>Discarded; CNY 99, ver = 200 remains</td></tr></tbody></table>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="keep-version-only-writes-in-the-base-table">Keep version-only writes in the base table<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#keep-version-only-writes-in-the-base-table" class="hash-link" aria-label="Direct link to Keep version-only writes in the base table" title="Direct link to Keep version-only writes in the base table">&#x200B;</a></h4>
<p>Daily reconciliation rewrites products with a newer <code>ver</code> even when prices stay unchanged. Forwarding all those updates would cause unnecessary index writes.</p>
<p>They cannot simply be discarded at ingestion. Arrival 2 above changes only <code>ver</code>. If it were discarded because the price stayed at 99, the stored version would remain 100. The late version-150 event would then incorrectly replace the price with 89.</p>
<p>Reading the base table with <code>MIN_DELTA</code> also cannot remove version-only changes: it compares the whole row, including <code>ver</code>.</p>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="project-the-required-columns-then-read-min_delta">Project the required columns, then read MIN_DELTA<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#project-the-required-columns-then-read-min_delta" class="hash-link" aria-label="Direct link to Project the required columns, then read MIN_DELTA" title="Direct link to Project the required columns, then read MIN_DELTA">&#x200B;</a></h4>
<p>Create an incremental materialized view containing only product ID and price, with its own Changelog and before images. When only <code>ver</code> changes, the view&apos;s before and after rows are identical, so <code>MIN_DELTA</code> suppresses the update.</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> MATERIALIZED </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VIEW</span><span class="token plain"> product_price_mv</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">BUILD IMMEDIATE REFRESH INCREMENTAL </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ON</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">COMMIT</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">KEY</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">product_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DISTRIBUTED</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">HASH</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">product_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> BUCKETS </span><span class="token number" style="color:hsl(35, 99%, 36%)">16</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">PROPERTIES </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;changelog.enable&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;changelog.need_historical_value&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> product_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> price </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> product</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- Illustrative ten-second window after the relevant refreshes complete.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> __DORIS_CHANGELOG_OP__ </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> op</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> product_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> price</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> product_price_mv</span><span class="token variable" style="color:hsl(221, 87%, 60%)">@incr</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;startTimestamp&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;2026-11-11 10:00:00&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;endTimestamp&apos;</span><span class="token plain">   </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;2026-11-11 10:00:10&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;incrementType&apos;</span><span class="token plain">  </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;MIN_DELTA&apos;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>Assuming the product already exists at the start, each window has the following effects:</p>






























<table><thead><tr><th>Changes within the window</th><th>MIN_DELTA output</th><th>Search engine action</th></tr></thead><tbody><tr><td>Reconciliation changes only <code>ver</code></td><td>None</td><td>None</td></tr><tr><td>Price falls from CNY 99 to CNY 89</td><td>-U 99, +U 89</td><td>Set price to CNY 89</td></tr><tr><td>Price falls to CNY 89 and returns to CNY 99</td><td>None</td><td>None</td></tr><tr><td>Product is deleted at price CNY 99</td><td>-D 99</td><td>Remove the product</td></tr></tbody></table>
<p>Flink Doris Connector can read the view&apos;s Changelog and deliver these meaningful result changes downstream.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="what-comes-next">What comes next<a href="https://doris.apache.org/blog/apache-doris-5-cdc-changelog/#what-comes-next" class="hash-link" aria-label="Direct link to What comes next" title="Direct link to What comes next">&#x200B;</a></h2>
<p>Changelog extends Doris&apos;s role in a real-time pipeline: Doris can ingest data, compute results, and continuously expose changes to those results. IVM and Table Stream prepare changes inside the database; Flink Doris Connector carries them to other systems.</p>
<p>The next article will examine IVM internals and incremental execution plan generation. Changelog is planned for Apache Doris 5.0; consult the documentation and release announcements for availability.</p></div>]]></content:encoded>
            <category>Tech Sharing</category>
        </item>
        <item>
            <title><![CDATA[Doris Summit 2026 Recap: From Real-Time Analytics to Real-Time Intelligence]]></title>
            <link>https://doris.apache.org/blog/doris-summit-2026-recap/</link>
            <guid>https://doris.apache.org/blog/doris-summit-2026-recap/</guid>
            <pubDate>Wed, 11 Nov 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[Doris Summit 2026 recap: Apache Doris 5.0, fresh data, multimodal analytics, AI agents, and production stories from HubSpot, Sony, and Raiffeisen Bank Romania.]]></description>
            <content:encoded><![CDATA[<header><div class="text-center mb-4"><a class="cursor-pointer hover:no-underline" lang="en" href="https://doris.apache.org/blog/">Blog</a><span class="px-2 text-[#8592A6]">/</span><span><span class="s-tags" lang="en"><span class="s-tag">Top News</span></span></span></div><h1 lang="en" class="blog-post-title text-[2rem] leading-normal lg:!text-[2.5rem] text-center" itemprop="headline">Doris Summit 2026 Recap: From Real-Time Analytics to Real-Time Intelligence</h1><div class="blog-info text-center flex justify-center text-sm text-black"><span class="authors"><span class="s-author text-black">Apache Doris &#xB7; Mingyu Chen</span></span><time datetime="2026-11-11T00:00:00.000Z" itemprop="datePublished" class="text-black ml-4">November 11, 2026</time></div></header><div id="__blog-post-container" class="markdown" itemprop="articleBody"><figure class="doris-youtube"><div class="doris-youtube__frame"><button type="button" class="doris-youtube__preview" aria-label="Play video: Apache Doris Summit 2026 Recap"><img class="doris-youtube__poster" src="https://doris.apache.org/images/blogs/doris-summit-2026-recap/video-poster.jpg" alt width="1920" height="1080" loading="lazy" decoding="async"><span class="doris-youtube__play" aria-hidden="true"><svg width="28" height="28" viewBox="0 0 24 24" fill="currentColor"><path d="M8 5v14l11-7z"/></svg></span></button></div><figcaption class="doris-youtube__caption"><span>Apache Doris Summit 2026 Recap</span><a href="https://www.youtube.com/watch?v=CTsaY5ISK6g" target="_blank" rel="noopener noreferrer">Watch on YouTube<!-- --> <span aria-hidden="true">&#x2197;</span></a></figcaption></figure>
<blockquote>
<p>Apache Doris, an Apache Software Foundation project, is an open-source database for real-time analytics and search. Teams commonly use it for real-time reporting, log analytics, lakehouse queries, and serving data to AI agents. Doris Summit is the Apache Doris community&apos;s global technical conference, where users, contributors, and partners share how they run Doris in production and where the technology is going.</p>
</blockquote>
<p><em>How Apache Doris is moving from real-time analytics to real-time intelligence: the keynotes mapped out the path, and production stories from HubSpot, Sony Interactive Entertainment, Raiffeisen Bank Romania, and other teams made it concrete.</em></p>
<p>At HubSpot, Apache Doris powers CRM object analytical queries across 33 clusters worldwide, and <strong>P50 backend query latency has dropped from about 1.8 seconds to about 500 milliseconds</strong>. At Raiffeisen Bank Romania, <strong>AI agents are already real users of the analytics platform</strong>: they query Doris through MCP tools, read governed model scores, and then explain risks and recommend next steps to bank employees. The first example is real-time analytics as it works today. The second points to what is changing: agents have joined the people reading reports as consumers of data, and they ask questions often and at any hour. That shift came up again and again at this year&apos;s Doris Summit. <strong>Agents need up-to-date data, the right business definitions, and answers that can be traced back to their source.</strong></p>
<p>Doris Summit 2026 took place online on October 21&#x2013;22, with 34 speakers presenting 31 sessions. The opening keynote started with exactly this shift. Apache Doris PMC Chair Mingyu Chen described it as a move <a href="https://apache-doris-summit.org/watch/real-time-intelligence" target="_blank" rel="noopener noreferrer">from real-time analytics to real-time intelligence</a>. Real-time analytics helps people see what is happening, faster. Real-time intelligence goes further: it lets AI continuously access fresh data, understand multimodal context, and make decisions based on the latest state of the business. <strong>The question is no longer just how fast we can analyze data, but how fast data can turn into intelligence.</strong></p>
<p>That theme ran through the entire summit. The other five keynotes built on it, covering how Apache Doris 5.0 keeps results fresh, how it goes beyond tables, and how agents understand, access, and verify data. The remaining 25 sessions showed what these directions look like in practice. They came from teams in CRM, gaming, retail, telecom, banking, insurance, mobility, and online video, as well as ecosystem partners working on stream processing, lakehouses, semantic layers, and graph analytics.</p>
<p><strong>Recordings of all 31 sessions are free to watch on the <a href="https://apache-doris-summit.org/watch" target="_blank" rel="noopener noreferrer">Doris Summit 2026 website</a>.</strong></p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="staying-fresh-results-that-keep-pace-with-the-business">Staying Fresh: Results That Keep Pace with the Business<a href="https://doris.apache.org/blog/doris-summit-2026-recap/#staying-fresh-results-that-keep-pace-with-the-business" class="hash-link" aria-label="Direct link to Staying Fresh: Results That Keep Pace with the Business" title="Direct link to Staying Fresh: Results That Keep Pace with the Business">&#x200B;</a></h2>
<p><img decoding="async" loading="lazy" alt="Two panels compare batch refresh and incremental processing. Batch refresh runs a full recompute at intervals, so results lag behind the business; incremental processing handles only the changes, so results keep pace." src="https://assets-cdn.selectdb.com/site/assets/shared/f10b0d407d82c4167db5e27fb37886c8.jpg" width="1600" height="900" class="img_ev3q"></p>
<p>Agents need more than fresh source data. They also need metrics and analytical results that keep up as the business changes. In the <a href="https://apache-doris-summit.org/watch/incremental-computing" target="_blank" rel="noopener noreferrer">incremental computing keynote</a>, VeloDB Solutions Architect Shilin Wu pointed out that maintaining these results through repeated batch refreshes introduces delays and costly recomputation. The upcoming Apache Doris 5.0 addresses this by <strong>processing only what changes</strong>. Changelog and Table Stream capture and consume changes, Flink-based pipelines handle downstream processing, and <strong>incremental view maintenance (IVM)</strong> automatically keeps analytical results up to date inside Doris. The talk demonstrated inserts, updates, and deletes flowing through to correctly updated results, and measured end-to-end latency. <a href="https://apache-doris-summit.org/watch/query-cache" target="_blank" rel="noopener noreferrer">Query Cache</a>, presented by Apache Druid PMC Member Jiayi Jin, applies the same idea: moving from full recomputation to incremental reuse.</p>
<p>User talks showed what fresh results mean in production. At Silpo, part of the Ukrainian retail group Fozzy Group, each pricing run recomputes about 15 million price cells across roughly 1,500 stores. Data Platform Lead Vitalii Kalmykov explained that the original calculation, built on SQL Server stored procedures, took about 10 minutes. With <a href="https://apache-doris-summit.org/watch/unified-data-platform" target="_blank" rel="noopener noreferrer">Doris running the calculation</a> and Temporal orchestrating it, <strong>each run now takes about 75 seconds</strong>; across 286 runs, the average was 74 seconds, with zero failures. The same Doris cluster also handles CDC ingestion, API serving, and data catalog search.</p>
<p>Rumble lets the teams that use the data build their own processing chains. In <a href="https://apache-doris-summit.org/watch/trusted-data-products" target="_blank" rel="noopener noreferrer"><em>Growing a Data Tree</em></a>, Jayson Minard described how Rumble&apos;s recommendations team moved from a centralized ClickHouse warehouse to Doris in compute-storage decoupled mode. The platform provides trusted base tables, and each team builds its own views and materialized views on top. It handles <strong>about 10 billion events a month with 91 materialized views</strong>; the longest processing chain is about 13 layers deep, and core views are ready within about 18 minutes.</p>
<p>Ishan Harkhani and Parmeetrai Lalwani of Armakuni built a <a href="https://apache-doris-summit.org/watch/multi-tenant-platform" target="_blank" rel="noopener noreferrer">multi-tenant marketing attribution platform</a> for home services businesses, running all three transformation layers (Bronze, Silver, and Gold) inside Doris. According to the speakers, <strong>processing time dropped from hours to minutes</strong>, and customer dashboards now refresh every 10 minutes. GreenSM, a Vietnamese EV ride-hailing platform, computes its recommendations ahead of time. Thang Duc Bui said its <a href="https://apache-doris-summit.org/watch/real-time-recommendations" target="_blank" rel="noopener noreferrer">destination recommendation</a> system <strong>writes more than 1 million records per second in production and serves queries in under 100 milliseconds</strong>.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="beyond-tables-agent-context-doesnt-always-fit-in-a-table">Beyond Tables: Agent Context Doesn&apos;t Always Fit in a Table<a href="https://doris.apache.org/blog/doris-summit-2026-recap/#beyond-tables-agent-context-doesnt-always-fit-in-a-table" class="hash-link" aria-label="Direct link to Beyond Tables: Agent Context Doesn&apos;t Always Fit in a Table" title="Direct link to Beyond Tables: Agent Context Doesn&apos;t Always Fit in a Table">&#x200B;</a></h2>
<p><img decoding="async" loading="lazy" alt="Tables, custom attributes, logs and text, vectors and images, and live events all flow into Apache Doris, which passes the combined context to an agent." src="https://assets-cdn.selectdb.com/site/assets/shared/14532850056add0a6957fcbafdc586a3.jpg" width="1600" height="900" class="img_ev3q"></p>
<p>The context that agents rely on often doesn&apos;t sit in neat tables. It includes customer-defined attributes, logs and text, vectors and images, and the latest events still in the stream. In the <a href="https://apache-doris-summit.org/watch/multimodal-lakehouse" target="_blank" rel="noopener noreferrer">multimodal lakehouse keynote</a>, Mingyu Chen and Lei Xu, co-founder and CTO of LanceDB, showed how <strong>Apache Doris 5.0 extends the lakehouse to multimodal analytics and retrieval</strong>. They started with how Kuaishou, the Chinese short-video platform, uses Doris with Apache Paimon, then explained how the Lance format, vector retrieval, and analytical engines work together so <strong>the same open data can serve search, analytics, retrieval, and AI</strong>.</p>
<p>CRM data at <a href="https://apache-doris-summit.org/watch/hubspot" target="_blank" rel="noopener noreferrer">HubSpot</a> is far from a neat table. Customers can define their own objects and properties, some tenants have thousands of properties, about 90% of write traffic is updates, and queries range from search to analytics that join across objects. Staff Software Engineer Alvaro Tuso explained how HubSpot <strong>maps arbitrary properties to typed VARIANT subpaths with inverted indexes</strong>, uses Merge-on-Write to absorb frequent updates, and splits the deployment into many smaller clusters, each serving a group of customers. This design now powers object reporting on 33 clusters worldwide; search is still being tuned.</p>
<p>Fresh events and historical data also need to be queried together. Apache Fluss PMC Member Anton Borisov showed how Doris, through the Fluss Catalog, can query historical data in Apache Paimon and real-time data in Fluss that hasn&apos;t been tiered into the lake yet, <a href="https://apache-doris-summit.org/watch/fluss-streaming-lakehouse" target="_blank" rel="noopener noreferrer"><strong>all in a single SQL statement</strong></a>. <strong>This integration is coming in Apache Doris 5.0.</strong> The talk also covered prototypes that improve scan and point-lookup performance. Fahad Shah of RisingWave told the story behind <a href="https://apache-doris-summit.org/watch/iceberg-rust" target="_blank" rel="noopener noreferrer">iceberg-rust</a> and demonstrated RisingWave writing to Iceberg tables that Doris then queried.</p>
<p>Search can live in the same database, too. Daniel Adayev of Tabsdata used Doris inverted indexes to <a href="https://apache-doris-summit.org/watch/tabsdata-event-search" target="_blank" rel="noopener noreferrer">handle event search and analytics together</a>, with <strong>no separate Elasticsearch cluster to maintain</strong>. &#xC1;kos Zalav&#xE1;ry, founder of Logiqum, used 73 million rows of real logs to compare <a href="https://apache-doris-summit.org/watch/append-only-logging" target="_blank" rel="noopener noreferrer">several append-only logging designs</a>. The final design keeps the logs themselves immutable and stores the mutable noise-filtering decisions separately.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="between-agents-and-data-understand-access-verify">Between Agents and Data: Understand, Access, Verify<a href="https://doris.apache.org/blog/doris-summit-2026-recap/#between-agents-and-data-understand-access-verify" class="hash-link" aria-label="Direct link to Between Agents and Data: Understand, Access, Verify" title="Direct link to Between Agents and Data: Understand, Access, Verify">&#x200B;</a></h2>
<p><img decoding="async" loading="lazy" alt="An agent&amp;#39;s question goes through Understand (the business) and Access (the data) to reach Apache Doris, and the answer returns to the agent through Verify (the results)." src="https://assets-cdn.selectdb.com/site/assets/shared/1374ac3a3815a49debb0d93220b15e0a.jpg" width="1600" height="900" class="img_ev3q"></p>
<p>Once the data is fresh and complete, agents still have to use it well. Three keynotes each took on one part of the problem: how agents understand the business, how they access the data, and how to tell whether they got it right.</p>
<p><strong>Understanding the business.</strong> In <a href="https://apache-doris-summit.org/watch/talk-to-your-data" target="_blank" rel="noopener noreferrer"><em>Talk to Your Data</em></a>, VeloDB Co-founder Owen Xiao described a three-layer architecture for enterprise analytics agents. The agent layer handles conversation, planning, and SQL execution, with support for multi-user collaboration, permissions, and auditing. <strong>The context layer records schemas, metric definitions, and business rules in Markdown files</strong> (for example, whether &quot;revenue&quot; means MRR or ARR); the files can be managed in Git and served to agents through MCP or APIs. The analytical database absorbs the bursty, highly concurrent queries that agents generate. Capy, the enterprise analytics agent presented in the talk, is expected to launch by the end of the year.</p>
<p>Raiffeisen Bank Romania lets <strong>models produce the numbers and LLMs explain them</strong>, hence the talk&apos;s title: <a href="https://apache-doris-summit.org/watch/raiffeisen" target="_blank" rel="noopener noreferrer"><em>ML Decides, LLMs Explain</em></a>. Models for churn, default, fraud, and more are trained and governed separately, and each writes its scores and drivers into Doris. ARIA, the bank&apos;s agentic AI platform, reads those results through MCP-based tools, uses OpenMetadata as its semantic layer, and explains them to employees. Alin Nedelcu and Adrian Neagu said risk analysts can ask questions in natural language and <strong>typically get back a chart and a CSV download link in under 2 seconds</strong>.</p>
<p>Other talks approached understanding from different angles. Azhar Izzannada Elbachtiar&apos;s <a href="https://apache-doris-summit.org/watch/metricflow-on-doris" target="_blank" rel="noopener noreferrer">reference implementation</a> uses MetricFlow to compile governed metrics into Doris SQL and returns an answer only when both freshness and provenance checks pass. It was validated on billion-scale event data. DatusAI Co-founder Harrison Zhao presented an <a href="https://apache-doris-summit.org/watch/open-semantic-layer" target="_blank" rel="noopener noreferrer">open semantic layer</a> for data agents. PuppyGraph CEO Weimo Liu demonstrated an agent that generates an <a href="https://apache-doris-summit.org/watch/ontology-graph" target="_blank" rel="noopener noreferrer">ontology graph</a> from thousands of tables and then queries the data in Doris directly as a graph. Dave Stokes of DBeaver warned that an agent&apos;s first answer can look plausible and still be wrong, and laid out <a href="https://apache-doris-summit.org/watch/teach-your-ai" target="_blank" rel="noopener noreferrer">what to teach your AI</a> and which guardrails to set up in Doris.</p>
<p><strong>Accessing the data.</strong> Getting results out of the database and into the agent&apos;s hands can also become a bottleneck. In <a href="https://apache-doris-summit.org/watch/agentic-data-plane" target="_blank" rel="noopener noreferrer"><em>The Agentic Data Plane</em></a>, Kevin Shen, a product manager at VeloDB, and Ian Cook, co-founder and CEO of Columnar, pointed out that row-by-row conversion and lost type information slow the whole pipeline down. They split connectivity into two planes. Tools such as MCP and CLIs form the <strong>control plane</strong>, which decides what to query. Arrow and ADBC form the <strong>data plane</strong>, which moves results in columnar batches and preserves data types. Doris already offers an Arrow Flight SQL service, and the Doris ADBC driver and ADBC Catalog are expected by the end of the year.</p>
<p>Agents also query differently from traditional analytics workloads. Ganesh Kumar noted that <strong>agents send large numbers of highly concurrent, narrow queries, often with latency budgets under 500 milliseconds</strong>. The talk compared Amazon Athena, Amazon Redshift Serverless, and Doris, then proposed a reference architecture with <a href="https://apache-doris-summit.org/watch/agent-data-layer" target="_blank" rel="noopener noreferrer">Doris as the hot data serving layer</a>. Sijie Han of AWS demonstrated Amazon Quick agents <a href="https://apache-doris-summit.org/watch/conversation-to-insight" target="_blank" rel="noopener noreferrer">querying Doris through MCP</a> and generating visualizations.</p>
<p>Because a single agent often acts on behalf of many users, Arpit Jain of MIT built a <a href="https://apache-doris-summit.org/watch/custom-access-controller" target="_blank" rel="noopener noreferrer">custom access controller</a> on the AccessControllerFactory SPI in Doris, with OpenFGA as the policy engine. It authorizes each user individually and fails closed when the policy service is unavailable.</p>
<p><strong>Verifying the results.</strong> In <a href="https://apache-doris-summit.org/watch/observe-the-agent" target="_blank" rel="noopener noreferrer"><em>Observe the Agent</em></a>, Apache Doris Committer Jack Jiang reminded the audience that <strong>an agent can run without a single error and still give the wrong answer</strong>. The talk introduced <a href="https://litefuse.ai/" target="_blank" rel="noopener noreferrer">Litefuse</a>, an agent observability and evaluation platform that is now available. Litefuse is OpenTelemetry-native, compatible with the Langfuse SDK, and built on Apache Doris. Jack Jiang argued that <strong>agent observability is fundamentally a real-time analytics problem</strong>. Long-text search across massive volumes of traces, filtering on nested JSON, and cost aggregation all rely on inverted indexes, VARIANT, and compute-storage separation, the same capabilities that HubSpot and other users already run in production.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="into-production-a-foundation-that-stands-up-to-real-workloads">Into Production: A Foundation That Stands Up to Real Workloads<a href="https://doris.apache.org/blog/doris-summit-2026-recap/#into-production-a-foundation-that-stands-up-to-real-workloads" class="hash-link" aria-label="Direct link to Into Production: A Foundation That Stands Up to Real Workloads" title="Direct link to Into Production: A Foundation That Stands Up to Real Workloads">&#x200B;</a></h2>
<p><img decoding="async" loading="lazy" alt="Many data streams flow into an Ingest workload while a separate Query workload serves dashboards and agents; both stand side by side on an Apache Doris foundation." src="https://assets-cdn.selectdb.com/site/assets/shared/654f2c1f62c0cbea2568009780ba4f50.jpg" width="1600" height="900" class="img_ev3q"></p>
<p>The opening keynote named <strong>production-ready infrastructure</strong> as one of the core themes of Apache Doris 5.0. Real-time intelligence ultimately has to run on production systems, and production is where the user talks offered the most evidence.</p>
<p>At Sony Interactive Entertainment, Staff Software Engineer Derek Bradley is responsible for analyzing IPFIX traffic at the edge of PlayStation&apos;s global network. The previous in-memory database slowed down on writes and timed out on queries during anomalies such as DDoS attacks, which is exactly when network experts need the data most. The new design had to handle ingestion, cleanup, aggregation, and queries at the same time on limited hardware (some edge sites have only a single server). In <a href="https://apache-doris-summit.org/watch/million-rows-per-second" target="_blank" rel="noopener noreferrer">evaluation tests</a>, <strong>a single Doris node ingested wide rows of more than 60 columns at 1.4 million rows per second</strong>.</p>
<p>Malawian telecom operator TNM handles about 1.1 billion records a day. James Mandiza walked through the company&apos;s <a href="https://apache-doris-summit.org/watch/telecom-lakehouse" target="_blank" rel="noopener noreferrer">migration from an Oracle data warehouse to Doris</a>. TNM deployed Doris 3.1 in compute-storage decoupled mode on a private cloud, kept its existing Qlik reports, ran the old and new systems side by side for about a month to reconcile results one business domain at a time, and built a single unified subscriber profile that serves multiple business systems. In sample production jobs, <strong>ingestion dropped from 50 minutes to 4 minutes, and one query went from 637 seconds to 4 seconds</strong>. The talk also shared a lesson learned: before user queries were isolated, they slowed down Routine Load, so <strong>the two workloads now run on separate compute groups</strong>.</p>
<p>Turkish insurer HDI Sigorta took a different path. Kaz&#x131;m Cesur explained that Oracle 19c still handles core transactions, while data flows through GoldenGate CDC and Kafka into VeloDB, built on Apache Doris, for <a href="https://apache-doris-summit.org/watch/ai-ready-data-foundation" target="_blank" rel="noopener noreferrer">real-time analytics</a>. <strong>More than 450 Routine Load jobs run in production</strong>, and AI applications are the next step for this foundation.</p>
<p>Lessons from operations and ingestion matter just as much. Nilanjan Sarkar of Tesco shared practices for <a href="https://apache-doris-summit.org/watch/decoupled-mode-on-aks" target="_blank" rel="noopener noreferrer">running Doris in decoupled mode</a> on Azure Kubernetes Service, covering node pool isolation, historical data migration, and metadata backup and recovery. Shekhar Rajak of Atlassian explained how <a href="https://apache-doris-summit.org/watch/exactly-once-ingestion" target="_blank" rel="noopener noreferrer">exactly-once ingestion</a> works across three paths: Routine Load, Flink, and Spark. Kaiming Wan of AutoMQ introduced a streaming platform that <a href="https://apache-doris-summit.org/watch/automq" target="_blank" rel="noopener noreferrer">moves Kafka&apos;s storage layer onto object storage</a>, and EMQ CTO Ivan Dyachkov presented the integration that lets <a href="https://apache-doris-summit.org/watch/emqx" target="_blank" rel="noopener noreferrer">EMQX batch-write MQTT device messages into Doris</a>.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="whats-next">What&apos;s Next<a href="https://doris.apache.org/blog/doris-summit-2026-recap/#whats-next" class="hash-link" aria-label="Direct link to What&apos;s Next" title="Direct link to What&apos;s Next">&#x200B;</a></h2>
<p><strong>Apache Doris 5.0 is coming soon.</strong> Over the next few weeks, we&apos;ll publish deep dives on topics including HubSpot, Apache Fluss, incremental computing, Sony Interactive Entertainment, Silpo, and Raiffeisen Bank Romania.</p>
<p>Get involved with the community:</p>
<ul>
<li>Website: <a href="https://doris.apache.org/">https://doris.apache.org</a></li>
<li>Contribute: <a href="https://doris.apache.org/community/how-to-contribute/contribute-to-doris/">https://doris.apache.org/community/how-to-contribute/contribute-to-doris</a></li>
<li>GitHub: <a href="https://github.com/apache/doris" target="_blank" rel="noopener noreferrer">github.com/apache/doris</a></li>
<li>Slack: <a href="https://doris.apache.org/slack/">doris.apache.org/slack</a></li>
</ul>
<p>Thanks to all 34 speakers and 27 community partners. Doris Summit 2026 was organized by VeloDB, with the Apache Software Foundation as Community Partner.</p>
<p><strong>Watch every session on demand at <a href="https://apache-doris-summit.org/watch" target="_blank" rel="noopener noreferrer">apache-doris-summit.org/watch</a>. Slides will be posted on the website as speakers approve them.</strong></p></div>]]></content:encoded>
            <category>Top News</category>
        </item>
        <item>
            <title><![CDATA[How JD.com Uses Apache Doris for Millions of Daily Lakehouse Queries and PB-Scale Scans]]></title>
            <link>https://doris.apache.org/blog/jd-apache-doris-lakehouse-query-optimization/</link>
            <guid>https://doris.apache.org/blog/jd-apache-doris-lakehouse-query-optimization/</guid>
            <pubDate>Tue, 10 Nov 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[How JD.com builds a unified Apache Doris lakehouse query engine for millions of daily queries and petabyte-scale scans, with push-based scheduling, partition pruning, and vectorized execution.]]></description>
            <content:encoded><![CDATA[<header><div class="text-center mb-4"><a class="cursor-pointer hover:no-underline" lang="en" href="https://doris.apache.org/blog/">Blog</a><span class="px-2 text-[#8592A6]">/</span><span><span class="s-tags" lang="en"><span class="s-tag">Best Practice</span></span></span></div><h1 lang="en" class="blog-post-title text-[2rem] leading-normal lg:!text-[2.5rem] text-center" itemprop="headline">How JD.com Uses Apache Doris for Millions of Daily Lakehouse Queries and PB-Scale Scans</h1><div class="blog-info text-center flex justify-center text-sm text-black"><span class="authors"><span class="s-author text-black">JD.com &#xB7; Conghui Cai</span></span><time datetime="2026-11-10T00:00:00.000Z" itemprop="datePublished" class="text-black ml-4">November 10, 2026</time></div></header><div id="__blog-post-container" class="markdown" itemprop="articleBody"><div class="theme-admonition theme-admonition-tip admonition_Gfwi alert alert--success"><div class="admonitionHeading_f1Ed">tip</div><div class="admonitionContent_UjKb"><p>Adapted from Conghui Cai&apos;s presentation at Doris Summit 2026. Cai is the OLAP Engine Tech Lead at JD Retail and an Apache Doris PMC member. The <a href="https://selectdb.com/blog/jd-apache-doris-lakehouse-query-optimization" target="_blank" rel="noopener noreferrer">original article</a> was published on November 10, 2026. The optimizations below describe JD.com&apos;s production implementation.</p></div></div>
<p>Growing business analytics demand and new AI agent queries have made JD.com&apos;s lakehouse workloads more varied. Running several query engines in parallel added architectural complexity, made resource scheduling harder, and complicated unified governance.</p>
<p>JD.com is gradually moving workloads from Presto, StarRocks, and other analytical engines to Apache Doris. Using Doris&apos;s Multi-Catalog capabilities, Nereids optimizer, and vectorized execution engine, the team has optimized the path from query scheduling and partition pruning to file scanning and execution resource management.</p>
<p>The unified engine now handles <strong>millions of queries and petabyte-scale data scans each day</strong>. AI agent queries account for approximately <strong>20% of queries</strong>, alongside BI reports and data quality tasks.</p>
<p>This article explains how JD.com&apos;s architecture evolved and how the team adapted Doris to large-scale lakehouse queries and mixed workloads.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="1-from-multiple-engines-to-a-unified-lakehouse">1. From multiple engines to a unified lakehouse<a href="https://doris.apache.org/blog/jd-apache-doris-lakehouse-query-optimization/#1-from-multiple-engines-to-a-unified-lakehouse" class="hash-link" aria-label="Direct link to 1. From multiple engines to a unified lakehouse" title="Direct link to 1. From multiple engines to a unified lakehouse">&#x200B;</a></h2>
<p>JD.com adopted Apache Doris early in its open source history to support advertising reports, while Presto remained its main lakehouse query engine. The team later introduced StarRocks and other analytical engines. During 2024 and 2025, it began consolidating OLAP workloads by migrating Presto and StarRocks workloads to Doris. In 2026, it continued building a unified architecture around Doris to reduce complexity and support a broader range of analytical needs over time.</p>
<p><img decoding="async" loading="lazy" alt="JD.com&amp;#39;s lakehouse query architecture evolves from Presto in 2021 and StarRocks exploration in 2022 to migration during 2024&#x2013;2025 and a unified Doris architecture in 2026" src="https://assets-cdn.selectdb.com/site/assets/shared/3676fc454f1e87fd7c1b821f07004fc1.png" width="1800" height="850" class="img_ev3q"></p>
<p>Historically, lakehouse queries followed a daily pattern with two peaks. Morning traffic mainly came from business analysis and BI reports. Overnight, large numbers of data quality tasks ran complex SQL queries.</p>
<p>As AI agent queries grew to about 20% of the total, that pattern began changing into a <strong>continuous, 24/7 mixed workload</strong>. Interactive queries, batch scans, and agent requests have different latency, throughput, and isolation requirements. JD.com needed an engine that could access existing lake data efficiently while supporting complex planning and execution.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="2-building-the-unified-query-architecture">2. Building the unified query architecture<a href="https://doris.apache.org/blog/jd-apache-doris-lakehouse-query-optimization/#2-building-the-unified-query-architecture" class="hash-link" aria-label="Direct link to 2. Building the unified query architecture" title="Direct link to 2. Building the unified query architecture">&#x200B;</a></h2>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="why-apache-doris">Why Apache Doris<a href="https://doris.apache.org/blog/jd-apache-doris-lakehouse-query-optimization/#why-apache-doris" class="hash-link" aria-label="Direct link to Why Apache Doris" title="Direct link to Why Apache Doris">&#x200B;</a></h3>
<p>Three capabilities provided the foundation for JD.com&apos;s choice.</p>
<p><strong>Multi-Catalog access to lake data.</strong> Doris can query Hive, Iceberg, Hudi, Paimon, and other external sources through one engine. This lets JD.com consolidate compute while keeping its existing lakehouse storage, reducing migration and architectural changes. See the <a href="https://doris.apache.org/docs/dev/lakehouse/catalog-overview/">Catalog overview</a> for how Doris connects to external systems.</p>
<p><strong>Query optimization.</strong> Lakehouse SQL performance depends on partition pruning, statistics, join planning, and scan task generation as well as scan speed. Doris&apos;s <a href="https://doris.apache.org/docs/dev/query-acceleration/optimization-technology-principle/query-optimizer/">Nereids optimizer</a> provides rule-based, cost-based, and history-based optimization capabilities and a framework for JD.com&apos;s workload-specific improvements.</p>
<p><strong>Vectorized and distributed execution.</strong> Doris&apos;s backend execution engine supports scanning, filtering, aggregation, and distributed computation across several file formats. This provides a common execution foundation for BI, data quality, and agent workloads.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="four-layers-of-the-architecture">Four layers of the architecture<a href="https://doris.apache.org/blog/jd-apache-doris-lakehouse-query-optimization/#four-layers-of-the-architecture" class="hash-link" aria-label="Direct link to Four layers of the architecture" title="Direct link to Four layers of the architecture">&#x200B;</a></h3>
<p>JD.com&apos;s unified lakehouse architecture has four main layers:</p>
<ul>
<li><strong>Business access:</strong> BI reports, business analysis, data quality tasks, and AI agents submit concurrent interactive queries and large batch scans.</li>
<li><strong>Unified query entry point:</strong> SQL dialect compatibility, authentication, and access governance prepare requests for Doris. Compatibility conversion accommodates existing Presto SQL and Spark SQL within the supported scope.</li>
<li><strong>Doris compute engine:</strong> Frontends (FEs) handle query planning, metadata access, partition pruning, and task coordination. Backends (BEs) scan files, evaluate expressions, aggregate results, and exchange data.</li>
<li><strong>Lakehouse storage:</strong> JD.com retains its existing data organization and storage systems, including Hive, Hudi, ORC, and Parquet, with adapters for internal storage systems.</li>
</ul>
<p>Together, these layers support millions of daily queries, PB-scale daily scans, and increasingly continuous mixed workloads.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="3-optimizing-the-path-from-planning-to-execution">3. Optimizing the path from planning to execution<a href="https://doris.apache.org/blog/jd-apache-doris-lakehouse-query-optimization/#3-optimizing-the-path-from-planning-to-execution" class="hash-link" aria-label="Direct link to 3. Optimizing the path from planning to execution" title="Direct link to 3. Optimizing the path from planning to execution">&#x200B;</a></h2>
<p>At this scale, computation is only part of query latency. Metadata retrieval, partition pruning, file listing, scan task scheduling, and resource management can all become bottlenecks. JD.com&apos;s work addresses the preparation and execution of queries together.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="push-based-scheduling-reduces-scanner-wait-time">Push-based scheduling reduces scanner wait time<a href="https://doris.apache.org/blog/jd-apache-doris-lakehouse-query-optimization/#push-based-scheduling-reduces-scanner-wait-time" class="hash-link" aria-label="Direct link to Push-based scheduling reduces scanner wait time" title="Direct link to Push-based scheduling reduces scanner wait time">&#x200B;</a></h3>
<p>For large lakehouse scans, the FE continually creates and distributes scan splits. In the Doris implementation JD.com previously used, BEs pulled batches of tasks on demand. When a local batch ran out, scanner threads could block while waiting for the FE. Metadata latency fluctuations could therefore occupy scan resources without doing useful work.</p>
<p>The team changed the scheduling protocol between the FE Coordinator and BE Scanner to a <strong>push model</strong>. The FE asynchronously pushes splits, while the BE maintains a bounded queue. When no local task is ready, the scanner suspends and releases CPU resources. New tasks wake it again. Capacity and consumption feedback regulate the supply of work.</p>
<p><img decoding="async" loading="lazy" alt="Pull scheduling blocks a scanner while fetching another batch; push scheduling supplies splits asynchronously and uses queue capacity and consumption feedback" src="https://assets-cdn.selectdb.com/site/assets/shared/707e87341fdc62caf9b136048c8a11d3.png" width="1800" height="890" class="img_ev3q"></p>
<p>The change has three main benefits:</p>
<ol>
<li><strong>Release scanner resources while waiting.</strong> Suspending scanners reduces the resources occupied by metadata waits, especially during concurrent file listing or metadata latency fluctuations.</li>
<li><strong>Limit task accumulation.</strong> When queues lack capacity, backpressure pauses producers and limits split buffering during scans over many files and partitions.</li>
<li><strong>Account for different consumption rates.</strong> Scheduling considers BE queue and execution state, avoids full queues, and reduces imbalance and slow tails caused by different BE processing rates.</li>
</ol>
<p><img decoding="async" loading="lazy" alt="Comparison of pull and push scheduling across waiting behavior, buffer control, assignment feedback, and task replenishment" src="https://assets-cdn.selectdb.com/site/assets/shared/4604499de60226cc97db4ef3685c70d9.png" width="1800" height="1030" class="img_ev3q"></p>
<p>The practical lesson is to <strong>reduce the compute resources consumed by task preparation and waiting</strong>, alongside improving execution speed.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="earlier-partition-pruning-avoids-unnecessary-metadata-requests">Earlier partition pruning avoids unnecessary metadata requests<a href="https://doris.apache.org/blog/jd-apache-doris-lakehouse-query-optimization/#earlier-partition-pruning-avoids-unnecessary-metadata-requests" class="hash-link" aria-label="Direct link to Earlier partition pruning avoids unnecessary metadata requests" title="Direct link to Earlier partition pruning avoids unnecessary metadata requests">&#x200B;</a></h3>
<p>Large Hive tables can contain many partitions. With a cold cache, fetching metadata for all of them can make planning expensive before execution even begins.</p>
<p>Using the Nereids framework, JD.com moved query predicates earlier into candidate partition retrieval. The goal is to <strong>fetch partitions on demand and exclude irrelevant data as early as possible</strong>. The team extended predicate inference in several ways:</p>
<ul>
<li>Rewrite conditions involving functions such as <code>date_trunc</code> into ranges on partition columns when the rewrite preserves semantics.</li>
<li>For very long <code>IN</code> lists, use a range to prefilter candidate partitions, then retain the original predicate in the FE for exact filtering.</li>
<li>Use constant folding and other simplifications early in planning to keep unnecessary partitions out of later stages.</li>
</ul>
<p><img decoding="async" loading="lazy" alt="File-level splitting and predicate-aware partition retrieval reduce unnecessary scan splits and metadata work" src="https://assets-cdn.selectdb.com/site/assets/shared/dbb3c5abf1f9c6d121b6c1e1199f2cfe.png" width="1800" height="1090" class="img_ev3q"></p>
<p>The presentation also illustrates Hive bucket pruning, partition-extrema scans, and filtering zero-byte files before split generation. Bucket pruning applies to eligible non-ACID Hive tables when the bucket key values can be computed; it still requires file listing and retains the original row predicate. The partition-extrema optimization described here is limited to <code>MIN/MAX</code> on the same partition column without <code>GROUP BY</code>, with filters covered by partition columns, on the supported Hive ORC/Parquet or Hudi native scan paths. File footers must confirm that an endpoint partition actually contains rows.</p>
<p>JD.com also addressed duplicated preparation work between file listing and cost-based optimizer statistics collection. <strong>List files once, then reuse the result</strong> for both cost estimation and scan split generation. Within a query, accesses to the same table and partition range can share the enumeration result.</p>
<p>For data volume estimates, the engine first uses valid statistics for the selected partitions. If those statistics are missing, it estimates from total file size, a decompression factor, and row width. This reduces dependence on fetching per-column statistics from the metastore while preserving useful planning information.</p>
<p><img decoding="async" loading="lazy" alt="A pruned partition set feeds one file listing whose query-scoped file information serves both CBO cost estimation and scan split generation" src="https://assets-cdn.selectdb.com/site/assets/shared/b8792693a85774d0f7d773569b442d4a.png" width="1800" height="1030" class="img_ev3q"></p>
<p>Coordinating partition pruning, file enumeration, and scan planning extends optimization across the entire query preparation phase. The <a href="https://doris.apache.org/docs/dev/lakehouse/catalogs/hive-catalog/">Hive Catalog documentation</a> explains the corresponding external data access capabilities in Doris.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="faster-scanning-and-computation-with-vectorized-execution">Faster scanning and computation with vectorized execution<a href="https://doris.apache.org/blog/jd-apache-doris-lakehouse-query-optimization/#faster-scanning-and-computation-with-vectorized-execution" class="hash-link" aria-label="Direct link to Faster scanning and computation with vectorized execution" title="Direct link to Faster scanning and computation with vectorized execution">&#x200B;</a></h3>
<p>After planning, file reads and operator execution determine throughput. JD.com optimized BE execution for complex predicates, multiple file formats, and frequently evaluated expressions.</p>
<p>For expression evaluation, the team uses common subexpression elimination (CSE) to reduce repeated work. It adjusts predicate order based on evaluation cost and filtering effectiveness, uses runtime feedback to adapt selected predicate strategies, and reuses results for frequently called functions with constant arguments.</p>
<p>For file reads, optimizations cover ORC, Parquet, and Hive Text/LZO. They reuse reader context, read columns on demand, reduce random access, and improve decompression and parsing. Concurrent file opening and reuse of HDFS connections further reduce scan overhead.</p>
<p>For filtering and aggregation, eligible <code>COUNT(*)</code> and <code>MIN/MAX</code> queries use file statistics to avoid unnecessary reads. Selected function predicates are converted into column ranges that can be pushed down to finer-grained units such as row groups. <strong>The original predicate remains for exact filtering when a range rewrite is not exact.</strong></p>
<p>Adaptive batch sizes, byte-based shuffle flow control, and improvements to aggregation state and memory management reduce buffering and memory pressure for wide rows. These changes improve execution efficiency and stability under mixed workloads.</p>
<p><img decoding="async" loading="lazy" alt="Eligible COUNT and MIN/MAX queries use metadata, while function-to-range rewrites support row-group pruning with residual predicates for correctness" src="https://assets-cdn.selectdb.com/site/assets/shared/083fc86cbab15c159cf2c786bc96e057.png" width="1800" height="1120" class="img_ev3q"></p>
<p>Across FE planning and BE execution, these optimizations address task waits, metadata access, scanning, and computation as parts of the same query path.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="4-compatibility-and-security-governance">4. Compatibility and security governance<a href="https://doris.apache.org/blog/jd-apache-doris-lakehouse-query-optimization/#4-compatibility-and-security-governance" class="hash-link" aria-label="Direct link to 4. Compatibility and security governance" title="Direct link to 4. Compatibility and security governance">&#x200B;</a></h2>
<p>A unified enterprise engine must fit existing SQL, storage, and security systems. JD.com extended its Doris integration in three areas.</p>
<p><strong>SQL dialect compatibility.</strong> The system converts both outer SQL and SQL stored in external views from a specified dialect, such as Spark SQL or Presto SQL, into Doris SQL for planning and execution. Within the supported compatibility scope, users can retain their existing SQL conventions.</p>
<p><strong>Storage compatibility.</strong> JD.com adapted the reading path for its customized Hudi LSM-tree architecture, including incremental queries over commit-time ranges and schema evolution handling. It added support for existing Hive RCFile and SequenceFile data and integrated native ChubaoFS reads for ORC, Parquet, and the Hudi native scan paths in use.</p>
<p><strong>Security and auditability.</strong> The query path associates business identity, request origin, and big data accounts. Unified authentication, credential management, and authorization control data access, including row-level and column-level permissions and data masking. Hive view authorization was also adapted so users can access authorized views according to the applicable rules. Linking business requests to underlying data access records improves traceability and auditing.</p>
<p>These storage and governance adaptations describe JD.com&apos;s environment; check the official documentation for the capabilities supported by a particular Doris release.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="5-next-steps-for-ai-agent-workloads">5. Next steps for AI agent workloads<a href="https://doris.apache.org/blog/jd-apache-doris-lakehouse-query-optimization/#5-next-steps-for-ai-agent-workloads" class="hash-link" aria-label="Direct link to 5. Next steps for AI agent workloads" title="Direct link to 5. Next steps for AI agent workloads">&#x200B;</a></h2>
<p>JD.com&apos;s architecture is evolving from several parallel engines toward a unified lakehouse query engine built on Doris. Multi-Catalog, Nereids, and vectorized execution let the team retain its lakehouse data while consolidating query compute and tuning it for production workloads.</p>
<p>The team plans four further directions:</p>
<ol>
<li><strong>Agent-oriented workload optimization:</strong> Build session-level caching and faster metadata access for agent workflows made up of multiple small queries, keeping end-to-end latency and cost manageable.</li>
<li><strong>Predictive acceleration:</strong> Use the predictability of daily traffic peaks and agent behavior for query result warm-up and execution plan reuse across queries.</li>
<li><strong>Elastic lakehouse compute:</strong> Use Doris&apos;s <a href="https://doris.apache.org/docs/dev/compute-storage-decoupled/intro/">compute-storage decoupled architecture</a> and scaling capabilities to handle traffic peaks, moving capacity planning toward dynamic scheduling along the workload curve.</li>
<li><strong>A shared semantic entry point:</strong> Coordinate the engine with a Text-to-SQL semantic layer for schema-aware SQL generation and validation.</li>
</ol>
<p>These directions build on the same production requirement: one analytical foundation must serve interactive reports, large data quality scans, and continuous AI agent requests efficiently.</p></div>]]></content:encoded>
            <category>Best Practice</category>
        </item>
        <item>
            <title><![CDATA[Apache Doris 4.2 Peer Read: 7.5× Faster Cold Queries with Shared Caches]]></title>
            <link>https://doris.apache.org/blog/apache-doris-4-2-peer-read-cache-sharing/</link>
            <guid>https://doris.apache.org/blog/apache-doris-4-2-peer-read-cache-sharing/</guid>
            <pubDate>Tue, 03 Nov 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[How Apache Doris 4.2 Peer Read shares File Cache data across compute groups, races object storage reads, and reduces cold-query latency.]]></description>
            <content:encoded><![CDATA[<header><div class="text-center mb-4"><a class="cursor-pointer hover:no-underline" lang="en" href="https://doris.apache.org/blog/">Blog</a><span class="px-2 text-[#8592A6]">/</span><span><span class="s-tags" lang="en"><span class="s-tag">Tech Sharing</span></span></span></div><h1 lang="en" class="blog-post-title text-[2rem] leading-normal lg:!text-[2.5rem] text-center" itemprop="headline">Apache Doris 4.2 Peer Read: 7.5&#xD7; Faster Cold Queries with Shared Caches</h1><div class="blog-info text-center flex justify-center text-sm text-black"><span class="authors"><span class="s-author text-black">Xin Deng</span></span><time datetime="2026-11-03T00:00:00.000Z" itemprop="datePublished" class="text-black ml-4">November 3, 2026</time></div></header><div id="__blog-post-container" class="markdown" itemprop="articleBody"><p>In an <a href="https://doris.apache.org/">Apache Doris</a> deployment with compute-storage separation, multiple compute groups share data in object storage. Without cache sharing, three problems commonly follow:</p>
<ul>
<li><strong>High first-query latency after separating reads and writes.</strong> Newly ingested data may already be cached in the write group, while a read group&apos;s first query still fetches it from object storage. A single primary-key lookup can take several seconds.</li>
<li><strong>Performance fluctuations after scaling.</strong> New nodes start with empty caches after scale-out or tablet rebalancing, and query performance takes time to recover.</li>
<li><strong>Repeated object storage reads after eviction.</strong> Limited cache capacity means previously fetched data may need to be downloaded again when it is accessed later.</li>
</ul>
<p>The missing piece is shared cache access. <strong>Peer Read</strong>, introduced in Apache Doris 4.2, tries another node&apos;s cache when a local read misses, including nodes in other compute groups. If the peer lacks the data or responds too slowly, the request falls back to object storage.</p>
<p>In a user&apos;s workload on a Doris cloud service, enabling Peer Read reduced average cold primary-key lookup latency from <strong>4.45 to 0.59 seconds</strong>, about <strong>7.5&#xD7; faster</strong>. P99 latency fell from 7.69 to 1.52 seconds, and object storage requests fell by about 98%. In a separate TPC-H 1 TB test, total cold-read time across 22 queries fell by about 51%.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="1-shared-data-isolated-caches">1. Shared data, isolated caches<a href="https://doris.apache.org/blog/apache-doris-4-2-peer-read-cache-sharing/#1-shared-data-isolated-caches" class="hash-link" aria-label="Direct link to 1. Shared data, isolated caches" title="Direct link to 1. Shared data, isolated caches">&#x200B;</a></h2>
<p>A Doris cluster with compute-storage separation can use multiple compute groups for read/write separation, online/offline workload isolation, and elastic scaling. Groups share data and metadata, so committed writes become visible to other groups.</p>
<p>Each BE, however, maintains its own local File Cache. Without Peer Read, a read group cannot directly use blocks cached by the write group or by another read group. Each group has to populate its own cache.</p>
<p><img decoding="async" loading="lazy" alt="Read groups share object storage but cannot use one another&amp;#39;s local cached blocks without peer reads" src="https://assets-cdn.selectdb.com/site/assets/shared/557e46a13aac2861a1fe643b66255ec4.jpg" width="1200" height="630" class="img_ev3q"></p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="why-cold-reads-are-slow">Why cold reads are slow<a href="https://doris.apache.org/blog/apache-doris-4-2-peer-read-cache-sharing/#why-cold-reads-are-slow" class="hash-link" aria-label="Direct link to Why cold reads are slow" title="Direct link to Why cold reads are slow">&#x200B;</a></h3>
<p>Object storage provides high throughput for large reads, but individual requests have much higher latency than local disks or a network within the same data center. Before reading table data, many queries must read segment footers and indexes. Those reads are small but numerous.</p>
<p>In the primary-key workload described later, each query averaged more than 200 remote I/O requests, mostly for footers and indexes. Waiting for those small requests accounted for much of the query time.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="cache-warm-up-and-peer-read">Cache warm-up and Peer Read<a href="https://doris.apache.org/blog/apache-doris-4-2-peer-read-cache-sharing/#cache-warm-up-and-peer-read" class="hash-link" aria-label="Direct link to Cache warm-up and Peer Read" title="Direct link to Cache warm-up and Peer Read">&#x200B;</a></h3>
<p>Earlier Doris versions already support cache warm-up, including incremental warm-up that notifies read groups after ingestion. Warm-up anticipates which data will be accessed and loads it from object storage before queries arrive. Peer Read covers misses discovered at query time.</p>






























<table><thead><tr><th>Dimension</th><th>Cache warm-up</th><th>Peer Read</th></tr></thead><tbody><tr><td>Trigger</td><td>Proactively loads object storage data before a query</td><td>Reads another node after a local cache miss</td></tr><tr><td>Prerequisite</td><td>Known access patterns and configured warm-up tasks or relationships</td><td>No prediction of hot data required</td></tr><tr><td>Typical use</td><td>Known hot data and incremental synchronization of newly ingested data</td><td>Cold reads after scaling, eviction, or before warm-up finishes</td></tr><tr><td>Cost</td><td>Each read group needs cache capacity; warm-up reads object storage</td><td>Uses the peer&apos;s network and disk resources</td></tr></tbody></table>
<p>The two approaches work together: warm-up prepares known hot data, while Peer Read fills gaps during execution.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="2-how-peer-read-works">2. How Peer Read works<a href="https://doris.apache.org/blog/apache-doris-4-2-peer-read-cache-sharing/#2-how-peer-read-works" class="hash-link" aria-label="Direct link to 2. How Peer Read works" title="Direct link to 2. How Peer Read works">&#x200B;</a></h2>
<p>Peer Read reuses existing BE File Caches without adding a separate cache service. It intervenes only on a local miss; a local hit follows the existing path.</p>
<p><img decoding="async" loading="lazy" alt="On a local cache miss, Doris discovers peers, fetches missing blocks, falls back to object storage when needed, and backfills the local cache" src="https://assets-cdn.selectdb.com/site/assets/shared/a583fe9b3fd0c3ab4d4635bb8bc374f7.jpg" width="1200" height="630" class="img_ev3q"></p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="21-find-candidate-peers">2.1 Find candidate peers<a href="https://doris.apache.org/blog/apache-doris-4-2-peer-read-cache-sharing/#21-find-candidate-peers" class="hash-link" aria-label="Direct link to 2.1 Find candidate peers" title="Direct link to 2.1 Find candidate peers">&#x200B;</a></h3>
<p>Candidates come from two sources:</p>
<ul>
<li><strong>FE hints during scaling.</strong> When a tablet moves between BEs in the same compute group, FE tells the destination about the source BE and gives that peer the highest priority. Initial reads can fetch cached blocks from the old BE.</li>
<li><strong>On-demand FE lookup.</strong> If no candidates are available locally, the BE asks FE in the background where the tablet is assigned across compute groups. The current read does not wait and proceeds to object storage. A cold query usually has many concurrent reads; the first footer read can trigger discovery, allowing later reads in the same query to use peers.</li>
</ul>
<p>The BE also remembers the compute group that last served a successful peer read for each tablet and prefers it next time.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="22-fetch-only-missing-blocks">2.2 Fetch only missing blocks<a href="https://doris.apache.org/blog/apache-doris-4-2-peer-read-cache-sharing/#22-fetch-only-missing-blocks" class="hash-link" aria-label="Direct link to 2.2 Fetch only missing blocks" title="Direct link to 2.2 Fetch only missing blocks">&#x200B;</a></h3>
<p>The requester asks peers only for blocks missing from its local cache. Returned data serves the current query and backfills local File Cache, allowing later reads of the same blocks to hit locally.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="23-give-peers-a-20-ms-head-start">2.3 Give peers a 20 ms head start<a href="https://doris.apache.org/blog/apache-doris-4-2-peer-read-cache-sharing/#23-give-peers-a-20-ms-head-start" class="hash-link" aria-label="Direct link to 2.3 Give peers a 20 ms head start" title="Direct link to 2.3 Give peers a 20 ms head start">&#x200B;</a></h3>
<p>By default, Peer Read races against object storage with a configurable <strong>20 ms head start</strong>. The BE sends the peer request first. If it returns within that window, Doris does not send an object storage request. Otherwise, Doris starts the object storage read too and uses the first result returned.</p>
<p><img decoding="async" loading="lazy" alt="A fast peer avoids an object storage request; a slower peer races object storage after the configurable 20 ms delay" src="https://assets-cdn.selectdb.com/site/assets/shared/8700a3517c3766aa72524ca2282de38b.jpg" width="1200" height="630" class="img_ev3q"></p>
<p>Starting both reads immediately would add an object storage request on every miss. Waiting indefinitely for a peer would let one slow node delay a query. The head start balances those costs.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="24-fall-back-automatically">2.4 Fall back automatically<a href="https://doris.apache.org/blog/apache-doris-4-2-peer-read-cache-sharing/#24-fall-back-automatically" class="hash-link" aria-label="Direct link to 2.4 Fall back automatically" title="Direct link to 2.4 Fall back automatically">&#x200B;</a></h3>
<p>If a peer is unreachable, times out, lacks the block, or is rate-limited, Doris falls back to object storage rather than failing the query because of the peer attempt.</p>
<p>Candidate lists also adapt. A node without the requested data moves to the end of the list. Repeated RPC failures evict a candidate. If all candidates repeatedly miss for a tablet, Doris temporarily pauses peer attempts for that tablet to avoid ineffective requests.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="25-let-a-write-group-fill-the-cache">2.5 Let a write group fill the cache<a href="https://doris.apache.org/blog/apache-doris-4-2-peer-read-cache-sharing/#25-let-a-write-group-fill-the-cache" class="hash-link" aria-label="Direct link to 2.5 Let a write group fill the cache" title="Direct link to 2.5 Let a write group fill the cache">&#x200B;</a></h3>
<p>In a one-writer, multiple-reader deployment, the write group can act as a <strong>fill compute group</strong>. If its BE receives a read request and also lacks the block, it fetches the block from object storage, stores it in its own File Cache, and returns it to the requesting read group.</p>
<p><img decoding="async" loading="lazy" alt="A write group fetches missing blocks into its cache and serves them to multiple read groups" src="https://assets-cdn.selectdb.com/site/assets/shared/35d0451718069dfc26af7f43720d2a45.jpg" width="1200" height="630" class="img_ev3q"></p>
<p>The fetched copy can then serve other read groups while it remains cached, reducing separate downloads of the same data. Fill requests have concurrency and timeout limits; when those limits are reached, the requester falls back to object storage itself.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="3-tpc-h-1-tb-roughly-half-the-cold-read-time">3. TPC-H 1 TB: roughly half the cold-read time<a href="https://doris.apache.org/blog/apache-doris-4-2-peer-read-cache-sharing/#3-tpc-h-1-tb-roughly-half-the-cold-read-time" class="hash-link" aria-label="Direct link to 3. TPC-H 1 TB: roughly half the cold-read time" title="Direct link to 3. TPC-H 1 TB: roughly half the cold-read time">&#x200B;</a></h2>
<p>We compared cold reads between a write group and a read group using TPC-H at 1 TB. The write group already had the data cached. Before each of the 22 sequential queries, the read group&apos;s cache was cleared.</p>
<p><img decoding="async" loading="lazy" alt="Total elapsed time for 22 TPC-H queries: 323.3 seconds from object storage, 158.6 with Peer Read, and 59.5 for local cache hits" src="https://assets-cdn.selectdb.com/site/assets/shared/14bfcf8012c22f2946b7565fe0c7cd0a.jpg" width="1200" height="630" class="img_ev3q"></p>

























<table><thead><tr><th>Read path</th><th style="text-align:right">Total time for 22 queries</th><th>Compared with direct object storage</th></tr></thead><tbody><tr><td>Cold read, direct object storage</td><td style="text-align:right">323.3 s</td><td>Baseline</td></tr><tr><td>Cold read, Peer Read enabled</td><td style="text-align:right"><strong>158.6 s</strong></td><td><strong>About 2&#xD7; faster; 51% less time</strong></td></tr><tr><td>Warm read, local cache hit (reference)</td><td style="text-align:right">59.5 s</td><td>Reference only</td></tr></tbody></table>
<p><strong>Test setup:</strong> TPC-H 1 TB; one FE with 4 CPU cores and 16 GB RAM; six BEs, each with 32 CPU cores, 128 GB RAM, and three 500 GB cloud disks. The write and read groups each had three BEs. Cache blocks were 1 MB, and Peer Read used its default race mode.</p>
<p>Peer Read reduced total elapsed time from 323.3 to 158.6 seconds. Sequential mode, which tries peers before falling back to object storage, produced a similar total of 155.5 seconds. In sequential mode, all 22 queries were faster than direct object storage reads, with per-query speedups from 1.4&#xD7; to 3.3&#xD7;.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="when-the-write-groups-cache-is-also-cold">When the write group&apos;s cache is also cold<a href="https://doris.apache.org/blog/apache-doris-4-2-peer-read-cache-sharing/#when-the-write-groups-cache-is-also-cold" class="hash-link" aria-label="Direct link to When the write group&apos;s cache is also cold" title="Direct link to When the write group&apos;s cache is also cold">&#x200B;</a></h3>
<p>We also tested a case where neither group had the data cached. The write group fetched it from object storage, cached it, and forwarded it to the read group. Across 22 queries, total time was <strong>332.4 seconds</strong>, about <strong>3% more</strong> than direct object storage reads.</p>
<p>This test used the same hardware and sequential mode. The extra forwarding hop added about 3% in this experiment. It also left data in the write group&apos;s cache for subsequent requests from other read groups, where it could provide the benefits measured in the cached-peer test. The result is specific to this setup, not a guarantee of a fixed overhead.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="4-doris-cloud-service-workload-75-faster-cold-point-queries">4. Doris cloud service workload: 7.5&#xD7; faster cold point queries<a href="https://doris.apache.org/blog/apache-doris-4-2-peer-read-cache-sharing/#4-doris-cloud-service-workload-75-faster-cold-point-queries" class="hash-link" aria-label="Direct link to 4. Doris cloud service workload: 7.5&#xD7; faster cold point queries" title="Direct link to 4. Doris cloud service workload: 7.5&#xD7; faster cold point queries">&#x200B;</a></h2>
<p>A user of a Doris cloud service runs one write group that continuously ingests data and multiple read groups that serve external APIs, primarily through primary-key lookups. First queries against new data had variable latency. Each read group needed substantial cache capacity, duplicating the same data across groups.</p>
<p>For Peer Read, the DBA designated the write group as the read groups&apos; fill compute group. A local miss first requests data from the write group; if that group&apos;s cache also misses, it fetches the data on the requester&apos;s behalf.</p>
<p>The user tested <strong>100 primary-key lookups</strong> against a business table using the Unique Key model. The write group first warmed the data. After clearing the read group&apos;s cache and restarting it, the user executed the same 100 queries with Peer Read disabled and enabled. The queries covered 100 different tablets and ran sequentially, once each.</p>
<p><img decoding="async" loading="lazy" alt="Cold primary-key lookup latency and object storage requests with Peer Read off and on, with local cache hits as a reference" src="https://assets-cdn.selectdb.com/site/assets/shared/fe4b8faaf18d37ab11d5d827ab81d05c.png" width="2080" height="832" class="img_ev3q"></p>



































<table><thead><tr><th>Metric</th><th style="text-align:right">Cold, Peer Read off</th><th style="text-align:right">Cold, Peer Read on</th><th style="text-align:right">Local warm read (reference)</th></tr></thead><tbody><tr><td>Average latency</td><td style="text-align:right">4.45 s</td><td style="text-align:right"><strong>0.59 s</strong></td><td style="text-align:right">0.06 s</td></tr><tr><td>P99 latency</td><td style="text-align:right">7.69 s</td><td style="text-align:right"><strong>1.52 s</strong></td><td style="text-align:right">0.09 s</td></tr><tr><td>Object storage requests</td><td style="text-align:right">21,368</td><td style="text-align:right"><strong>372</strong></td><td style="text-align:right">0</td></tr><tr><td>Bytes read from object storage</td><td style="text-align:right">4.24 GiB</td><td style="text-align:right"><strong>About 186 KiB</strong></td><td style="text-align:right">0</td></tr></tbody></table>
<p>Each compute group had one BE, and the test used one sequential run. These measurements describe the user&apos;s Doris cloud service environment.</p>
<p>All 100 queries obtained data from peers and were faster with Peer Read enabled. Average latency fell by about <strong>87%</strong>, a <strong>7.5&#xD7;</strong> speedup; P99 fell by about <strong>80%</strong>. Object storage requests dropped to about 1.7% of the original count, reducing the request-billed portion of storage cost.</p>
<p>Point lookups benefited more than scan-heavy TPC-H queries because their latency was dominated by many small footer and index reads. Peer Read shortened the wait for each of those reads.</p>
<p>Local cache hits remained roughly an order of magnitude faster. Peer Read reduces cold-read latency while the local cache is being populated; local caching still provides the fastest read path.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="5-enable-peer-read-in-apache-doris">5. Enable Peer Read in Apache Doris<a href="https://doris.apache.org/blog/apache-doris-4-2-peer-read-cache-sharing/#5-enable-peer-read-in-apache-doris" class="hash-link" aria-label="Direct link to 5. Enable Peer Read in Apache Doris" title="Direct link to 5. Enable Peer Read in Apache Doris">&#x200B;</a></h2>
<blockquote>
<p><strong>Apache Doris 4.2 provides Peer Read as an experimental feature, disabled by default.</strong></p>
</blockquote>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="configuration">Configuration<a href="https://doris.apache.org/blog/apache-doris-4-2-peer-read-cache-sharing/#configuration" class="hash-link" aria-label="Direct link to Configuration" title="Direct link to Configuration">&#x200B;</a></h3>
<ol>
<li>Enable File Cache on every BE with <code>enable_file_cache = true</code>.</li>
<li>Set <code>enable_cache_read_from_peer = true</code> on every BE. This switch controls both same-group and cross-group peer reads.</li>
<li>For fill behavior in a one-writer, multiple-reader deployment, set <code>peer_cache_fill_compute_group_id</code> on every BE in each requesting read group. Use the write group&apos;s <strong>compute group ID</strong>, not its name.</li>
</ol>
<p>See the <a href="https://doris.apache.org/docs/4.x/compute-storage-decoupled/file-cache/file-cache-peer-read/">Doris 4.x Peer Cache Read documentation</a> for configuration procedures, parameter details, and troubleshooting.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="verify-the-read-path">Verify the read path<a href="https://doris.apache.org/blog/apache-doris-4-2-peer-read-cache-sharing/#verify-the-read-path" class="hash-link" aria-label="Direct link to Verify the read path" title="Direct link to Verify the read path">&#x200B;</a></h3>
<p>Inspect these counters under <code>SegmentIterator</code> in Query Profile:</p>





















<table><thead><tr><th>Counter</th><th>Meaning</th></tr></thead><tbody><tr><td><code>NumPeerIOTotal</code></td><td>Number of peer reads</td></tr><tr><td><code>CrossCGPeerIOTotal</code></td><td>Peer reads across compute groups</td></tr><tr><td><code>PeerRaceWin</code> / <code>S3RaceWin</code></td><td>Races won by the peer and by object storage, respectively</td></tr></tbody></table>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="operational-considerations">Operational considerations<a href="https://doris.apache.org/blog/apache-doris-4-2-peer-read-cache-sharing/#operational-considerations" class="hash-link" aria-label="Direct link to Operational considerations" title="Direct link to Operational considerations">&#x200B;</a></h3>
<ul>
<li>Cross-group reads use the peer group&apos;s network and disk resources. A fill group also uses object storage bandwidth and cache capacity. Disable Peer Read where strict resource isolation is required.</li>
<li>Cross-availability-zone peer reads can incur inter-zone traffic charges.</li>
<li>If <code>S3RaceWin</code> substantially exceeds <code>PeerRaceWin</code>, the peer path is not faster in that environment. To prioritize fewer object storage requests, consider increasing <code>peer_race_hedge_delay_ms</code>. If latency is the priority and peers provide little benefit, consider disabling Peer Read.</li>
<li>Peer Read applies to internal tables in compute-storage separation mode. External-table reads, such as Hive and Iceberg, do not use this path.</li>
</ul>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="6-reuse-cached-data-across-groups">6. Reuse cached data across groups<a href="https://doris.apache.org/blog/apache-doris-4-2-peer-read-cache-sharing/#6-reuse-cached-data-across-groups" class="hash-link" aria-label="Direct link to 6. Reuse cached data across groups" title="Direct link to 6. Reuse cached data across groups">&#x200B;</a></h2>
<p>Peer Read lets a compute group use blocks already cached elsewhere in the cluster. Newly ingested data, first reads on scaled-out nodes, and data accessed again after eviction can all benefit without a new cache service. If a peer cannot serve the request, Doris falls back to object storage.</p>
<p>In the TPC-H 1 TB test, this cut total cold-read time roughly in half. In the Doris cloud service user&apos;s primary-key workload, average cold-query latency fell from 4.45 to 0.59 seconds. Peer Read was planned for the upcoming Apache Doris 4.2 release at the time of the original article; evaluate its experimental implementation with your own workload and resource-isolation requirements.</p></div>]]></content:encoded>
            <category>Tech Sharing</category>
        </item>
        <item>
            <title><![CDATA[Apache Doris and Vane: Bringing Multimodal Data into Business Analytics]]></title>
            <link>https://doris.apache.org/blog/apache-doris-vane-multimodal-analytics/</link>
            <guid>https://doris.apache.org/blog/apache-doris-vane-multimodal-analytics/</guid>
            <pubDate>Thu, 29 Oct 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[A practical Apache Doris and Vane workflow for transcribing audio, generating embeddings, searching feedback, and tracing results to business records.]]></description>
            <content:encoded><![CDATA[<header><div class="text-center mb-4"><a class="cursor-pointer hover:no-underline" lang="en" href="https://doris.apache.org/blog/">Blog</a><span class="px-2 text-[#8592A6]">/</span><span><span class="s-tags" lang="en"><span class="s-tag">Tech Sharing</span></span></span></div><h1 lang="en" class="blog-post-title text-[2rem] leading-normal lg:!text-[2.5rem] text-center" itemprop="headline">Apache Doris and Vane: Bringing Multimodal Data into Business Analytics</h1><div class="blog-info text-center flex justify-center text-sm text-black"><span class="authors"><span class="s-author text-black">Apache Doris</span></span><time datetime="2026-10-29T00:00:00.000Z" itemprop="datePublished" class="text-black ml-4">October 29, 2026</time></div></header><div id="__blog-post-container" class="markdown" itemprop="articleBody"><p>Orders, support tickets, and production batches already live in databases. Much of the detail in customer feedback, however, still lives in call recordings, transcripts, and attachments.</p>
<p>To answer &#x201C;Which other customers reported a similar problem, and which production batches were involved?&#x201D;, a team may need to listen to recordings, summarize the issue, and check business systems one by one. The data exists, but querying it together remains difficult.</p>
<p>Apache Doris and Vane connect those sources. Vane processes audio, images, and video into text, candidate classifications, and embeddings. <strong>Doris brings those results into the existing business data model</strong>, where they can be joined with orders, tickets, and production batches. The same records support similarity search and business analysis while retaining references to the original evidence.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="bring-multimodal-data-into-business-queries">Bring multimodal data into business queries<a href="https://doris.apache.org/blog/apache-doris-vane-multimodal-analytics/#bring-multimodal-data-into-business-queries" class="hash-link" aria-label="Direct link to Bring multimodal data into business queries" title="Direct link to Bring multimodal data into business queries">&#x200B;</a></h2>
<p>Enterprise AI retrieval usually involves more than finding semantically similar content. Queries also carry business constraints such as product model, time range, equipment type, and the orders or batches that need investigation.</p>
<p>Keeping business data, text search, and vector search in Doris lets those constraints participate in the same SQL workflow:</p>
<ul>
<li><strong>Narrow the scope, then find related content.</strong> For feedback about an X1 device that will not start, restrict the model and date range, then find descriptions such as &#x201C;the switch does nothing&#x201D; and &#x201C;nothing happens when I turn it on.&#x201D; A fault-code investigation can also include text matching.</li>
<li><strong>Continue from retrieval into analysis.</strong> Join retrieved feedback through tickets to orders and batches. With explicit review status, scope, and deduplication rules, analyze how candidate issues are distributed across batches and over time.</li>
<li><strong>Reuse existing business data and SQL workflows.</strong> Filtering, retrieval, joins, and aggregation can share the same data environment, reducing business-field replication, synchronization work, and application-side result assembly.</li>
</ul>
<p>The result is a path from finding relevant content to tracing its business context and analyzing its distribution.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="doris-and-vane-from-files-to-usable-data">Doris and Vane: from files to usable data<a href="https://doris.apache.org/blog/apache-doris-vane-multimodal-analytics/#doris-and-vane-from-files-to-usable-data" class="hash-link" aria-label="Direct link to Doris and Vane: from files to usable data" title="Direct link to Doris and Vane: from files to usable data">&#x200B;</a></h2>
<p>Turning a file into queryable data can require document parsing and chunking, audio transcription, video frame extraction, business-field extraction, and embedding generation. A support call, for example, can become segment records containing a ticket ID, transcript, candidate fault category, and embedding, plus the original recording URI and timestamps.</p>
<p>Those steps have different processing costs. One input can expand into many segments, while reading, decoding, and inference run at different speeds. After a Python prototype works, a team still has to manage batches, concurrency, model reuse, and failures.</p>
<p><img decoding="async" loading="lazy" alt="Business data flows directly into Doris, while Vane processes documents, images, audio, and video into text, fields, and embeddings for joined SQL analysis and retrieval" src="https://assets-cdn.selectdb.com/site/assets/shared/0d4225f601fdaa14222ae75303b25a9f.png" width="1600" height="920" class="img_ev3q"></p>
<p><a href="https://github.com/AstroVela/vane" target="_blank" rel="noopener noreferrer">Vane</a> combines SQL, Python UDFs, and AI functions in one dataflow. Business identifiers, source references, and processing results stay associated while the engine coordinates reads, decoding, inference, and output handling. The resulting text, structured fields, and vectors are loaded into Doris alongside business records.</p>
<p>The following support-recording example follows the order <strong>prepare Doris tables &#x2192; process and load with Vane &#x2192; query in Doris</strong>. The code consists of excerpts, not a complete standalone pipeline. Use the <a href="https://vane.astrovela.ai/docs/data/tutorials/use-cases/audio-support-doris-search" target="_blank" rel="noopener noreferrer">Vane + Doris Support Recording Search tutorial</a> for environment setup, recordings, UDF implementation and registration, segment expansion, and loading code.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="from-support-recordings-to-business-analysis">From support recordings to business analysis<a href="https://doris.apache.org/blog/apache-doris-vane-multimodal-analytics/#from-support-recordings-to-business-analysis" class="hash-link" aria-label="Direct link to From support recordings to business analysis" title="Direct link to From support recordings to business analysis">&#x200B;</a></h2>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="prepare-doris-tables-and-indexes">Prepare Doris tables and indexes<a href="https://doris.apache.org/blog/apache-doris-vane-multimodal-analytics/#prepare-doris-tables-and-indexes" class="hash-link" aria-label="Direct link to Prepare Doris tables and indexes" title="Direct link to Prepare Doris tables and indexes">&#x200B;</a></h3>
<p>In a Doris SQL client, create the destination database and segment table. <code>feedback_segments</code> stores transcript text, a candidate category, an independent review status, a 384-dimensional embedding, and source positions. It also retains ticket, product-model, and date fields. The inverted index supports text filtering; the ANN index prepares for approximate vector retrieval.</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DATABASE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">IF</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">NOT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">EXISTS</span><span class="token plain"> vane_support_demo</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">TABLE</span><span class="token plain"> vane_support_demo</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">feedback_segments </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    ticket_id </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VARCHAR</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">64</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">NOT</span><span class="token plain"> </span><span class="token boolean" style="color:hsl(35, 99%, 36%)">NULL</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    segment_id </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INT</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">NOT</span><span class="token plain"> </span><span class="token boolean" style="color:hsl(35, 99%, 36%)">NULL</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- Business filters.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    product_model </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VARCHAR</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">64</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    event_date </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- AI labels are candidates; load new records with review_status = &apos;pending&apos;.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">text</span><span class="token plain"> STRING</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    fault_category </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VARCHAR</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">64</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    review_status </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VARCHAR</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">32</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- Original recording and segment boundaries, in milliseconds.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    source_uri STRING</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    start_ms </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BIGINT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    end_ms </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BIGINT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    embedding ARRAY</span><span class="token operator" style="color:hsl(221, 87%, 60%)">&lt;</span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FLOAT</span><span class="token operator" style="color:hsl(221, 87%, 60%)">&gt;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">NOT</span><span class="token plain"> </span><span class="token boolean" style="color:hsl(35, 99%, 36%)">NULL</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- Use the English parser for this English-language example.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INDEX</span><span class="token plain"> idx_text</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token keyword" style="color:hsl(301, 63%, 40%)">text</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">USING</span><span class="token plain"> INVERTED PROPERTIES</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;parser&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;english&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- Match dimensions and distance settings to ingestion and query embeddings.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INDEX</span><span class="token plain"> idx_embedding</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">embedding</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">USING</span><span class="token plain"> ANN PROPERTIES</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;index_type&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;hnsw&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;metric_type&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;l2_distance&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;dim&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;384&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ENGINE</span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain">OLAP</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DUPLICATE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">KEY</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">ticket_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> segment_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DISTRIBUTED</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">HASH</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">ticket_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> BUCKETS </span><span class="token number" style="color:hsl(35, 99%, 36%)">1</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">PROPERTIES</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;replication_num&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;1&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>Also prepare the business relationship tables from the tutorial: <code>ticket_orders</code> maps tickets to orders, and <code>orders</code> records production batches. The example assumes one order per ticket and one batch per order. In a real deployment, use the corresponding business tables already in Doris.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="process-recordings-in-vane">Process recordings in Vane<a href="https://doris.apache.org/blog/apache-doris-vane-multimodal-analytics/#process-recordings-in-vane" class="hash-link" aria-label="Direct link to Process recordings in Vane" title="Direct link to Process recordings in Vane">&#x200B;</a></h3>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="associate-recordings-with-ticket-metadata">Associate recordings with ticket metadata<a href="https://doris.apache.org/blog/apache-doris-vane-multimodal-analytics/#associate-recordings-with-ticket-metadata" class="hash-link" aria-label="Direct link to Associate recordings with ticket metadata" title="Direct link to Associate recordings with ticket metadata">&#x200B;</a></h4>
<p>Vane can carry file references and ticket metadata through the same pipeline:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token comment" style="color:hsl(230, 4%, 64%)">-- Run in Vane: combine file references with business metadata.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">WITH</span><span class="token plain"> files </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        ticket_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        product_model</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        event_date</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- FILE retains the reference; AUDIOFILE is the transcription UDF input.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        audio_file</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">            </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">file</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">url</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token boolean" style="color:hsl(35, 99%, 36%)">NULL</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token boolean" style="color:hsl(35, 99%, 36%)">NULL</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token boolean" style="color:hsl(35, 99%, 36%)">NULL</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token boolean" style="color:hsl(35, 99%, 36%)">NULL</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> audio</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- Enumerate files; transcription reads their contents later.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> list_files</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;./recordings/*.wav&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> f</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">JOIN</span><span class="token plain"> read_csv</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;tickets.csv&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> header </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token boolean" style="color:hsl(35, 99%, 36%)">true</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> t</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">      </span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- Match T1024.wav to its unique ticket ID; unmatched files are excluded.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">      </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ON</span><span class="token plain"> regexp_extract</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">url</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;([^/]+)\.wav$&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">1</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> t</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">ticket_id</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> ticket_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> product_model</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> event_date</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> audio</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> files</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>The source file enters the pipeline with business context attached. Transcription, extraction, and embedding generation continue along the same flow.</p>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="transcribe-and-retain-segment-timestamps">Transcribe and retain segment timestamps<a href="https://doris.apache.org/blog/apache-doris-vane-multimodal-analytics/#transcribe-and-retain-segment-timestamps" class="hash-link" aria-label="Direct link to Transcribe and retain segment timestamps" title="Direct link to Transcribe and retain segment timestamps">&#x200B;</a></h4>
<p>Transcription retains segment positions so a retrieved result can be checked against the recording:</p>
<div class="language-python codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-python codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token comment" style="color:hsl(230, 4%, 64%)"># Vane batch UDF excerpt. See the tutorial for implementation and registration.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token decorator annotation punctuation" style="color:hsl(119, 34%, 47%)">@vane</span><span class="token decorator annotation punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token decorator annotation punctuation" style="color:hsl(119, 34%, 47%)">cls</span><span class="token decorator annotation punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token decorator annotation punctuation" style="color:hsl(119, 34%, 47%)">batch</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">actor_number</span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token number" style="color:hsl(35, 99%, 36%)">1</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> gpus</span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token number" style="color:hsl(35, 99%, 36%)">0</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> return_dtype</span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;VARCHAR&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">class</span><span class="token plain"> </span><span class="token class-name" style="color:hsl(35, 99%, 36%)">SpeechRecognizer</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token comment" style="color:hsl(230, 4%, 64%)"># Load once per actor and reuse the model across batches.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">def</span><span class="token plain"> </span><span class="token function" style="color:hsl(221, 87%, 60%)">__init__</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">self</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> model_name</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">from</span><span class="token plain"> faster_whisper </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">import</span><span class="token plain"> WhisperModel</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        self</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">model </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> WhisperModel</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">            model_name</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">            device</span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;cpu&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">            compute_type</span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;int8&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">def</span><span class="token plain"> </span><span class="token function" style="color:hsl(221, 87%, 60%)">__call__</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">self</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> audios</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token comment" style="color:hsl(230, 4%, 64%)"># Transcribe a batch of AUDIOFILE values.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token comment" style="color:hsl(230, 4%, 64%)"># Return one JSON string per input, including segment IDs,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token comment" style="color:hsl(230, 4%, 64%)"># text, and start/end timestamps in milliseconds.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token comment" style="color:hsl(230, 4%, 64%)"># Later SQL expands those segments into rows.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="extract-candidate-categories-and-generate-embeddings">Extract candidate categories and generate embeddings<a href="https://doris.apache.org/blog/apache-doris-vane-multimodal-analytics/#extract-candidate-categories-and-generate-embeddings" class="hash-link" aria-label="Direct link to Extract candidate categories and generate embeddings" title="Direct link to Extract candidate categories and generate embeddings">&#x200B;</a></h4>
<p>Transcribed segments can feed further SQL processing. The classification prompt constrains the JSON schema and categories and preserves uncertainty when the evidence is insufficient:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token comment" style="color:hsl(230, 4%, 64%)">-- Run in Vane; segments comes from transcription and segment expansion.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    ticket_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    segment_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">text</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    ai_prompt</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;Classify the fault using only the support recording segment below. &apos;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token operator" style="color:hsl(221, 87%, 60%)">||</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;Return only a JSON object with the key fault_category. &apos;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token operator" style="color:hsl(221, 87%, 60%)">||</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;Allowed values: unable_to_start, general_inquiry, other_fault, needs_review. &apos;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token operator" style="color:hsl(221, 87%, 60%)">||</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;Do not treat negated, hypothetical, or resolved issues as confirmed faults. &apos;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token operator" style="color:hsl(221, 87%, 60%)">||</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;Use needs_review when evidence is insufficient. Segment: &apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">||</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">text</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        provider :</span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;openai&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        model :</span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;...&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- Replace with a text model ID available to your account.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        on_error :</span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;raise&apos;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> fault_json</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> segments</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>Validate the JSON and normalize categories before loading. Invalid JSON or values outside the allowed set become <code>needs_review</code>. Valid classifications still remain candidate labels awaiting independent review. Raising model-call errors prevents an API failure from becoming a valid classification.</p>
<p>Generate an embedding from the same transcript:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token comment" style="color:hsl(230, 4%, 64%)">-- Vane SELECT expression excerpt.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">ai_embed</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">text</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    provider :</span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;transformers&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    model :</span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    dimensions :</span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">384</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    options :</span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> struct_pack</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">normalize :</span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token boolean" style="color:hsl(35, 99%, 36%)">true</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> embedding</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>Ingestion and query embeddings must use the same model and processing settings. The 384-dimensional output must match the Doris ANN index and loading configuration, and normalization must be consistent.</p>
<p>Each recording is now represented by text, candidate categories, vectors, and source positions that Doris can query.</p>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="load-the-processed-records-into-doris">Load the processed records into Doris<a href="https://doris.apache.org/blog/apache-doris-vane-multimodal-analytics/#load-the-processed-records-into-doris" class="hash-link" aria-label="Direct link to Load the processed records into Doris" title="Direct link to Load the processed records into Doris">&#x200B;</a></h4>
<p>Vane&apos;s <code>DorisStreamLoadSink</code> uses Doris Stream Load to write the results. Each row includes the transcript, category, review status, embedding, ticket metadata, source URI, and segment boundaries. Subsequent retrieval and analysis run in Doris.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="search-feedback-and-trace-its-business-context">Search feedback and trace its business context<a href="https://doris.apache.org/blog/apache-doris-vane-multimodal-analytics/#search-feedback-and-trace-its-business-context" class="hash-link" aria-label="Direct link to Search feedback and trace its business context" title="Direct link to Search feedback and trace its business context">&#x200B;</a></h3>
<p>Run the following SQL in a Doris SQL client after loading the tutorial data.</p>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="find-similar-feedback-within-business-constraints">Find similar feedback within business constraints<a href="https://doris.apache.org/blog/apache-doris-vane-multimodal-analytics/#find-similar-feedback-within-business-constraints" class="hash-link" aria-label="Direct link to Find similar feedback within business constraints" title="Direct link to Find similar feedback within business constraints">&#x200B;</a></h4>
<p>First inspect the first nonempty segment from ticket T1024. Then reuse its stored vector to search other tickets for model X1 in September 2026:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token comment" style="color:hsl(230, 4%, 64%)">-- Inspect the segment used as the query example.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> ticket_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> segment_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">text</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> vane_support_demo</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">feedback_segments</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">WHERE</span><span class="token plain"> ticket_id </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;T1024&apos;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  </span><span class="token operator" style="color:hsl(221, 87%, 60%)">AND</span><span class="token plain"> length</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">trim</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token keyword" style="color:hsl(301, 63%, 40%)">text</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">&gt;</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">0</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ORDER</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> segment_id</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">LIMIT</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">1</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- Reuse the same segment&apos;s embedding without calling the model again.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">WITH</span><span class="token plain"> query_feedback </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> ticket_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> segment_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">text</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> embedding</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> vane_support_demo</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">feedback_segments</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">WHERE</span><span class="token plain"> ticket_id </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;T1024&apos;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">      </span><span class="token operator" style="color:hsl(221, 87%, 60%)">AND</span><span class="token plain"> length</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">trim</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token keyword" style="color:hsl(301, 63%, 40%)">text</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">&gt;</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">0</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ORDER</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> segment_id</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">LIMIT</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">1</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> q</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">ticket_id </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> query_ticket_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">       q</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">segment_id </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> query_segment_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">       q</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token keyword" style="color:hsl(301, 63%, 40%)">text</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> query_text</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">       f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">ticket_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">segment_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token keyword" style="color:hsl(301, 63%, 40%)">text</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">fault_category</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">       f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">source_uri</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">start_ms</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">end_ms</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">       l2_distance_approximate</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">embedding</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> q</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">embedding</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> distance</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> vane_support_demo</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">feedback_segments f</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">CROSS</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">JOIN</span><span class="token plain"> query_feedback q</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">WHERE</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">product_model </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;X1&apos;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  </span><span class="token operator" style="color:hsl(221, 87%, 60%)">AND</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">event_date </span><span class="token operator" style="color:hsl(221, 87%, 60%)">&gt;=</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">20260901</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">AND</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">event_date </span><span class="token operator" style="color:hsl(221, 87%, 60%)">&lt;</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">20261001</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  </span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- Exclude every segment from the source ticket.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  </span><span class="token operator" style="color:hsl(221, 87%, 60%)">AND</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">ticket_id </span><span class="token operator" style="color:hsl(221, 87%, 60%)">&lt;&gt;</span><span class="token plain"> q</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">ticket_id</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ORDER</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> distance </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ASC</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">ticket_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">segment_id</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">LIMIT</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">3</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>Smaller distances indicate closer vectors. The query returns up to three segments; one ticket can appear more than once. Returning both query and candidate text helps verify what is being compared. Similarity does not confirm a fault.</p>
<p>To require the transcript to mention &#x201C;indicator light,&#x201D; add <code>AND f.text MATCH_ANY &apos;indicator light&apos;</code> to the <code>WHERE</code> clause before <code>ORDER BY</code>. This combines text matching with vector ranking.</p>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="join-feedback-to-orders-and-production-batches">Join feedback to orders and production batches<a href="https://doris.apache.org/blog/apache-doris-vane-multimodal-analytics/#join-feedback-to-orders-and-production-batches" class="hash-link" aria-label="Direct link to Join feedback to orders and production batches" title="Direct link to Join feedback to orders and production batches">&#x200B;</a></h4>
<p>Use business relationships to trace a segment through its ticket to an order and batch. <code>LEFT JOIN</code> keeps unmatched feedback visible for data-quality checks:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">ticket_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">segment_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token keyword" style="color:hsl(301, 63%, 40%)">text</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">fault_category</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">       t</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">order_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> o</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">production_batch</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">       f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">source_uri</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">start_ms</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">end_ms</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> vane_support_demo</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">feedback_segments f</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">LEFT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">JOIN</span><span class="token plain"> vane_support_demo</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">ticket_orders t </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ON</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">ticket_id </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> t</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">ticket_id</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">LEFT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">JOIN</span><span class="token plain"> vane_support_demo</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">orders o </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ON</span><span class="token plain"> t</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">order_id </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> o</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">order_id</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">WHERE</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">product_model </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;X1&apos;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  </span><span class="token operator" style="color:hsl(221, 87%, 60%)">AND</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">event_date </span><span class="token operator" style="color:hsl(221, 87%, 60%)">&gt;=</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">20260901</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">AND</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">event_date </span><span class="token operator" style="color:hsl(221, 87%, 60%)">&lt;</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">20261001</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ORDER</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">ticket_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">segment_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>In the demonstration data, T1024 maps to O9001 and T1025 to O9002, both in B202608; T1026 maps to O9003 in B202609. These relationships come from the business tables. The source URI and millisecond timestamps remain available for listening to the original evidence. Unmatched order or batch fields are <code>NULL</code>.</p>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="count-candidate-tickets-by-batch">Count candidate tickets by batch<a href="https://doris.apache.org/blog/apache-doris-vane-multimodal-analytics/#count-candidate-tickets-by-batch" class="hash-link" aria-label="Direct link to Count candidate tickets by batch" title="Direct link to Count candidate tickets by batch">&#x200B;</a></h4>
<p>The next query searches the entire segment table for AI-labeled <code>unable_to_start</code> feedback within the model and date range, deduplicates by ticket, then counts by batch. Its scope is independent of the earlier Top-3 result.</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">WITH</span><span class="token plain"> candidate_tickets </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DISTINCT</span><span class="token plain"> ticket_id</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> vane_support_demo</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">feedback_segments</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">WHERE</span><span class="token plain"> product_model </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;X1&apos;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">      </span><span class="token operator" style="color:hsl(221, 87%, 60%)">AND</span><span class="token plain"> event_date </span><span class="token operator" style="color:hsl(221, 87%, 60%)">&gt;=</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">20260901</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">AND</span><span class="token plain"> event_date </span><span class="token operator" style="color:hsl(221, 87%, 60%)">&lt;</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">20261001</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">      </span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- At least one AI-labeled segment qualifies the ticket; review is separate.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">      </span><span class="token operator" style="color:hsl(221, 87%, 60%)">AND</span><span class="token plain"> fault_category </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;unable_to_start&apos;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">COALESCE</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">o</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">production_batch</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;Unmatched batch&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> production_batch</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">       </span><span class="token function" style="color:hsl(221, 87%, 60%)">COUNT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DISTINCT</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">ticket_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> candidate_ticket_count</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> candidate_tickets f</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">LEFT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">JOIN</span><span class="token plain"> vane_support_demo</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">ticket_orders t </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ON</span><span class="token plain"> f</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">ticket_id </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> t</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">ticket_id</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">LEFT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">JOIN</span><span class="token plain"> vane_support_demo</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">orders o </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ON</span><span class="token plain"> t</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">order_id </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> o</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">order_id</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">GROUP</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">COALESCE</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">o</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">production_batch</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;Unmatched batch&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ORDER</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> candidate_ticket_count </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DESC</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> production_batch</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p><code>candidate_ticket_count</code> counts distinct tickets with at least one segment carrying the candidate label. It is not a segment count or a failure rate, and it does not imply human confirmation. Tickets without a matching batch remain in a separate group. If no segments have the category, the result is empty.</p>
<p>Vane turns recordings into structured records; Doris connects them to tickets, orders, and batches. Similarity search, business tracing, and batch-level analysis can then use the same SQL environment.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="manufacturing-applications">Manufacturing applications<a href="https://doris.apache.org/blog/apache-doris-vane-multimodal-analytics/#manufacturing-applications" class="hash-link" aria-label="Direct link to Manufacturing applications" title="Direct link to Manufacturing applications">&#x200B;</a></h2>
<p>One manufacturer uses Doris to bring together production, inspection, equipment, and support data for line monitoring, yield analysis, batch tracing, and fault statistics. It extended that environment with document, image, and recording data, using Vane for multimodal processing and Doris for full-text and vector retrieval alongside existing analytics.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="connect-yield-changes-to-past-corrective-actions">Connect yield changes to past corrective actions<a href="https://doris.apache.org/blog/apache-doris-vane-multimodal-analytics/#connect-yield-changes-to-past-corrective-actions" class="hash-link" aria-label="Direct link to Connect yield changes to past corrective actions" title="Direct link to Connect yield changes to past corrective actions">&#x200B;</a></h3>
<p>Doris combines process parameters, test results, equipment state, and batch information to track yield and drill down by production stage, equipment, and shift. When yield falls, engineers also need historical incident reports, 8D reports, and experiment records to find similar problems and effective actions.</p>
<p>Vane parses those documents, extracts symptoms, parameter conditions, corrective actions, and validation results, and generates embeddings. It preserves business identifiers, document versions, and page numbers. Once loaded into Doris, these records support keyword and vector retrieval constrained by product or process, followed by joins to current batch parameters, historical experiments, and before-and-after metrics.</p>
<p>A detected anomaly can thus connect directly to prior experience. AI can propose investigative steps based on business data and document evidence, while engineers validate causes and corrective actions through experiments.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="connect-customer-descriptions-to-operating-and-manufacturing-data">Connect customer descriptions to operating and manufacturing data<a href="https://doris.apache.org/blog/apache-doris-vane-multimodal-analytics/#connect-customer-descriptions-to-operating-and-manufacturing-data" class="hash-link" aria-label="Direct link to Connect customer descriptions to operating and manufacturing data" title="Direct link to Connect customer descriptions to operating and manufacturing data">&#x200B;</a></h3>
<p>Support tickets, fault codes, operating logs, and batch records provide one view of product quality. Recordings, text, and photos provide another. Phrases such as &#x201C;it won&apos;t charge&#x201D; and &#x201C;charging stops halfway&#x201D; need operating context to determine whether they describe the same issue.</p>
<p>Vane transcribes calls and parses attachments, extracts symptoms and candidate categories, generates vectors, and retains ticket IDs and source positions. Doris combines model, date, and keyword constraints with vector retrieval, then joins related feedback to operating logs, repair results, and batches. Counts are deduplicated by ticket or product according to the analysis.</p>
<p>Business users can inspect original evidence and investigate whether similar complaints cluster around a batch or operating condition. That connects customer descriptions with production tracing and assessment of the affected population.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="start-with-one-data-source">Start with one data source<a href="https://doris.apache.org/blog/apache-doris-vane-multimodal-analytics/#start-with-one-data-source" class="hash-link" aria-label="Direct link to Start with one data source" title="Direct link to Start with one data source">&#x200B;</a></h2>
<p>Multimodal analysis becomes useful when information in recordings, images, and video can participate in business queries. Vane prepares the content; Doris connects it to customers, orders, tickets, and batches.</p>
<p>Start with one concrete source and one business question. The <a href="https://vane.astrovela.ai/docs/data/tutorials/use-cases/audio-support-doris-search" target="_blank" rel="noopener noreferrer">support recording tutorial</a> provides a complete example of content processing, semantic retrieval, and business analysis in a single workflow.</p></div>]]></content:encoded>
            <category>Tech Sharing</category>
        </item>
        <item>
            <title><![CDATA[Apache Doris and Lance: How Lazy Materialization Speeds Up Vector Search]]></title>
            <link>https://doris.apache.org/blog/apache-doris-lance-lazy-materialization/</link>
            <guid>https://doris.apache.org/blog/apache-doris-lance-lazy-materialization/</guid>
            <pubDate>Wed, 28 Oct 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[How Apache Doris implements lazy materialization for Lance using column dependency analysis, pinned snapshots, distributed row-ID fetches, and two-phase reads.]]></description>
            <content:encoded><![CDATA[<header><div class="text-center mb-4"><a class="cursor-pointer hover:no-underline" lang="en" href="https://doris.apache.org/blog/">Blog</a><span class="px-2 text-[#8592A6]">/</span><span><span class="s-tags" lang="en"><span class="s-tag">Tech Sharing</span></span></span></div><h1 lang="en" class="blog-post-title text-[2rem] leading-normal lg:!text-[2.5rem] text-center" itemprop="headline">Apache Doris and Lance: How Lazy Materialization Speeds Up Vector Search</h1><div class="blog-info text-center flex justify-center text-sm text-black"><span class="authors"><span class="s-author text-black">Wenqiang Li</span></span><time datetime="2026-10-28T00:00:00.000Z" itemprop="datePublished" class="text-black ml-4">October 28, 2026</time></div></header><div id="__blog-post-container" class="markdown" itemprop="articleBody"><p>Autonomous driving, knowledge-base retrieval, and multimodal search queries often perform several tasks at once: find similar records, apply business filters, and return text and attributes. As datasets grow, latency depends on both retrieval speed and how much data the execution pipeline reads, processes, and transfers.</p>
<p>The <a href="https://doris.apache.org/blog/apache-doris-lance-vector-search/">previous article</a> described a billion-record test in which vector search with four filters took 2.32 seconds with Doris + Lance and 25.228 seconds with Ray + pylance, a latency ratio of about 10.87&#xD7;. At the same scale, Doris + Lance took 0.43 seconds for vector search alone and 0.73 seconds with a time filter.</p>
<p>Query planning, parallel search, prefiltering, on-demand column reads, and caching work together in that execution path. This article focuses on <strong>lazy materialization</strong>, also called <strong>two-phase reading</strong>. It defers columns needed only for final output until after TopN, so candidates that are later discarded do not incur the full cost of reading and transferring their contents.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="why-read-some-columns-later">Why read some columns later?<a href="https://doris.apache.org/blog/apache-doris-lance-lazy-materialization/#why-read-some-columns-later" class="hash-link" aria-label="Direct link to Why read some columns later?" title="Direct link to Why read some columns later?">&#x200B;</a></h2>
<p>Suppose a Lance knowledge-base table contains <code>id</code>, <code>title</code>, <code>body</code>, and <code>embedding</code>. This query returns the 20 most relevant documents:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> title</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> body</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> _distance</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> vector_search</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;table&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;lance_catalog.demo.documents&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;column&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;embedding&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;query_vector&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;[0.1, 0.2, 0.3, 0.4]&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;metric&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;l2&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;top_k&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;20&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ORDER</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> _distance </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ASC</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>The four-dimensional vector is illustrative; use a vector and distance metric compatible with your dataset and index.</p>
<p>The query needs all four output values, but at different times. <code>_distance</code> must exist before ranking. In this example, <code>title</code> and <code>body</code> are needed only for display, so they can wait until the result is selected. Whether the business <code>id</code> can wait depends on its use in filtering, sorting, or other computation.</p>
<p>Reading the complete body during candidate generation makes losing documents incur I/O, decoding, and transfer costs. Distributed execution increases that cost: multiple search splits produce local candidates that Doris merges into a global TopN. Some candidates never reach the final result, yet their eagerly loaded bodies have already passed through Arrow conversion, Block transfers, and sorting.</p>
<p>Lazy materialization changes the order: <strong>select results using the required information, then fetch the remaining contents for those rows</strong>. Wide columns, such as long document bodies and rich attributes, offer the largest opportunity to save work.</p>
<p><img decoding="async" loading="lazy" alt="Early materialization ranks complete candidate rows, while two-phase reading ranks IDs and scores before fetching selected payloads" src="https://assets-cdn.selectdb.com/site/assets/shared/7462ef133668b5fa37d9f4f534b10718.jpg" width="1730" height="909" class="img_ev3q"></p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="how-the-two-phases-work-together">How the two phases work together<a href="https://doris.apache.org/blog/apache-doris-lance-lazy-materialization/#how-the-two-phases-work-together" class="hash-link" aria-label="Direct link to How the two phases work together" title="Direct link to How the two phases work together">&#x200B;</a></h2>
<p>Doris&apos;s optimizer, distributed execution framework, and Lance&apos;s row-level reads cooperate on this optimization. FE identifies output columns that can be deferred and adds a materialization node to the physical plan. BEs perform search, filtering, and TopN, then use the retained row locators to fetch the remaining columns in batches.</p>




















<table><thead><tr><th>Phase</th><th>Main work</th><th>Data carried</th></tr></thead><tbody><tr><td>Phase 1: select results</td><td>Generate candidates and perform required filtering and ranking</td><td>Required early columns, distance or score, and hidden row locators</td></tr><tr><td>Phase 2: complete the output</td><td>Fetch columns by row ID and restore result order</td><td>Deferred output columns for selected rows</td></tr></tbody></table>
<p><img decoding="async" loading="lazy" alt="FE plans a pinned snapshot; BEs run parallel search, global TopN, and materialization against that Lance dataset version" src="https://assets-cdn.selectdb.com/site/assets/shared/cc544e10bcf92a83edf3e1ea0bf12471.jpg" width="1731" height="909" class="img_ev3q"></p>
<p>For an eligible query, the flow is:</p>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">Lance search splits</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  &#x2192; required early columns + score/distance + hidden row locator</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  &#x2192; Doris filtering / local TopN / exchange / global TopN</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  &#x2192; Materialize: batch row-ID fetch</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  &#x2192; restore result order and assemble output</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>The exact positions of TopN, Exchange, Project, and Filter depend on the plan. The key is that deferred columns stay out of the candidate stream until the optimized TopN has selected rows.</p>
<p>That design raises two implementation questions: which columns can wait, and how can Doris retrieve them accurately afterward?</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="phase-1-read-only-the-required-columns">Phase 1: read only the required columns<a href="https://doris.apache.org/blog/apache-doris-lance-lazy-materialization/#phase-1-read-only-the-required-columns" class="hash-link" aria-label="Direct link to Phase 1: read only the required columns" title="Direct link to Phase 1: read only the required columns">&#x200B;</a></h2>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="trace-column-dependencies">Trace column dependencies<a href="https://doris.apache.org/blog/apache-doris-lance-lazy-materialization/#trace-column-dependencies" class="hash-link" aria-label="Direct link to Trace column dependencies" title="Direct link to Trace column dependencies">&#x200B;</a></h3>
<p>Eligibility depends on how a column is used. Even a large body column must be read early if an early filter or sort needs its value.</p>
<p>During Nereids physical-plan postprocessing, <code>LazyMaterializeTopN</code> starts from TopN&apos;s output slots and traces each column&apos;s origin. <code>MaterializeProbeVisitor</code> walks down the plan to check whether sorting, filtering, or another operator needs the column early, and whether it traces back to an original column that supports row-ID fetching.</p>
<p>Sort keys need values before TopN. Columns used by residual Doris-side filters need values before those filters. Expressions evaluated early by Project also constrain their input columns. The optimizer tracks aliases and original-column dependencies so pruning one output does not remove an input still needed by another.</p>
<p><img decoding="async" loading="lazy" alt="Distance and residual-filter columns remain in phase one, while an output-only body column can be fetched after global TopN" src="https://assets-cdn.selectdb.com/site/assets/shared/55483fbc622db91f4fe5c0d1190de195.jpg" width="1731" height="909" class="img_ev3q"></p>






























<table><thead><tr><th>Column use</th><th>Treatment</th><th>Reason</th></tr></thead><tbody><tr><td>Vector <code>_distance</code> or full-text <code>_score</code></td><td>Keep in retrieval and ranking</td><td>These values are generated by search and cannot be fetched as ordinary stored columns</td></tr><tr><td>Doris-side sort keys or residual-filter inputs</td><td>Read early</td><td>Operators need actual values to select candidates</td></tr><tr><td>Inputs to expressions evaluated early</td><td>Retain according to expression dependencies</td><td>The expression needs those inputs</td></tr><tr><td>Top-level columns used only for output, such as <code>title</code> and <code>body</code></td><td>Defer when eligible</td><td>They can be fetched from the original dataset after selection</td></tr></tbody></table>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="prune-projections-and-retain-locators">Prune projections and retain locators<a href="https://doris.apache.org/blog/apache-doris-lance-lazy-materialization/#prune-projections-and-retain-locators" class="hash-link" aria-label="Direct link to Prune projections and retain locators" title="Direct link to Prune projections and retain locators">&#x200B;</a></h3>
<p>Once eligible columns are identified, <code>LazySlotPruning</code> adjusts scan and upstream outputs. It removes deferred columns from the early flow and adds a hidden global row-locator column. The optimizer then constructs <code>PhysicalLazyMaterialize</code>, recording the columns to fetch, their source relations, and each relation&apos;s locator column.</p>
<p>On the BE, <code>LanceTableReader</code> creates a scanner using the pruned projection. When a later fetch is needed, it calls <code>lance_scanner_with_row_id(scanner, true)</code> to request native Lance row IDs. A converter wraps them in an internal Doris locator that can travel across operators and BEs.</p>
<p>The candidate can therefore omit its body while retaining enough information to retrieve it later.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="phase-2-fetch-the-selected-contents">Phase 2: fetch the selected contents<a href="https://doris.apache.org/blog/apache-doris-lance-lazy-materialization/#phase-2-fetch-the-selected-contents" class="hash-link" aria-label="Direct link to Phase 2: fetch the selected contents" title="Direct link to Phase 2: fetch the selected contents">&#x200B;</a></h2>
<p>After TopN selects rows, the second phase retrieves their remaining output columns. It must preserve snapshot consistency and result order while organizing efficient reads.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="pin-the-snapshot-and-locate-the-row">Pin the snapshot and locate the row<a href="https://doris.apache.org/blog/apache-doris-lance-lazy-materialization/#pin-the-snapshot-and-locate-the-row" class="hash-link" aria-label="Direct link to Pin the snapshot and locate the row" title="Direct link to Pin the snapshot and locate the row">&#x200B;</a></h3>
<p>Lance returns native <code>uint64</code> row IDs. Doris wraps each in a versioned internal locator containing the source BE, a query-local mapping ID, and the Lance row ID.</p>
<p>The mapping ID identifies a saved scan context; it is not a physical filename. A Lance row ID is also not simply a row number in a Parquet or ORC file.</p>
<p>The saved context contains the dataset URI, pinned version, and storage access options. Phase two restores those values through the mapping and opens the same dataset snapshot. The snapshot version belongs to the context and does not need to be repeated in every locator.</p>
<p><strong>Both phases must interpret row IDs against the same snapshot.</strong> If phase one selects a row from version V, phase two must fetch from V rather than opening <code>latest</code>. <code>LanceTableReader::read_by_row_ids</code> therefore requires a fixed version and opens the dataset through the shared <code>LanceSessionManager</code>.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="route-requests-and-fetch-in-batches">Route requests and fetch in batches<a href="https://doris.apache.org/blog/apache-doris-lance-lazy-materialization/#route-requests-and-fetch-in-batches" class="hash-link" aria-label="Direct link to Route requests and fetch in batches" title="Direct link to Route requests and fetch in batches">&#x200B;</a></h3>
<p>The materialization operator decodes the hidden locators and groups <code>multiget_data_v2</code> requests by source BE. The receiving BE resolves the saved scan context, then sorts and deduplicates row IDs within each mapping to form a batch request.</p>
<p><img decoding="async" loading="lazy" alt="Selected rows carry BE IDs, mapping IDs, and Lance row IDs; grouped requests resolve the pinned snapshot, fetch rows, and restore output order" src="https://assets-cdn.selectdb.com/site/assets/shared/6ad22d24d4082a5c83916f41bd4be903.jpg" width="1730" height="909" class="img_ev3q"></p>
<p>In the Lance-specific path, <code>RowIdStorageReader</code> uses <code>LanceTableReader::read_by_row_ids</code> to call the dataset-level API. It fetches columns by row ID without recreating a normal <code>FileScanner</code> to scan the candidate-producing fragment:</p>
<div class="language-cpp codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-cpp codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token function" style="color:hsl(221, 87%, 60%)">lance_dataset_take_rows</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    dataset</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    row_ids</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token function" style="color:hsl(221, 87%, 60%)">data</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    row_ids</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token function" style="color:hsl(221, 87%, 60%)">size</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    projected_columns</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token operator" style="color:hsl(221, 87%, 60%)">&amp;</span><span class="token plain">arrow_stream</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p><code>projected_columns</code> contains only the columns needed in phase two. The SDK returns an <code>ArrowArrayStream</code>. Doris imports it into a <code>RecordBatchReader</code>, consumes batches, and converts them into Doris Blocks.</p>
<p>Some Lance reads happen only while the Arrow stream is consumed. Measuring fetch time must therefore include both the API call and subsequent <code>ReadNext</code> calls. The shared session can reuse relevant metadata and data caches, but phase two still pays for dataset opening, row-ID requests, storage reads, decoding, and conversion.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="restore-order-and-assemble-output">Restore order and assemble output<a href="https://doris.apache.org/blog/apache-doris-lance-lazy-materialization/#restore-order-and-assemble-output" class="hash-link" aria-label="Direct link to Restore order and assemble output" title="Direct link to Restore order and assemble output">&#x200B;</a></h3>
<p>Sorting and deduplicating row IDs changes the storage-read order, and responses from different BEs can arrive in any order. Doris maintains mappings from output positions to fetch positions and source BEs, then assembles the returned values in TopN&apos;s original output order.</p>
<p>A duplicate row ID within a fetch group can be read once and mapped to multiple output positions. The implementation also checks requested versus returned row counts, column lengths, and row counts across BE responses. These checks keep fetched values aligned with row identity, the snapshot, and ranking.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="where-the-savings-come-from">Where the savings come from<a href="https://doris.apache.org/blog/apache-doris-lance-lazy-materialization/#where-the-savings-come-from" class="hash-link" aria-label="Direct link to Where the savings come from" title="Direct link to Where the savings come from">&#x200B;</a></h2>
<p>Lazy materialization reduces early reads of wide output columns for candidates that will be discarded.</p>
<p>A simple model illustrates the potential. Suppose search splits produce C candidates, the final result contains K rows, and each row has W bytes of deferrable output columns:</p>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">Early payload volume &#x2248; C &#xD7; W</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">Deferred payload volume &#x2248; K &#xD7; W</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">Avoided payload volume &#x2248; (C &#x2212; K) &#xD7; W</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>This describes logical output-column volume. It excludes index reads and vector reranking and does not equal bytes downloaded from object storage. Page or block read amplification, compression, caching, row locators, and fetch RPCs all affect actual cost.</p>
<p>For example, if 16 splits each produce 20 candidates, the final result keeps 20 rows, and each body is 4 KiB:</p>

















<table><thead><tr><th>Read strategy</th><th style="text-align:right">Logical body volume</th></tr></thead><tbody><tr><td>Read bodies early for all 320 candidates</td><td style="text-align:right">320 &#xD7; 4 KiB = 1.25 MiB</td></tr><tr><td>Fetch bodies only for the final 20 rows</td><td style="text-align:right">20 &#xD7; 4 KiB = 80 KiB</td></tr></tbody></table>
<p>The logical body volume falls to <strong>1/16</strong>. This is an explanatory model, not a measured speedup or object storage transfer reduction.</p>
<p>The savings can affect several stages:</p>
<ul>
<li><strong>Reading and decoding:</strong> losing candidates do not require early reads and decoding of deferred columns.</li>
<li><strong>Transfers and memory movement:</strong> smaller intermediate Blocks reduce network traffic and memory copying.</li>
<li><strong>Sorting:</strong> wide columns no longer travel through TopN with every candidate.</li>
</ul>

























<table><thead><tr><th>More likely to benefit</th><th>Gains may be limited</th></tr></thead><tbody><tr><td>Wide output columns and a small final Top-K</td><td>Only distances, scores, or a few narrow columns are returned</td></tr><tr><td>Many candidates from multiple splits</td><td>Candidate count is already close to final result count</td></tr><tr><td>Columns are needed only for display</td><td>Most columns participate in early filters, sorting, or computation</td></tr><tr><td>Reads, decoding, or transfers are expensive</td><td>ANN computation, reranking, prefiltering, or queueing dominates</td></tr></tbody></table>
<p>With <code>OFFSET</code>, each search split may need to produce <code>top_k + offset</code> candidates even though only <code>top_k</code> rows are returned. Lazy materialization can avoid fetching output columns for skipped rows, but it does not remove candidate generation, sorting, or skipping.</p>
<p>The net gain depends on the work saved relative to the extra fetch, RPC, and result-reassembly costs.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="benchmark-two-phase-reads-on-and-off">Benchmark: two-phase reads on and off<a href="https://doris.apache.org/blog/apache-doris-lance-lazy-materialization/#benchmark-two-phase-reads-on-and-off" class="hash-link" aria-label="Direct link to Benchmark: two-phase reads on and off" title="Direct link to Benchmark: two-phase reads on and off">&#x200B;</a></h2>
<p>An internal benchmark compared the same queries with two-phase reading disabled and enabled. Vector search alone, vector search with a time filter, and vector search with time and sensor-array filters all fell from tens of seconds to single-digit seconds.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="test-setup">Test setup<a href="https://doris.apache.org/blog/apache-doris-lance-lazy-materialization/#test-setup" class="hash-link" aria-label="Direct link to Test setup" title="Direct link to Test setup">&#x200B;</a></h3>
<p>The test used a build based on <code>doris-4.1.5-release-c7f95adaaa</code> with <strong>104,343,874 rows</strong>. That build identifier describes the test environment; it does not establish availability in a standard 4.1.5 release. The cluster had one FE and two BEs. Each BE had 32 CPU cores, 128 GB RAM, and 1 TB of storage. Both scalar and vector indexes had 15 index segments.</p>
<p>All three queries used <code>vector_search</code>, sorted by L2 distance, set <code>nprobes=128</code>, <code>use_index=true</code>, and <code>top_k=20000</code>, and returned every column, including the vector. The sensor query filtered an array for Pandar128.</p>
<p>The test toggled <code>enable_lance_lazy_materialization</code>. The cluster restarted before each group, and each SQL statement ran three consecutive times. Below, <strong>cold</strong> means the first execution after restart; <strong>min</strong> means the minimum of the three executions. Speedup is disabled time divided by enabled time.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="first-execution-474-to-629-faster">First execution: 4.74&#xD7; to 6.29&#xD7; faster<a href="https://doris.apache.org/blog/apache-doris-lance-lazy-materialization/#first-execution-474-to-629-faster" class="hash-link" aria-label="Direct link to First execution: 4.74&#xD7; to 6.29&#xD7; faster" title="Direct link to First execution: 4.74&#xD7; to 6.29&#xD7; faster">&#x200B;</a></h3>
<p><img decoding="async" loading="lazy" alt="First-execution times with lazy materialization disabled and enabled across three vector search queries" src="https://assets-cdn.selectdb.com/site/assets/shared/cf88ae71cf1544f78c6a6fc966005497.png" width="1920" height="928" class="img_ev3q"></p>





























<table><thead><tr><th>Query</th><th style="text-align:right">Disabled (s)</th><th style="text-align:right">Enabled (s)</th><th style="text-align:right">Speedup</th></tr></thead><tbody><tr><td>Vector search only</td><td style="text-align:right">41.877</td><td style="text-align:right">8.839</td><td style="text-align:right">4.74&#xD7;</td></tr><tr><td>Vector + time filter</td><td style="text-align:right">33.805</td><td style="text-align:right">5.565</td><td style="text-align:right">6.07&#xD7;</td></tr><tr><td>Vector + time + sensor-array filter</td><td style="text-align:right">31.208</td><td style="text-align:right">4.962</td><td style="text-align:right">6.29&#xD7;</td></tr></tbody></table>
<p>Elapsed time fell by about <strong>78.9% to 84.1%</strong>, including queries that combined filtering with two-phase reads.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="minimum-of-three-executions-649-to-664-faster">Minimum of three executions: 6.49&#xD7; to 6.64&#xD7; faster<a href="https://doris.apache.org/blog/apache-doris-lance-lazy-materialization/#minimum-of-three-executions-649-to-664-faster" class="hash-link" aria-label="Direct link to Minimum of three executions: 6.49&#xD7; to 6.64&#xD7; faster" title="Direct link to Minimum of three executions: 6.49&#xD7; to 6.64&#xD7; faster">&#x200B;</a></h3>
<p><img decoding="async" loading="lazy" alt="Minimum times from three executions with lazy materialization disabled and enabled across the same three queries" src="https://assets-cdn.selectdb.com/site/assets/shared/4059fcb719da7d831b92aa3af84cf7b0.png" width="1920" height="928" class="img_ev3q"></p>





























<table><thead><tr><th>Query</th><th style="text-align:right">Disabled (s)</th><th style="text-align:right">Enabled (s)</th><th style="text-align:right">Speedup</th></tr></thead><tbody><tr><td>Vector search only</td><td style="text-align:right">39.630</td><td style="text-align:right">6.110</td><td style="text-align:right">6.49&#xD7;</td></tr><tr><td>Vector + time filter</td><td style="text-align:right">31.950</td><td style="text-align:right">4.901</td><td style="text-align:right">6.52&#xD7;</td></tr><tr><td>Vector + time + sensor-array filter</td><td style="text-align:right">28.377</td><td style="text-align:right">4.275</td><td style="text-align:right">6.64&#xD7;</td></tr></tbody></table>
<p>The minimum times fell by about <strong>84.6% to 84.9%</strong>. The improvement was present in both first and repeated executions.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="why-these-queries-benefited">Why these queries benefited<a href="https://doris.apache.org/blog/apache-doris-lance-lazy-materialization/#why-these-queries-benefited" class="hash-link" aria-label="Direct link to Why these queries benefited" title="Direct link to Why these queries benefited">&#x200B;</a></h3>
<p>These queries both ranked candidates and returned full rows, including vectors. Multiple search tasks produced candidates, but only some survived the global Top-K. Reading output-only columns early made losing candidates incur unnecessary reads, decoding, and transfers.</p>
<p>Two-phase reading defers that work. Phase one carries search, filter, and sort inputs plus row locators. Phase two completes the selected rows. The amount of full-output processing therefore follows the final result more closely than the intermediate candidate count.</p>
<p>The experiment shows that even a Top-K of 20,000 can benefit when the query returns all columns. Actual gains depend on the workload and the balance between saved work and second-phase overhead.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="availability">Availability<a href="https://doris.apache.org/blog/apache-doris-lance-lazy-materialization/#availability" class="hash-link" aria-label="Direct link to Availability" title="Direct link to Availability">&#x200B;</a></h2>
<p>At the time of the original article, this capability was planned for the upcoming Apache Doris 4.2 release. Consult the <a href="https://doris.apache.org/docs/4.x/lakehouse/catalogs/lance-catalog/">Lance Catalog documentation</a> for release support and compatibility.</p>
<p>Lazy materialization connects three pieces: the optimizer identifies output columns that can wait, distributed execution carries stable locators, and Lance fetches selected contents by native row ID from a pinned snapshot. For retrieval applications that return rich text and attributes, this brings column reads closer to the final result size and avoids spending work on discarded candidates.</p></div>]]></content:encoded>
            <category>Tech Sharing</category>
        </item>
        <item>
            <title><![CDATA[From Real-Time Ingestion to Fresh Results: Incremental Computing in Apache Doris 5.0]]></title>
            <link>https://doris.apache.org/blog/apache-doris-5-incremental-computing/</link>
            <guid>https://doris.apache.org/blog/apache-doris-5-incremental-computing/</guid>
            <pubDate>Thu, 22 Oct 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[Learn how Apache Doris 5.0 uses Changelog, Table Stream, and incremental view maintenance for order metrics, joined tables, ETL, and Flink change streams.]]></description>
            <content:encoded><![CDATA[<header><div class="text-center mb-4"><a class="cursor-pointer hover:no-underline" lang="en" href="https://doris.apache.org/blog/">Blog</a><span class="px-2 text-[#8592A6]">/</span><span><span class="s-tags" lang="en"><span class="s-tag">Tech Sharing</span></span></span></div><h1 lang="en" class="blog-post-title text-[2rem] leading-normal lg:!text-[2.5rem] text-center" itemprop="headline">From Real-Time Ingestion to Fresh Results: Incremental Computing in Apache Doris 5.0</h1><div class="blog-info text-center flex justify-center text-sm text-black"><span class="authors"><span class="s-author text-black">Apache Doris &#xB7; Mingyu Chen</span></span><time datetime="2026-10-22T00:00:00.000Z" itemprop="datePublished" class="text-black ml-4">October 22, 2026</time></div></header><div id="__blog-post-container" class="markdown" itemprop="articleBody"><p>Real-time analytics depends on more than ingesting new data quickly. Downstream metrics and denormalized tables also need to reflect the latest business state.</p>
<p>Consider an online order. A customer pays, a support agent changes the address, or an operations team corrects the amount. Dashboards and joined business tables need to reflect each change. Scheduled full recomputation becomes expensive as the dataset grows: infrequent runs leave results stale, while frequent runs repeatedly scan large tables to process a handful of updates.</p>
<p><strong>Apache Doris 5.0 introduces an incremental computing framework built on Changelog and Table Stream.</strong> These components capture and consume row-level changes. Incremental view maintenance uses those changes to update stored query results.</p>
<p>This article introduces the framework through four order-processing scenarios and explains when to use each approach. These capabilities are experimental and require explicit configuration. The original article previewed Doris 5.0; trying the features before release requires builds that include the relevant changes.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="changelog-and-table-stream-the-foundation">Changelog and Table Stream: the foundation<a href="https://doris.apache.org/blog/apache-doris-5-incremental-computing/#changelog-and-table-stream-the-foundation" class="hash-link" aria-label="Direct link to Changelog and Table Stream: the foundation" title="Direct link to Changelog and Table Stream: the foundation">&#x200B;</a></h2>
<p><img decoding="async" loading="lazy" alt="An orders table produces a Changelog whose changes are consumed independently by two Table Streams" src="https://assets-cdn.selectdb.com/site/assets/shared/e426d249db8a1005aa8c39e85b6b0dcc.jpg" width="1730" height="909" class="img_ev3q"></p>
<p>To update metrics and joined tables after an order changes, the system must know what changed and how far each downstream consumer has progressed. Changelog and Table Stream handle those two responsibilities.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="changelog-records-row-level-changes">Changelog records row-level changes<a href="https://doris.apache.org/blog/apache-doris-5-incremental-computing/#changelog-records-row-level-changes" class="hash-link" aria-label="Direct link to Changelog records row-level changes" title="Direct link to Changelog records row-level changes">&#x200B;</a></h3>
<p>An orders table stores current state. Changelog records inserts, updates, and deletes. Querying the table shows what an order looks like now; reading Changelog shows how it got there.</p>
<p>Suppose order 1 changes from <code>created</code> with an amount of 100 to <code>paid</code> with an amount of 120. The table keeps the new state, but an aggregate by status also needs to subtract the old 100 from the <code>created</code> group. Changelog can retain both the old and new row. The old row is the <strong>before image</strong>. A delete likewise needs the old values to determine what to remove from an aggregate.</p>
<p>For supported internal tables, Doris persists row changes with commit timestamps and record sequence numbers so downstream consumers can read them in order. The examples here handle updates and deletes, so they use Unique Key tables with Changelog and historical values enabled at table creation.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="table-stream-tracks-consumption">Table Stream tracks consumption<a href="https://doris.apache.org/blog/apache-doris-5-incremental-computing/#table-stream-tracks-consumption" class="hash-link" aria-label="Direct link to Table Stream tracks consumption" title="Direct link to Table Stream tracks consumption">&#x200B;</a></h3>
<p>A Table Stream references a base table with Changelog enabled and exposes changes that the stream has not consumed. A customer-support pipeline and an audit task can create separate streams over the orders table. Advancing one stream does not affect the other.</p>
<p>Each stream tracks its own consumption position per partition. An ordinary <code>SELECT</code> inspects pending changes without advancing that position. With <code>INSERT INTO ... SELECT ... FROM &lt;stream&gt;</code>, the target write and position advance commit in the same transaction; both roll back if it fails.</p>
<p>Consumers choose a stream type:</p>
<ul>
<li><code>append_only</code> reads appended records.</li>
<li><code>min_delta</code> collapses repeated changes to the same key into a net delta.</li>
<li><code>detail</code> preserves individual changes.</li>
</ul>
<p>Changelog records <strong>what changed</strong>; Table Stream tracks <strong>what has been consumed</strong>. Incremental view maintenance builds on both.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="incremental-view-maintenance">Incremental view maintenance<a href="https://doris.apache.org/blog/apache-doris-5-incremental-computing/#incremental-view-maintenance" class="hash-link" aria-label="Direct link to Incremental view maintenance" title="Direct link to Incremental view maintenance">&#x200B;</a></h2>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="what-ivm-does">What IVM does<a href="https://doris.apache.org/blog/apache-doris-5-incremental-computing/#what-ivm-does" class="hash-link" aria-label="Direct link to What IVM does" title="Direct link to What IVM does">&#x200B;</a></h3>
<p>A materialized view stores the result of a SQL query. When its base tables change, the stored result needs to change too. <strong>Incremental view maintenance (IVM)</strong> computes how inserts, updates, and deletes affect that result, then applies the corresponding changes.</p>
<p>You still define the view in SQL. For supported aggregates and joins, Doris reads the changes through Changelog and Table Stream, generates an incremental plan, and maintains the result. You do not need to hand-code every change-handling rule or recompute the entire dataset on every refresh.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="how-ivm-updates-a-result">How IVM updates a result<a href="https://doris.apache.org/blog/apache-doris-5-incremental-computing/#how-ivm-updates-a-result" class="hash-link" aria-label="Direct link to How IVM updates a result" title="Direct link to How IVM updates a result">&#x200B;</a></h3>
<p><img decoding="async" loading="lazy" alt="IVM retracts an order&amp;#39;s old contribution, adds its new contribution, and commits the result with the stream position" src="https://assets-cdn.selectdb.com/site/assets/shared/13a476499e428457d40000dbbf815ee6.jpg" width="1730" height="909" class="img_ev3q"></p>
<p>For order 1, changing from <code>created, 100</code> to <code>paid, 120</code> requires removing one order and 100 from the <code>created</code> group, then adding one order and 120 to the <code>paid</code> group.</p>
<p>IVM performs three steps:</p>
<ol>
<li><strong>Read base-table changes.</strong> Doris creates internal Table Streams for participating base tables. The refresh task reads pending changes, including before and after images.</li>
<li><strong>Compute result changes.</strong> Doris derives an incremental plan from the view definition. Here, that plan retracts the old row&apos;s contribution and adds the new row&apos;s contribution.</li>
<li><strong>Commit results and progress.</strong> The materialized view update and stream positions commit in one transaction. A failure rolls both back, keeping the result consistent with consumption progress.</li>
</ol>
<p>The first refresh must establish a baseline before incremental changes can be applied. Refreshes are asynchronous, so a view can lag behind its base tables until a refresh finishes. For custom processing inside Doris, you can create and consume Table Streams directly.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="four-practical-scenarios">Four practical scenarios<a href="https://doris.apache.org/blog/apache-doris-5-incremental-computing/#four-practical-scenarios" class="hash-link" aria-label="Direct link to Four practical scenarios" title="Direct link to Four practical scenarios">&#x200B;</a></h2>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="1-keep-order-metrics-current">1. Keep order metrics current<a href="https://doris.apache.org/blog/apache-doris-5-incremental-computing/#1-keep-order-metrics-current" class="hash-link" aria-label="Direct link to 1. Keep order metrics current" title="Direct link to 1. Keep order metrics current">&#x200B;</a></h3>
<p><img decoding="async" loading="lazy" alt="An order status change subtracts a record from the created group and adds it to the paid group" src="https://assets-cdn.selectdb.com/site/assets/shared/8db31a2817b6c0a4f81fef13a8892a58.jpg" width="1730" height="909" class="img_ev3q"></p>
<p>An operations dashboard shows order counts, total amounts, and average amounts by status. Payments move orders between groups; amount corrections and deletes must also update the existing metrics. Counting only new orders would produce incorrect results.</p>
<p>For supported aggregates, IVM uses old and new Changelog values to maintain the affected groups. Teams define metrics in SQL and can reduce repeated scans of historical data.</p>
<p>First, set <code>enable_feature_changelog = true</code> and <code>enable_table_stream = true</code> in <code>fe.conf</code> on every FE. Set <code>enable_feature_changelog = true</code> in <code>be.conf</code> on the BEs for Changelog cleanup, then restart the affected nodes. See the <a href="https://doris.apache.org/docs/dev/query-acceleration/materialized-view/async-materialized-view/incremental-materialized-view/#prerequisites">IVM prerequisites</a>. Create a Unique Key orders table with Changelog and before images enabled:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DATABASE</span><span class="token plain"> incr_article_demo</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">USE</span><span class="token plain"> incr_article_demo</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">TABLE</span><span class="token plain"> orders </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    order_id </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BIGINT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    customer_id </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BIGINT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    order_status </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VARCHAR</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">16</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    amount </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DECIMAL</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">12</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">2</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">UNIQUE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">KEY</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">order_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DISTRIBUTED</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">HASH</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">order_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> BUCKETS </span><span class="token number" style="color:hsl(35, 99%, 36%)">1</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">PROPERTIES </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;replication_num&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;1&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;enable_unique_key_merge_on_write&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;changelog.enable&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;changelog.need_historical_value&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INSERT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INTO</span><span class="token plain"> orders </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VALUES</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">1</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">10</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;created&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">100.00</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">2</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">20</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;paid&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain">    </span><span class="token number" style="color:hsl(35, 99%, 36%)">200.00</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">3</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">10</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;paid&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain">    </span><span class="token number" style="color:hsl(35, 99%, 36%)">300.00</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>Create the aggregate view and run a complete refresh. <strong>Wait for that refresh to succeed before modifying the orders.</strong> Then apply the changes and request an incremental refresh:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> MATERIALIZED </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VIEW</span><span class="token plain"> orders_by_status</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">BUILD DEFERRED</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">REFRESH INCREMENTAL FALLBACK </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ON</span><span class="token plain"> MANUAL</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DISTRIBUTED</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> RANDOM BUCKETS </span><span class="token number" style="color:hsl(35, 99%, 36%)">1</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">PROPERTIES </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;replication_num&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;1&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> order_status</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">       </span><span class="token function" style="color:hsl(221, 87%, 60%)">COUNT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token operator" style="color:hsl(221, 87%, 60%)">*</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> order_count</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">       </span><span class="token function" style="color:hsl(221, 87%, 60%)">SUM</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">amount</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> total_amount</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">       </span><span class="token function" style="color:hsl(221, 87%, 60%)">AVG</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">amount</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> avg_amount</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> orders</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">GROUP</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> order_status</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">REFRESH MATERIALIZED </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VIEW</span><span class="token plain"> orders_by_status COMPLETE</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- Wait for the complete refresh to succeed before continuing.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INSERT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INTO</span><span class="token plain"> orders </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VALUES</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">1</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">10</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;paid&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">120.00</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">2</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">20</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;paid&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">180.00</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DELETE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> orders </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">WHERE</span><span class="token plain"> order_id </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">3</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INSERT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INTO</span><span class="token plain"> orders </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VALUES</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">4</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">30</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;created&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">400.00</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">REFRESH MATERIALIZED </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VIEW</span><span class="token plain"> orders_by_status INCREMENTAL FALLBACK</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p><code>FALLBACK</code> allows a refresh to use partition or complete recomputation when a change cannot be maintained incrementally. It does not make unsupported view definitions eligible for IVM.</p>
<p>After the refresh finishes, the <code>paid</code> group contains orders 1 and 2, totaling 300, and the <code>created</code> group contains only order 4. The expected values are:</p>























<table><thead><tr><th>order_status</th><th style="text-align:right">order_count</th><th style="text-align:right">total_amount</th><th style="text-align:right">avg_amount</th></tr></thead><tbody><tr><td>created</td><td style="text-align:right">1</td><td style="text-align:right">400.00</td><td style="text-align:right">400.00</td></tr><tr><td>paid</td><td style="text-align:right">2</td><td style="text-align:right">300.00</td><td style="text-align:right">150.00</td></tr></tbody></table>
<p>These metrics summarize the example&apos;s order amounts. Define gross sales, refunds, and other production metrics according to your business rules; a refund is not simply an order deletion.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="2-maintain-a-denormalized-customer-order-table">2. Maintain a denormalized customer-order table<a href="https://doris.apache.org/blog/apache-doris-5-incremental-computing/#2-maintain-a-denormalized-customer-order-table" class="hash-link" aria-label="Direct link to 2. Maintain a denormalized customer-order table" title="Direct link to 2. Maintain a denormalized customer-order table">&#x200B;</a></h3>
<p><img decoding="async" loading="lazy" alt="Changes to either orders or customers update a left-joined wide table, including corrected cities and late customer records" src="https://assets-cdn.selectdb.com/site/assets/shared/95147f3e328db994f4d559dcc675581a.jpg" width="1731" height="909" class="img_ev3q"></p>
<p>Operations and support teams often need orders joined with customer details. Processing only order-table deltas misses changes when a customer moves or when customer information arrives after an order. IVM join maintenance handles changes on both sides.</p>
<p>Continue with the orders table from the previous scenario. Create a customer table and joined view, establish the baseline, then change customer 10&apos;s city and add customer 30:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">TABLE</span><span class="token plain"> customers </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    customer_id </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BIGINT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    customer_name </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VARCHAR</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">32</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    city </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VARCHAR</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">32</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">UNIQUE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">KEY</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">customer_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DISTRIBUTED</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">HASH</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">customer_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> BUCKETS </span><span class="token number" style="color:hsl(35, 99%, 36%)">1</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">PROPERTIES </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;replication_num&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;1&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;enable_unique_key_merge_on_write&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;changelog.enable&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;changelog.need_historical_value&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INSERT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INTO</span><span class="token plain"> customers </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VALUES</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">10</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;Alice&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;Beijing&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">20</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;Bob&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain">   </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;Shanghai&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> MATERIALIZED </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VIEW</span><span class="token plain"> orders_with_customer</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">BUILD DEFERRED</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">REFRESH INCREMENTAL FALLBACK </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ON</span><span class="token plain"> MANUAL</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DISTRIBUTED</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> RANDOM BUCKETS </span><span class="token number" style="color:hsl(35, 99%, 36%)">1</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">PROPERTIES </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;replication_num&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;1&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> o</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">order_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> o</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">order_status</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> o</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">amount</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">       c</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">customer_name</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> c</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">city</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> orders o</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">LEFT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">JOIN</span><span class="token plain"> customers c </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ON</span><span class="token plain"> o</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">customer_id </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> c</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">customer_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">REFRESH MATERIALIZED </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VIEW</span><span class="token plain"> orders_with_customer COMPLETE</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- Wait for the complete refresh to succeed before continuing.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INSERT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INTO</span><span class="token plain"> customers </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VALUES</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">10</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;Alice&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;Hangzhou&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">30</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;Carol&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;Shenzhen&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">REFRESH MATERIALIZED </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VIEW</span><span class="token plain"> orders_with_customer INCREMENTAL FALLBACK</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>After refresh, order 1 shows the new city, Hangzhou, and order 4 gains the previously missing customer information. This view uses <strong>current</strong> customer attributes. A report that needs the city at order time must preserve that historical attribute in its data model.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="3-process-changes-between-warehouse-layers">3. Process changes between warehouse layers<a href="https://doris.apache.org/blog/apache-doris-5-incremental-computing/#3-process-changes-between-warehouse-layers" class="hash-link" aria-label="Direct link to 3. Process changes between warehouse layers" title="Direct link to 3. Process changes between warehouse layers">&#x200B;</a></h3>
<p><img decoding="async" loading="lazy" alt="A Table Stream collapses ODS changes with min_delta and writes net changes into a DWD table atomically with its position" src="https://assets-cdn.selectdb.com/site/assets/shared/02afc7ae7b966a17d92caf7f7c51b505.jpg" width="1730" height="909" class="img_ev3q"></p>
<p>IVM automates view maintenance for supported SQL. More customized warehouse pipelines, such as ODS-to-DWD processing, may need explicit cleansing logic, consolidation of repeated updates, and retry control. Table Stream provides a basis for those pipelines inside Doris.</p>
<p>Create a stream that includes the initial order state, then write current rows and subsequent changes into a downstream Unique Key table:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> STREAM orders_dwd_stream </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ON</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">TABLE</span><span class="token plain"> orders</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">PROPERTIES </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;type&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;min_delta&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;show_initial_rows&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">TABLE</span><span class="token plain"> dwd_orders </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    order_id </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BIGINT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    order_status </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VARCHAR</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">16</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    amount </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DECIMAL</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">12</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">2</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">UNIQUE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">KEY</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">order_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DISTRIBUTED</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">HASH</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">order_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> BUCKETS </span><span class="token number" style="color:hsl(35, 99%, 36%)">1</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">PROPERTIES </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;replication_num&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;1&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;enable_unique_key_merge_on_write&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INSERT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INTO</span><span class="token plain"> dwd_orders </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">order_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> order_status</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> amount</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> __DORIS_DELETE_SIGN__</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> order_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> order_status</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> amount</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">       </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">CASE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">WHEN</span><span class="token plain"> __DORIS_STREAM_CHANGE_TYPE_COL__ </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;DELETE&apos;</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">THEN</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">1</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ELSE</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">0</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">END</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> orders_dwd_stream</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">WHERE</span><span class="token plain"> __DORIS_STREAM_CHANGE_TYPE_COL__ </span><span class="token operator" style="color:hsl(221, 87%, 60%)">IN</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;APPEND&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;UPDATE_AFTER&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;DELETE&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>The first execution loads current orders. Repeat the <code>INSERT</code> to process later net changes. <code>UPDATE_AFTER</code> replaces the old state, while <code>DELETE</code> uses the delete marker to remove a downstream row. This state-synchronization pipeline does not write <code>UPDATE_BEFORE</code> into the target. To audit every individual change, create a separate <code>detail</code> stream and store its output in an audit table.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="4-send-doris-changes-to-other-systems-with-flink">4. Send Doris changes to other systems with Flink<a href="https://doris.apache.org/blog/apache-doris-5-incremental-computing/#4-send-doris-changes-to-other-systems-with-flink" class="hash-link" aria-label="Direct link to 4. Send Doris changes to other systems with Flink" title="Direct link to 4. Send Doris changes to other systems with Flink">&#x200B;</a></h3>
<p><img decoding="async" loading="lazy" alt="A Doris snapshot and Changelog feed a Flink source and job, which can write to databases, Kafka, or lake tables" src="https://assets-cdn.selectdb.com/site/assets/shared/b806ff499f54e0e4ef5eba0c92656afd.jpg" width="1730" height="909" class="img_ev3q"></p>
<p>Some order changes also need to reach Kafka, a data lake, or another business system. Flink Doris Connector can use a Doris table as an incremental source.</p>
<p>In the Flink SQL Client, configure the orders table as a source:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">SET</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;execution.checkpointing.interval&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;10s&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SET</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;table.exec.source.cdc-events-duplicate&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;true&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">TABLE</span><span class="token plain"> orders_from_doris </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    order_id </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BIGINT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    customer_id </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BIGINT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    order_status STRING</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    amount </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DECIMAL</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">12</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">2</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">PRIMARY</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">KEY</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">order_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">NOT</span><span class="token plain"> ENFORCED</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">WITH</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;connector&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;doris&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;fenodes&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;&lt;fe-host&gt;:8030&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;table.identifier&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;incr_article_demo.orders&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;username&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;&lt;doris-user&gt;&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;password&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;&lt;doris-password&gt;&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;source.scan.mode&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;initial&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;source.changelog.increment-type&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;detail&apos;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- Start the source, then run the following changes in a separate Doris SQL session.</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">*</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> orders_from_doris</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>After the snapshot completes, run these changes in Doris:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">INSERT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INTO</span><span class="token plain"> orders </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VALUES</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">5</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">30</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;created&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">50.00</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INSERT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INTO</span><span class="token plain"> orders </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VALUES</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token number" style="color:hsl(35, 99%, 36%)">5</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">30</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;paid&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain">    </span><span class="token number" style="color:hsl(35, 99%, 36%)">50.00</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DELETE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> orders </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">WHERE</span><span class="token plain"> order_id </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">5</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>The insert, payment update, and delete then flow into the Flink job. <code>initial</code> reads an existing snapshot before consuming later changes.</p>
<p>This example targets <strong>Doris 5.0.0+ and Flink Doris Connector 26.4.0+</strong>. Preview use requires Doris and connector builds with the Changelog interface changes. The destination sink must support updates and deletes. Recovery and delivery semantics also depend on checkpointing, log retention, deduplication, and sink behavior; source configuration alone does not establish an end-to-end guarantee.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="choosing-an-approach">Choosing an approach<a href="https://doris.apache.org/blog/apache-doris-5-incremental-computing/#choosing-an-approach" class="hash-link" aria-label="Direct link to Choosing an approach" title="Direct link to Choosing an approach">&#x200B;</a></h2>
<p><img decoding="async" loading="lazy" alt="Large datasets, small deltas, and frequent updates motivate a choice among IVM, Table Stream, and a Flink source" src="https://assets-cdn.selectdb.com/site/assets/shared/16a0f202543b77fcf475771c5edbeac5.jpg" width="1730" height="909" class="img_ev3q"></p>
<p>Incremental computation is most useful when a large stored dataset receives frequent changes. It complements full recomputation rather than eliminating the need for it.</p>

























<table><thead><tr><th>Approach</th><th>Best fit</th><th>What you control</th></tr></thead><tbody><tr><td>Table Stream</td><td>Custom in-database ETL and warehouse layers</td><td>Change consumption, transformations, and scheduling; <code>min_delta</code> can collapse intermediate updates, and tracked positions support retries</td></tr><tr><td>IVM</td><td>Supported SQL aggregates and multi-table joins</td><td>The SQL view definition; Doris manages incremental plans and internal streams, and the materialized view can also support transparent query acceleration</td></tr><tr><td>Flink Doris Connector</td><td>Sending changes to Kafka, lake tables, or other systems</td><td>The Flink pipeline and sinks consuming Changelog directly</td></tr></tbody></table>
<p><img decoding="async" loading="lazy" alt="Start with an order-metrics pilot, verify correctness and freshness, then expand to joined tables and broader pipelines" src="https://assets-cdn.selectdb.com/site/assets/shared/2540e0ff10c01a9dcaaf01bd8d862ce1.jpg" width="1731" height="909" class="img_ev3q"></p>
<p>Changelog retention defaults to one day. Size <code>changelog.ttl_seconds</code> to cover the longest expected consumer delay; a delayed consumer cannot rely on change records that have already expired. See <a href="https://doris.apache.org/docs/dev/data-operate/incremental/changelog/">Changelog</a> and <a href="https://doris.apache.org/docs/dev/data-operate/incremental/table-stream/">Table Stream</a> for supported operations and recovery guidance.</p>
<p>Start with a well-defined single-table aggregate, such as order counts by status. Verify correctness, refresh time, end-to-end visibility delay, and compute consumption before expanding to more complex pipelines. A follow-up technical article will examine Changelog storage and incremental plan generation.</p>
<p>Doris 5.0&apos;s incremental framework extends real-time ingestion to downstream results. Changelog captures changes, Table Stream manages consumption, and IVM maintains supported query results. Together, they can reduce repeated work and shorten the delay between a business update and the results that depend on it. These capabilities were announced ahead of the Doris 5.0 release; consult the project documentation and release announcements for availability.</p></div>]]></content:encoded>
            <category>Tech Sharing</category>
        </item>
        <item>
            <title><![CDATA[Apache Doris and Lance: Inside Distributed Vector Search]]></title>
            <link>https://doris.apache.org/blog/apache-doris-lance-vector-search/</link>
            <guid>https://doris.apache.org/blog/apache-doris-lance-vector-search/</guid>
            <pubDate>Thu, 15 Oct 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[A technical look at Apache Doris and Lance integration, including index-aware parallel search, filtering, caching, SQL analysis, and vector search benchmarks.]]></description>
            <content:encoded><![CDATA[<header><div class="text-center mb-4"><a class="cursor-pointer hover:no-underline" lang="en" href="https://doris.apache.org/blog/">Blog</a><span class="px-2 text-[#8592A6]">/</span><span><span class="s-tags" lang="en"><span class="s-tag">Tech Sharing</span></span></span></div><h1 lang="en" class="blog-post-title text-[2rem] leading-normal lg:!text-[2.5rem] text-center" itemprop="headline">Apache Doris and Lance: Inside Distributed Vector Search</h1><div class="blog-info text-center flex justify-center text-sm text-black"><span class="authors"><span class="s-author text-black">Wenqiang Li</span></span><time datetime="2026-10-15T00:00:00.000Z" itemprop="datePublished" class="text-black ml-4">October 15, 2026</time></div></header><div id="__blog-post-container" class="markdown" itemprop="articleBody"><p>Autonomous driving and multimodal search workloads are growing quickly. A query often needs more than the nearest vectors: it must also filter by vehicle type, time, device, or region, then join the results with business data and compute aggregates.</p>
<p>Treating vector search as a separate service adds work to that process. The application retrieves candidates, moves them into a database or analytics engine, and assembles the final result. As datasets grow, data movement and coordination across systems become more expensive.</p>
<p>Doris and Lance divide the work differently. Lance provides multimodal storage and vector and full-text indexes. Doris plans queries, executes them across the cluster, and runs the remaining SQL operations. You can query existing Lance datasets directly and combine filtering, vector search, joins, aggregation, and sorting in one SQL statement.</p>
<p>In a test using autonomous driving data, <strong>Doris + Lance completed vector search with four filters over one billion records in 2.32 seconds, compared with 25.228 seconds for Ray + pylance</strong>, a latency ratio of about 10.87&#xD7;. The test used Top-K 20,000, 95% recall, enabled caches, and no concurrent queries. The full results and their limitations appear below.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="1-architecture">1. Architecture<a href="https://doris.apache.org/blog/apache-doris-lance-vector-search/#1-architecture" class="hash-link" aria-label="Direct link to 1. Architecture" title="Direct link to 1. Architecture">&#x200B;</a></h2>
<p>A Lance dataset includes data files, version metadata, data fragments, and indexes. Doris reads that metadata to plan a query. The frontend (FE) plans the work; backends (BEs) read data and execute searches. Search results flow directly into other Doris operators for joins and aggregation.</p>
<p><img decoding="async" loading="lazy" alt="Doris FE plans access to Lance datasets, while BEs execute searches and SQL operations alongside business tables" src="https://assets-cdn.selectdb.com/site/assets/shared/1ee0d5a09ad5f70b35d2f516a0c557bb.jpg" width="1730" height="909" class="img_ev3q"></p>
<p>Doris supports two catalog options. Filesystem Catalog discovers datasets through directories; REST Catalog discovers them through a Lance Namespace service. The underlying data can reside on a local filesystem, S3-compatible object storage, or OSS. For ad hoc queries, a file table-valued function (TVF) with Lance format support can access a dataset directly.</p>
<p>Doris exposes vector search through <code>vector_search()</code> and Lance full-text search (FTS) through <code>full_text_search()</code>. Full-text search supports matching any term (Match OR), all terms (Match AND), or a phrase. Phrase queries require an index that stores token positions. In the default strict coverage mode, all fragments in the selected dataset version must have an index; fragments without an index do not automatically fall back to a flat scan. Both search functions can feed subsequent SQL analysis. Combining vector and text rankings requires explicit result-merging and scoring rules.</p>
<p>A query has three main steps:</p>
<ol>
<li><strong>Plan the work.</strong> FE reads the schema, dataset version, fragment list, and index coverage. It determines column types, projected columns, and task boundaries. Each query uses a fixed dataset version.</li>
<li><strong>Read and search.</strong> BEs call Lance through lance-c, receive Arrow data, and convert it into Doris Blocks for downstream operators.</li>
<li><strong>Analyze the results.</strong> Results can participate in joins, aggregation, sorting, and pagination, including queries against Doris internal tables or other catalogs.</li>
</ol>
<p>The application can express retrieval and analysis together instead of implementing a separate round of joins and statistics after fetching Lance results.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="2-parallel-search">2. Parallel search<a href="https://doris.apache.org/blog/apache-doris-lance-vector-search/#2-parallel-search" class="hash-link" aria-label="Direct link to 2. Parallel search" title="Direct link to 2. Parallel search">&#x200B;</a></h2>
<p>Distributed search starts with task boundaries. Poor boundaries can make tasks read the same index data repeatedly; too few tasks leave BEs underused.</p>
<p>Doris splits search work by Lance <strong>physical index segment</strong>. An index segment and a data fragment are different units: one index segment can cover multiple fragments. Doris reads their mapping before scheduling scan tasks.</p>
<p><img decoding="async" loading="lazy" alt="FE assigns physical index segments to parallel ANN tasks and unindexed fragments to flat search, then merges the global Top-K" src="https://assets-cdn.selectdb.com/site/assets/shared/f51b2b5666d395051557be0f0df2e787.jpg" width="1730" height="909" class="img_ev3q"></p>
<p>For vector search, FE finds an index matching the vector column and distance metric, then distributes its segments across BEs. Fragments in the selected version that lack index coverage get flat-search tasks, which scan the data directly. Their results join the same final merge.</p>
<p>Doris sorts the returned candidates and selects the global Top-K. Indexed data uses the index, while data outside index coverage still participates in the query. When the index uses approximate nearest neighbor (ANN) search, recall still depends on the index type and search parameters.</p>
<p>Ordinary filtered scans can also use indexes. Some equality, range, <code>IN</code>, and array-label predicates can use Lance BTree, Bitmap, or LabelList indexes. Where supported, Doris organizes scans by index segment and also scans data outside index coverage. Eligibility depends on the predicate and index type.</p>
<p>Segment size affects parallel efficiency. Enough segments let multiple BEs share the work; excessive segmentation adds scheduling, index-opening, and merge overhead. Choose a layout based on data distribution, BE count, and query concurrency.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="3-filtering-before-search">3. Filtering before search<a href="https://doris.apache.org/blog/apache-doris-lance-vector-search/#3-filtering-before-search" class="hash-link" aria-label="Direct link to 3. Filtering before search" title="Direct link to 3. Filtering before search">&#x200B;</a></h2>
<p>Parallelism helps use cluster resources, but reducing the search space can save more work. Filter placement also affects whether a query returns enough results. If you need similar records for a particular vehicle type, searching first and removing other vehicle types afterward may leave fewer than K results.</p>
<p>In <code>vector_search()</code> and <code>full_text_search()</code>, <code>filter</code> specifies the predicate and <code>prefilter</code> controls when it runs. <strong>The default is <code>prefilter=false</code>.</strong> Set <code>&quot;prefilter&quot;=&quot;true&quot;</code> explicitly to filter before selecting search candidates.</p>
<p><img decoding="async" loading="lazy" alt="Prefiltering restricts the search scope first; postfiltering and an outer WHERE can discard candidates after retrieval" src="https://assets-cdn.selectdb.com/site/assets/shared/f9bdf5dda172b452940fa9cd8e67cfdd.jpg" width="1731" height="909" class="img_ev3q"></p>
<p>This example searches within a vehicle type and region. It uses an illustrative four-dimensional vector and returns Top-20; the benchmark later in this post uses Top-K 20,000. Replace the table, columns, and values with your own, and match the vector dimensions and <code>metric</code> to the dataset and index.</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> scene_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> scene_text</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> resource_uri</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> _distance</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> vector_search</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;table&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;lance_demo.autodrive.scene_samples&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;column&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;embedding&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;query_vector&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;[0.12, 0.34, 0.56, 0.78]&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;top_k&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;20&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;metric&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;cosine&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;filter&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;vehicle_type = &apos;sedan&apos; AND region_code = &apos;zone_a&apos;&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;prefilter&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;use_index&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ORDER</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> _distance </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ASC</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> scene_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>With <code>prefilter=true</code>, Lance applies the function&apos;s filter before selecting candidates. A compatible scalar index can narrow the search; otherwise, evaluating the predicate may still require a scan. The savings depend on index availability and filter selectivity.</p>
<p>With the default <code>prefilter=false</code>, Lance selects candidates and then applies the function&apos;s <code>filter</code>. An outer SQL <code>WHERE</code> applies further filtering in Doris. Either can discard retrieved records, leaving fewer than K rows.</p>
<p>For ordinary Lance scans, Doris can push supported SQL predicates into Lance. Some join runtime filters can also become <code>IN</code> or range predicates, depending on predicate and type compatibility. With search functions, use <code>prefilter</code> explicitly to control the filtering order.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="4-reading-output-columns-on-demand">4. Reading output columns on demand<a href="https://doris.apache.org/blog/apache-doris-lance-vector-search/#4-reading-output-columns-on-demand" class="hash-link" aria-label="Direct link to 4. Reading output columns on demand" title="Direct link to 4. Reading output columns on demand">&#x200B;</a></h2>
<p>Retrieval may need only distances and a few filtering columns, while the final output includes long text, labels, and resource paths. Reading all those columns at the start makes losing candidates incur unnecessary I/O and transfer costs.</p>
<p>For eligible vector and full-text searches, Doris can separate retrieval into two reads: select the results first, then fetch the remaining output columns.</p>
<p><img decoding="async" loading="lazy" alt="Phase one carries search columns, row IDs, and scores through Top-K; phase two fetches display columns for selected rows" src="https://assets-cdn.selectdb.com/site/assets/shared/1cad335bb0510890a7028aa93f56a362.jpg" width="1731" height="909" class="img_ev3q"></p>
<p>The first read returns the data required for search, filtering, and computation, along with row IDs and distances or scores. After Doris selects the global Top-K, the second read fetches other output columns by row ID.</p>
<p>This saves reads and transfers for columns that can wait until the final result is known. It does not eliminate reads needed for search or filtering. The optimization is especially useful when the final result is small and each record carries substantial text or attributes.</p>
<p>Both reads use the same dataset version, so the retrieved row and its later-fetched contents remain consistent. Doris also supports selecting Lance snapshots by version, time, or named reference for repeatable queries. The <a href="https://doris.apache.org/blog/apache-doris-lance-lazy-materialization/">lazy materialization deep dive</a> explains the implementation.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="5-caching-and-diagnostics">5. Caching and diagnostics<a href="https://doris.apache.org/blog/apache-doris-lance-vector-search/#5-caching-and-diagnostics" class="hash-link" aria-label="Direct link to 5. Caching and diagnostics" title="Direct link to 5. Caching and diagnostics">&#x200B;</a></h2>
<p>Repeated queries often access the same indexes and files. Caching reduces repeated index loading, metadata parsing, and object storage reads.</p>
<p>Doris shares a Lance Session within each BE. Ordinary scans, vector search, full-text search, and row-ID fetches can reuse the relevant caches in that session.</p>
<p><img decoding="async" loading="lazy" alt="Scans, search, and row-ID fetches reuse one BE&amp;#39;s Lance session, with index and metadata memory caches and a local data cache" src="https://assets-cdn.selectdb.com/site/assets/shared/6c48943674ce7e6c3b9c729836083a28.jpg" width="1731" height="909" class="img_ev3q"></p>
<p>Each BE manages its own caches; BEs do not share a Lance cache pool. Cache capacity also accounts for only part of memory use. Scan tasks, prefetching, and sorting need additional memory.</p>
<p>Use <code>EXPLAIN</code>, Query Profile, and BE metrics to investigate latency. The plan shows task boundaries. Profile breaks down dataset opening, index loading, remote reads, format conversion, and second-phase column fetches. Index and metadata cache hit rates and occupancy are BE-level statistics and may include multiple queries.</p>
<p>Start by checking whether the query used an index or flat search. Then determine whether filtering, data reads, search, or output-column fetches dominate. See the <a href="https://doris.apache.org/docs/dev/lakehouse/best-practices/lance-query-profile/">Lance Query Profile reference</a> for metric definitions.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="6-sql-analysis-after-retrieval">6. SQL analysis after retrieval<a href="https://doris.apache.org/blog/apache-doris-lance-vector-search/#6-sql-analysis-after-retrieval" class="hash-link" aria-label="Direct link to 6. SQL analysis after retrieval" title="Direct link to 6. SQL analysis after retrieval">&#x200B;</a></h2>
<p>Search results can participate in SQL like a table. Doris feeds them into joins, aggregation, and sorting. For example, one statement can retrieve similar samples from Lance, join labels from a Doris internal table, and count samples by category.</p>
<p><img decoding="async" loading="lazy" alt="An embedding-driven search flows into business joins, SQL analysis, and a curated set of scenes" src="https://assets-cdn.selectdb.com/site/assets/shared/878484b6eccde4c88494fd46ad2844e1.jpg" width="1730" height="909" class="img_ev3q"></p>
<p>The following query retrieves Top-20 samples for the selected vehicle type and region, then joins <code>internal.demo.scene_labels</code> to count scene categories. It assumes that <code>scene_id</code> is unique in the Lance dataset and that the label table contains one record per <code>scene_id</code>. The four-dimensional vector and metric are illustrative and must match your actual data and index.</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">WITH</span><span class="token plain"> candidates </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> scene_id</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> vector_search</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;table&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;lance_demo.autodrive.scene_samples&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;column&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;embedding&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;query_vector&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;[0.12, 0.34, 0.56, 0.78]&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;top_k&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;20&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;metric&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;cosine&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;filter&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;vehicle_type = &apos;sedan&apos; AND region_code = &apos;zone_a&apos;&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;prefilter&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;use_index&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ORDER</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> _distance </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ASC</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> scene_id</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">LIMIT</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">20</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">COALESCE</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">l</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">scene_type</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;Uncategorized&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> scene_type</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token function" style="color:hsl(221, 87%, 60%)">COUNT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token operator" style="color:hsl(221, 87%, 60%)">*</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> sample_count</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> candidates c</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">LEFT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">JOIN</span><span class="token plain"> internal</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">demo</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">scene_labels l</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ON</span><span class="token plain"> c</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">scene_id </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> l</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">scene_id</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">GROUP</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">COALESCE</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">l</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">scene_type</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;Uncategorized&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ORDER</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> sample_count </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DESC</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> scene_type</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p><code>candidates</code> defines the search result, <code>LEFT JOIN</code> adds categories, and <code>GROUP BY</code> counts them. Missing labels and null categories appear as <code>Uncategorized</code>. The application receives the aggregate directly.</p>
<p>These counts describe the returned Top-K samples, not the entire dataset. To count the full dataset, scan and aggregate the Lance table directly. Keeping the vehicle and region predicates inside the search function restricts the scope when candidates are selected.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="7-benchmark-results">7. Benchmark results<a href="https://doris.apache.org/blog/apache-doris-lance-vector-search/#7-benchmark-results" class="hash-link" aria-label="Direct link to 7. Benchmark results" title="Direct link to 7. Benchmark results">&#x200B;</a></h2>
<p>The benchmark compares Doris + Lance with Ray + pylance on autonomous driving datasets containing 100 million, 500 million, and one billion records. It covers six query types: vector search alone and vector search with device, time, vehicle type, geographic, or four combined filters.</p>
<p><strong>All tests used Top-K 20,000, 95% recall, enabled caches, and no concurrency. Times are in seconds.</strong> Ray used four actors at 100 million records and 16 actors at 500 million and one billion. Enabled caches do not imply that every read hit a cache. The available records do not specify the hardware for either system, the Doris BE count, or the timing aggregation method. These results compare elapsed times in this test and should not be treated as a hardware-normalized benchmark.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="one-billion-records">One billion records<a href="https://doris.apache.org/blog/apache-doris-lance-vector-search/#one-billion-records" class="hash-link" aria-label="Direct link to One billion records" title="Direct link to One billion records">&#x200B;</a></h3>
<p><img decoding="async" loading="lazy" alt="Elapsed time for six vector search scenarios at one billion records, comparing Doris with Ray" src="https://assets-cdn.selectdb.com/site/assets/shared/0a538f15866665ed8a9f9a6deed8b446.png" width="1920" height="1056" class="img_ev3q"></p>















































<table><thead><tr><th>Query</th><th style="text-align:right">Doris + Lance (s)</th><th style="text-align:right">Ray + pylance (s)</th><th style="text-align:right">Latency ratio</th></tr></thead><tbody><tr><td>Vector search only</td><td style="text-align:right">0.43</td><td style="text-align:right">1.075</td><td style="text-align:right">2.50&#xD7;</td></tr><tr><td>Device filter</td><td style="text-align:right">0.54</td><td style="text-align:right">1.803</td><td style="text-align:right">3.34&#xD7;</td></tr><tr><td>Time filter</td><td style="text-align:right">0.73</td><td style="text-align:right">6.044</td><td style="text-align:right">8.28&#xD7;</td></tr><tr><td>Vehicle type filter</td><td style="text-align:right">0.53</td><td style="text-align:right">1.689</td><td style="text-align:right">3.19&#xD7;</td></tr><tr><td>Geographic filter</td><td style="text-align:right">1.19</td><td style="text-align:right">12.908</td><td style="text-align:right">10.85&#xD7;</td></tr><tr><td>Four combined filters</td><td style="text-align:right">2.32</td><td style="text-align:right">25.228</td><td style="text-align:right">10.87&#xD7;</td></tr></tbody></table>
<p>At one billion records, geographic filtering and four-filter search took 1.19 and 2.32 seconds with Doris, about 90.8% less time than Ray + pylance. Time-filtered search fell from 6.044 to 0.73 seconds, a latency ratio of about 8.28&#xD7;.</p>
<p>Index planning, prefiltering, parallel search, and on-demand column reads all contribute to this execution path. The test did not disable those optimizations individually, so it cannot isolate their contributions.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="all-test-cases">All test cases<a href="https://doris.apache.org/blog/apache-doris-lance-vector-search/#all-test-cases" class="hash-link" aria-label="Direct link to All test cases" title="Direct link to All test cases">&#x200B;</a></h3>
<p><img decoding="async" loading="lazy" alt="Heatmap of Ray-to-Doris latency ratios across six query types and three dataset sizes" src="https://assets-cdn.selectdb.com/site/assets/shared/2baf35c02ccfea7e82e8c94b6e088ebb.png" width="1760" height="1088" class="img_ev3q"></p>
<p>Each cell below lists <strong>Doris / Ray elapsed time in seconds</strong>.</p>















































<table><thead><tr><th>Query</th><th style="text-align:right">100 million records</th><th style="text-align:right">500 million records</th><th style="text-align:right">1 billion records</th></tr></thead><tbody><tr><td>Vector search only</td><td style="text-align:right">0.60 / 0.478</td><td style="text-align:right">0.47 / 0.226</td><td style="text-align:right">0.43 / 1.075</td></tr><tr><td>Device filter</td><td style="text-align:right">0.64 / 0.847</td><td style="text-align:right">0.50 / 0.594</td><td style="text-align:right">0.54 / 1.803</td></tr><tr><td>Time filter</td><td style="text-align:right">0.69 / 1.235</td><td style="text-align:right">0.64 / 2.856</td><td style="text-align:right">0.73 / 6.044</td></tr><tr><td>Vehicle type filter</td><td style="text-align:right">0.71 / 0.797</td><td style="text-align:right">0.52 / 0.583</td><td style="text-align:right">0.53 / 1.689</td></tr><tr><td>Geographic filter</td><td style="text-align:right">0.73 / 2.138</td><td style="text-align:right">1.00 / 5.955</td><td style="text-align:right">1.19 / 12.908</td></tr><tr><td>Four combined filters</td><td style="text-align:right">0.96 / 5.171</td><td style="text-align:right">1.67 / 11.927</td><td style="text-align:right">2.32 / 25.228</td></tr></tbody></table>
<p>The latency ratio is Ray + pylance time divided by Doris + Lance time; values above one favor Doris. Doris had lower elapsed time in 16 of the 18 cases. For four-filter search, the ratios were about 5.39&#xD7;, 7.14&#xD7;, and 10.87&#xD7; at 100 million, 500 million, and one billion records, respectively.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="8-availability-and-next-steps">8. Availability and next steps<a href="https://doris.apache.org/blog/apache-doris-lance-vector-search/#8-availability-and-next-steps" class="hash-link" aria-label="Direct link to 8. Availability and next steps" title="Direct link to 8. Availability and next steps">&#x200B;</a></h2>
<p>At the time of the original October 2026 article, this integration was planned for Apache Doris 4.2. The <a href="https://doris.apache.org/docs/4.x/lakehouse/catalogs/lance-catalog/">Lance Catalog documentation</a> describes its experimental status and compatibility requirements.</p>
<p>Doris integrates Lance throughout query execution: index segments distribute work across BEs, prefiltering narrows the search space, late materialization reduces output-column reads, and caches reuse indexes, metadata, and file contents. Together, these mechanisms let existing Lance datasets support retrieval and SQL analytics without an application-side data assembly step.</p>
<p>The benchmark results show the potential for large vector searches with business filters. Evaluate the gains with your own data, indexes, and deployment. For a broader application example, see <a href="https://doris.apache.org/blog/apache-doris-lance-physical-ai-analytics/">Apache Doris and Lance for Physical AI Analytics</a>.</p></div>]]></content:encoded>
            <category>Tech Sharing</category>
        </item>
        <item>
            <title><![CDATA[Apache Doris x Fluss: Unified Queries Across Stream and Lake]]></title>
            <link>https://doris.apache.org/blog/apache-doris-fluss-stream-lake-analytics/</link>
            <guid>https://doris.apache.org/blog/apache-doris-fluss-stream-lake-analytics/</guid>
            <pubDate>Thu, 08 Oct 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[How Apache Doris 5.0 reads Fluss log and primary-key tables, combines Paimon history with recent data, and manages JVM memory during Union Read.]]></description>
            <content:encoded><![CDATA[<header><div class="text-center mb-4"><a class="cursor-pointer hover:no-underline" lang="en" href="https://doris.apache.org/blog/">Blog</a><span class="px-2 text-[#8592A6]">/</span><span><span class="s-tags" lang="en"><span class="s-tag">Tech Sharing</span></span></span></div><h1 lang="en" class="blog-post-title text-[2rem] leading-normal lg:!text-[2.5rem] text-center" itemprop="headline">Apache Doris x Fluss: Unified Queries Across Stream and Lake</h1><div class="blog-info text-center flex justify-center text-sm text-black"><span class="authors"><span class="s-author text-black">Apache Doris &#xB7; Mingyu Chen</span></span><time datetime="2026-10-08T00:00:00.000Z" itemprop="datePublished" class="text-black ml-4">October 8, 2026</time></div></header><div id="__blog-post-container" class="markdown" itemprop="articleBody"><p>A campaign&apos;s conversion rate has dropped. The team needs to compare it with similar past campaigns before calling it abnormal. In a road test, a rise in human interventions means little without today&apos;s test-run count, each vehicle&apos;s current state, and records from previous weeks. Both investigations need new events and historical data in the same query.</p>
<p>Fluss keeps event logs and current state in tables. With its <a href="https://doris.apache.org/docs/dev/lakehouse/catalogs/fluss-catalog/">Fluss Catalog</a>, Apache Doris 5.0 can query those tables alongside history tiered to <a href="https://doris.apache.org/docs/dev/lakehouse/catalogs/paimon-catalog/">Paimon</a>. The read path depends on which portion of the data a query needs.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="1-how-fluss-unifies-streams-and-lakes">1. How Fluss unifies streams and lakes<a href="https://doris.apache.org/blog/apache-doris-fluss-stream-lake-analytics/#1-how-fluss-unifies-streams-and-lakes" class="hash-link" aria-label="Direct link to 1. How Fluss unifies streams and lakes" title="Direct link to 1. How Fluss unifies streams and lakes">&#x200B;</a></h2>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="keep-event-streams-and-current-state-in-tables">Keep event streams and current state in tables<a href="https://doris.apache.org/blog/apache-doris-fluss-stream-lake-analytics/#keep-event-streams-and-current-state-in-tables" class="hash-link" aria-label="Direct link to Keep event streams and current state in tables" title="Direct link to Keep event streams and current state in tables">&#x200B;</a></h3>
<p>Many real-time pipelines send events through a message queue and then copy them into a state store or analytics engine. Until the copy finishes, analysts cannot query the latest events. For a query that also needs history or current state, they must keep track of what each system holds.</p>
<p>Apache Fluss stores events in tables with schemas and feeds downstream stream consumers. In a suitable pipeline, it can handle the ingestion and distribution previously done by a separate messaging system. Analysts can query recent events without a copy job built solely for analytics. Fluss&apos;s columnar layout can also reduce I/O when a query selects only a few fields from a wide table.</p>
<p><img decoding="async" loading="lazy" alt="Fluss architecture with log and primary-key tables, a tiering service, and a Paimon lake" src="https://assets-cdn.selectdb.com/site/assets/shared/20187fc94d23eb9f3b91f2bf815b736b.jpg" width="1730" height="909" class="img_ev3q"></p>
<p>Fluss has two table types:</p>




















<table><thead><tr><th>Table type</th><th>Suitable data</th><th>Read behavior</th></tr></thead><tbody><tr><td>Log table</td><td>Append-only takeover events, trip records, and device alerts</td><td>Retains events in write order for continuous consumption and analysis</td></tr><tr><td>Primary-key table</td><td>Changing vehicle states, device configurations, and campaign rules</td><td>Maintains the current value by primary key and retains a changelog</td></tr></tbody></table>
<p>Each table has a Log layer for recent writes and a Lake layer for older data. A tiering service writes the older records to an open lake format. The readable lake snapshot records how far the data has been tiered. Doris uses that position to separate lake history from new log records.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="analyze-fluss-data-with-sql">Analyze Fluss data with SQL<a href="https://doris.apache.org/blog/apache-doris-fluss-stream-lake-analytics/#analyze-fluss-data-with-sql" class="hash-link" aria-label="Direct link to Analyze Fluss data with SQL" title="Direct link to Analyze Fluss data with SQL">&#x200B;</a></h3>
<p>Analysts still need to compare events with history, join them to current state, and inspect individual records. How unusual is a new deviation, and which devices or users account for it? Doris queries Fluss tables directly to answer those questions with SQL.</p>
<p><img decoding="async" loading="lazy" alt="Apache Doris 5.0 queries Fluss log and primary-key tables alongside Paimon history and Doris dimension tables" src="https://assets-cdn.selectdb.com/site/assets/shared/64f3acc7ba028e5912142c88502fd881.jpg" width="1730" height="909" class="img_ev3q"></p>

























<table><thead><tr><th>Scenario</th><th>Question</th><th>Data needed</th></tr></thead><tbody><tr><td>Campaign monitoring</td><td>Is a new conversion change outside the range of similar past campaigns?</td><td>Latest behavior events, historical trends, and current campaign state</td></tr><tr><td>Device and fleet analysis</td><td>Which devices have new alerts, and have similar anomalies occurred before?</td><td>Real-time events, long-term operating records, and current device states</td></tr><tr><td>Risk review</td><td>Does a new anomaly match a historical pattern?</td><td>New events, historical details, and continuously updated object states</td></tr></tbody></table>
<p>Suppose human interventions spike at one intersection during an autonomous driving road test. The team queries the last 30 minutes of events, counts the test runs through that segment, and compares the intervention rate with the same time of day over previous weeks. More interventions may simply mean more vehicles passed through. If the rate rose too, the team needs to investigate.</p>
<p>The team then checks current vehicle states, narrows down the trips and time window, and reviews the driving records.</p>
<p>Doris 5.0 queries Fluss tables through the <a href="https://doris.apache.org/docs/dev/lakehouse/catalogs/fluss-catalog/#configuring-catalog">Fluss Catalog</a>. If a table has been tiered to Paimon, the same query can read lake history and records still in the Fluss log.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="2-how-doris-reads-new-events-history-and-current-state-from-fluss">2. How Doris reads new events, history, and current state from Fluss<a href="https://doris.apache.org/blog/apache-doris-fluss-stream-lake-analytics/#2-how-doris-reads-new-events-history-and-current-state-from-fluss" class="hash-link" aria-label="Direct link to 2. How Doris reads new events, history, and current state from Fluss" title="Direct link to 2. How Doris reads new events, history, and current state from Fluss">&#x200B;</a></h2>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="21-query-newly-written-events">2.1 Query newly written events<a href="https://doris.apache.org/blog/apache-doris-fluss-stream-lake-analytics/#21-query-newly-written-events" class="hash-link" aria-label="Direct link to 2.1 Query newly written events" title="Direct link to 2.1 Query newly written events">&#x200B;</a></h3>
<p>To investigate, the road-test team filters recent intervention records by road segment, trigger, and the software version running when each event occurred. Copying the records into Doris first would slow down that initial query.</p>
<p>Fluss divides tables into Buckets for parallel reads and writes. In a partitioned table, records go to a partition and then a Bucket. Unpartitioned tables go straight to Buckets. Each Bucket has its own Offset, a position in its log.</p>
<p>Doris reads Fluss log tables through the Fluss Catalog. It can filter and aggregate those records or join them with vehicle models, test plans, and other dimensions in Doris tables. Teams may still store recurring, stable query results in Doris internal tables.</p>
<p><img decoding="async" loading="lazy" alt="Doris selects the relevant Fluss partition and fixes a read-end offset for each Bucket" src="https://assets-cdn.selectdb.com/site/assets/shared/aa2f365454800a0cceb9a4c4b71f2ea4.jpg" width="1730" height="909" class="img_ev3q"></p>
<p>Analysts can inspect Fluss databases, tables, and columns through the Catalog before they query. Fluss still owns the source tables; storing results in Doris is optional.</p>
<p>At planning time, Doris fixes the log end position for each Bucket. It stops there even if more records arrive during execution. Those records appear in a later query, so each execution has a fixed endpoint.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="22-combine-lake-history-with-new-fluss-events">2.2 Combine lake history with new Fluss events<a href="https://doris.apache.org/blog/apache-doris-fluss-stream-lake-analytics/#22-combine-lake-history-with-new-fluss-events" class="hash-link" aria-label="Direct link to 2.2 Combine lake history with new Fluss events" title="Direct link to 2.2 Combine lake history with new Fluss events">&#x200B;</a></h3>
<p>To establish a baseline, the team compares the same road segment across several weeks of morning rush hour. Recent intervention and trip events may still be in the Fluss log, outside the latest readable Paimon snapshot. Separate lake and log queries would force the team to reconcile overlap and gaps itself.</p>
<p>The tiering service writes log records to Paimon, commits a readable snapshot, and records the last tiered Offset for each Bucket. Fluss still holds records written after those positions.</p>
<p><img decoding="async" loading="lazy" alt="Union Read uses a Paimon lake snapshot and reads each Fluss Bucket from its tiering position to the query&amp;#39;s fixed end" src="https://assets-cdn.selectdb.com/site/assets/shared/d5dbeac1a59124797438fbfb2f4f67d7.jpg" width="1731" height="909" class="img_ev3q"></p>
<p>For Fluss tables with lake tiering enabled, Doris can use <a href="https://doris.apache.org/docs/dev/lakehouse/catalogs/fluss-catalog/#tiered-lake-tables-and-union-read">Union Read</a>. At query planning, Doris fixes a Paimon snapshot and the end Offset for each Bucket. Paimon supplies the history covered by the snapshot; Fluss supplies records from the tiering position to the fixed end. Analysts query one logical table. Records that arrive later appear in the next query.</p>
<p>For append-only events such as interventions, the Offset boundary helps prevent duplicate or missing reads. Analysts can inspect the lake and log separately to check tiering progress. If no readable lake snapshot exists yet, the default query can read only data still retained by Fluss. A task that needs complete history should first confirm that a snapshot is ready and check the log retention range.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="23-reconstruct-the-current-value-of-a-primary-key-table">2.3 Reconstruct the current value of a primary-key table<a href="https://doris.apache.org/blog/apache-doris-fluss-stream-lake-analytics/#23-reconstruct-the-current-value-of-a-primary-key-table" class="hash-link" aria-label="Direct link to 2.3 Reconstruct the current value of a primary-key table" title="Direct link to 2.3 Reconstruct the current value of a primary-key table">&#x200B;</a></h3>
<p>Vehicles and device configurations change state too. A vehicle might move from &quot;road testing&quot; to &quot;awaiting maintenance.&quot; Counting both changes as current would put two versions of the same vehicle in the report.</p>
<p>A primary-key table has two possible read baselines. For a Fluss-only read, Doris starts with a KV snapshot and applies the later changelog. For a tiered table using Union Read, it starts with a Paimon lake snapshot and applies the Fluss changelog after that snapshot. Union Read does not combine the KV and lake snapshots.</p>
<p><img decoding="async" loading="lazy" alt="Fluss state reads use a KV snapshot and changelog; Union Read uses a Paimon snapshot and the later changelog" src="https://assets-cdn.selectdb.com/site/assets/shared/733c18e16faa47d6dd02961139ec2108.jpg" width="1730" height="909" class="img_ev3q"></p>
<p><em>Figure 5. The two paths use a KV snapshot and a lake snapshot as their respective baselines. In Union Read, an update returns the new value and a deletion removes the primary key.</em></p>
<p>Union Read finds keys changed since the lake snapshot, filters their older lake rows, and emits the latest values from the log tail. An update replaces the old state; a deletion removes the key. Each vehicle appears once in the current-state result.</p>
<p>For road-test analysis, the event table records the software version at the time of the event. The vehicle state table shows the version running now. Those versions answer different questions.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="24-choose-the-read-range-for-the-task">2.4 Choose the read range for the task<a href="https://doris.apache.org/blog/apache-doris-fluss-stream-lake-analytics/#24-choose-the-read-range-for-the-task" class="hash-link" aria-label="Direct link to 2.4 Choose the read range for the task" title="Direct link to 2.4 Choose the read range for the task">&#x200B;</a></h3>
<p>Trend analysis needs both history and new events. A baseline report for an archived month may need only lake data. To check tiering progress, analysts need to see what remains in the log. Doris provides three entry points for Fluss tables tiered to Paimon:</p>

























<table><thead><tr><th>Query entry point</th><th>Read range</th><th>Use and limitation</th></tr></thead><tbody><tr><td>Table name</td><td>Normally uses Union Read to cover lake history and untiered changes</td><td>Suitable for combined historical and recent analysis; the default mode may change the read path when its conditions are not met</td></tr><tr><td><code>table$lake</code></td><td>Only data tiered to Paimon</td><td>Checks a historical baseline or tiering result; excludes records not yet in the lake</td></tr><tr><td><code>table$log</code></td><td>Only the Fluss log after the readable lake snapshot</td><td>Checks increments in an append-only event table; excludes lake history and does not apply to primary-key tables</td></tr></tbody></table>
<p><img decoding="async" loading="lazy" alt="The table, table$lake, and table$log entry points cover both sides, only Paimon history, and only the Fluss log tail respectively" src="https://assets-cdn.selectdb.com/site/assets/shared/4723d1a1e4a9616effe934424d507b22.jpg" width="1731" height="909" class="img_ev3q"></p>
<p><em>Figure 6. The table name covers both lake and log. <code>$lake</code> reads only the lake; <code>$log</code> reads only the append-only log after the readable lake snapshot.</em></p>
<p>When querying the table name directly, <a href="https://doris.apache.org/docs/dev/lakehouse/catalogs/fluss-catalog/#union-read-modes"><code>fluss.union_read.mode</code></a> controls how Doris chooses the read path. The <code>$lake</code> and <code>$log</code> entry points already identify a specific data segment.</p>

























<table><thead><tr><th>Mode</th><th>Behavior when querying the full table</th><th>When to use it</th></tr></thead><tbody><tr><td><code>auto</code> (default)</td><td>Uses Union Read when a readable lake snapshot exists and the other conditions are met; otherwise adjusts the read path to favor currently readable data</td><td>Everyday analysis where query availability takes priority</td></tr><tr><td><code>required</code></td><td>Must actually use the lake; errors if Union Read cannot run safely</td><td>Deployment acceptance checks that require history and increments to join as expected</td></tr><tr><td><code>disabled</code></td><td>Does not read the lake; reads only data currently available from Fluss</td><td>Temporarily isolate a lake-side problem or compare read paths</td></tr></tbody></table>
<p><code>$log</code> and <code>disabled</code> start at different positions. <code>$log</code> starts at the tiering position recorded by the lake snapshot. For log tables, <code>disabled</code> reads records still retained by Fluss; for primary-key tables, it reconstructs current state. If Fluss has removed older log segments, a <code>disabled</code> query on a log table cannot see history that exists only in the lake.</p>
<p>Several factors affect scan cost and the choice of read path:</p>
<ul>
<li>The lake side uses Doris&apos;s Paimon reader and <a href="https://doris.apache.org/docs/dev/lakehouse/data-cache/">file cache</a>. Partition filters and selecting only the necessary columns can reduce scanning and decoding. A filter on an ordinary data column gives the right result but may not reduce the data read from the source.</li>
<li>Tiering delays lengthen the primary-key changelog tail that must be merged, increasing memory use. Doris limits the number of tail records for primary-key Union Read. Above that limit, <code>auto</code> changes the read path and <code>required</code> returns an error.</li>
<li><a href="https://doris.apache.org/docs/dev/lakehouse/catalogs/fluss-catalog/#union-read-modes"><code>EXPLAIN</code></a> shows whether Union Read is used and the ranges planned for the lake and log. <a href="https://doris.apache.org/docs/dev/query-acceleration/query-profile/">Query Profile</a> shows row counts and time spent on each side. Together, they reveal whether the cost comes from scanning history, reading the log tail, or tiering progress.</li>
</ul>
<p>Teams can save the results of stable, frequently run queries in Doris internal tables when needed.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="3-performance-measurements">3. Performance measurements<a href="https://doris.apache.org/blog/apache-doris-fluss-stream-lake-analytics/#3-performance-measurements" class="hash-link" aria-label="Direct link to 3. Performance measurements" title="Direct link to 3. Performance measurements">&#x200B;</a></h2>
<p>We tested the read paths on an 18-core development machine with 48 GB of memory. Doris 5.0 ran as one FE and one BE, with the BE&apos;s default 2 GB JVM heap. Fluss 1.0.0 ran one CoordinatorServer and one TabletServer; Paimon used MinIO on the same machine. The primary-key test table had 30 million keys, 13 columns (about 210 bytes per row), and 16 Buckets. After one warm-up, we ran each query five times and report the median. Docker port forwarding limited bandwidth to both Fluss and the lake, so comparisons on this machine are more useful than the absolute times.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="31-primary-key-tables-pure-jni-reads-versus-union-read">3.1 Primary-key tables: pure JNI reads versus Union Read<a href="https://doris.apache.org/blog/apache-doris-fluss-stream-lake-analytics/#31-primary-key-tables-pure-jni-reads-versus-union-read" class="hash-link" aria-label="Direct link to 3.1 Primary-key tables: pure JNI reads versus Union Read" title="Direct link to 3.1 Primary-key tables: pure JNI reads versus Union Read">&#x200B;</a></h3>
<p><img decoding="async" loading="lazy" alt="Count and group-by timings for pure JNI reads and Union Read with lake auto-compaction" src="https://assets-cdn.selectdb.com/site/assets/shared/bdcda22ea765a85cc90f54064b6db711.jpg" width="1731" height="909" class="img_ev3q"></p>
<p>We measured three read paths:</p>
<ul>
<li>With a pure JNI read (<code>fluss.union_read.mode = &apos;disabled&apos;</code>), the BE does not read the lake. For each Bucket, it copies the full KV snapshot to local disk, scans it with RocksDB, and merges the later changelog to reconstruct current values. The BE calls the Fluss Java SDK through JNI.</li>
<li>With Union Read and lake auto-compaction, Doris uses the Paimon lake snapshot as the baseline and reads lake data with its <a href="https://doris.apache.org/docs/dev/lakehouse/catalogs/fluss-catalog/#query-performance">native Parquet reader</a>. For each Bucket with a log tail, the BE reads that tail once from Fluss through JNI and filters older lake rows by primary key. The lake table has <code>table.datalake.auto-compaction</code> enabled.</li>
<li>With Union Read but no lake auto-compaction, the logical read is the same. Overlapping lake files, however, require the Paimon Java reader through JNI to merge them. This is the default Fluss configuration.</li>
</ul>
<p>The first column counts keys updated after the lake snapshot, which determines how much Union Read must fetch from Fluss: 0, 10,000, or 100,000 keys per Bucket. Each cell gives the time in seconds for <code>COUNT(*)</code>, a grouped aggregation (count, amount sum, and average discount by category), and <code>SELECT *</code> (excluding transfer of results to the client), in that order.</p>

































<table><thead><tr><th>Keys updated after the lake snapshot</th><th>Pure JNI read</th><th>Union Read with auto-compaction</th><th>Union Read speedup (count / group by)</th><th>Union Read without auto-compaction</th></tr></thead><tbody><tr><td>0</td><td>6.04 / 6.23 / 8.07</td><td>0.34 / 1.12 / 9.27</td><td>17.8&#xD7; / 5.6&#xD7;</td><td>1.06 / 2.08 / OOM</td></tr><tr><td>160,000</td><td>6.07 / 6.11 / 6.98</td><td>0.52 / 1.28 / 9.65</td><td>11.8&#xD7; / 4.8&#xD7;</td><td>1.06 / 1.97 / OOM</td></tr><tr><td>1.6 million</td><td>6.25 / 6.73 / 7.84</td><td>1.08 / 1.73 / 10.80</td><td>5.8&#xD7; / 3.9&#xD7;</td><td>1.40 / 2.83 / OOM</td></tr></tbody></table>
<ul>
<li>For <code>SELECT *</code>, pure JNI finishes 1 to 3 seconds sooner than Union Read, but it uses an average of 9 to 10 cores (68 to 75 core-seconds). Union Read uses 1 to 2 cores (9 to 18 core-seconds). Pure JNI consumes 4 to 8 times as much CPU time. The KV snapshot is on local disk, while lake data crosses a forwarded port, which favors pure JNI in this setup.</li>
<li>Pure JNI copies each Bucket&apos;s KV snapshot to a BE temporary directory so RocksDB can open it. A query uses a sampled peak of 2.9 to 4.3 GB and releases the space afterward. Union Read does not copy the KV snapshot and does not use that BE disk space.</li>
<li>Without lake auto-compaction, a merge read can load data from several files into the <a href="https://doris.apache.org/docs/dev/lakehouse/catalogs/fluss-catalog/#be-jvm-heap-memory">BE&apos;s JVM heap</a> at once. A full-table read uses 16 scanners in parallel by default and fails with <code>OutOfMemoryError</code> on the default 2 GB heap. <code>enable_jni_heap_admission</code> prevents that failure in this test, as shown below. Enabling <code>table.datalake.auto-compaction</code> for the primary-key lake table addresses the underlying cause.</li>
</ul>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="32-be-jvm-memory-control">3.2 BE JVM Memory Control<a href="https://doris.apache.org/blog/apache-doris-fluss-stream-lake-analytics/#32-be-jvm-memory-control" class="hash-link" aria-label="Direct link to 3.2 BE JVM Memory Control" title="Direct link to 3.2 BE JVM Memory Control">&#x200B;</a></h3>
<p>We repeated the full-table read without lake auto-compaction on a BE with a 2 GB JVM heap, then enabled <code>enable_jni_heap_admission</code> and ran it again:</p>
<p><img decoding="async" loading="lazy" alt="JVM heap admission queues JNI readers to avoid running too many heap-intensive scans at once" src="https://assets-cdn.selectdb.com/site/assets/shared/1a8b81a8e220c4a31892b442eec0d230.jpg" width="1730" height="909" class="img_ev3q"></p>

























<table><thead><tr><th>Keys updated after the lake snapshot</th><th>Disabled</th><th><code>enable_jni_heap_admission</code> enabled</th></tr></thead><tbody><tr><td>0</td><td>OOM</td><td>11.8 s</td></tr><tr><td>160,000</td><td>OOM</td><td>12.2 s</td></tr><tr><td>1.6 million</td><td>OOM</td><td>13.5 s</td></tr></tbody></table>
<p><a href="https://doris.apache.org/docs/dev/lakehouse/catalogs/fluss-catalog/#jni-heap-admission"><code>enable_jni_heap_admission</code></a> is new in Doris 5.0 and defaults to off. When enabled, readers that expect heavy JVM heap use, including the merge readers in this test, declare an estimate before they start. The BE queues a new reader if admitting it would push declared usage beyond half the maximum JVM heap. Readers proceed as earlier ones finish. This prevented OOM in the test, though queueing increased elapsed time.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="4-planned-work">4. Planned work<a href="https://doris.apache.org/blog/apache-doris-fluss-stream-lake-analytics/#4-planned-work" class="hash-link" aria-label="Direct link to 4. Planned work" title="Direct link to 4. Planned work">&#x200B;</a></h2>
<p>Apache Doris 5.0.0 provides the Fluss Catalog as an experimental feature for reads and analysis. Union Read currently works with Paimon lake tables; Iceberg, Lance, and other lake formats are planned. We plan to benchmark historical scans, log-tail merging, and concurrent queries on reproducible workloads, then use those results to improve performance and resource use.</p>
<p>Today, Doris reads Fluss log and KV data through the Java SDK. Fluss 1.0 has a Rust SDK, and we plan to move these reads to it gradually. Before switching, we need to preserve the semantics of log tables, primary-key tables, and Union Read. Real workloads will show whether Rust improves data conversion, memory use, and resource control.</p></div>]]></content:encoded>
            <category>Tech Sharing</category>
        </item>
        <item>
            <title><![CDATA[Apache Doris 5.0 Variant Across Internal and Open Lakehouse Tables]]></title>
            <link>https://doris.apache.org/blog/apache-doris-variant-open-lakehouse/</link>
            <guid>https://doris.apache.org/blog/apache-doris-variant-open-lakehouse/</guid>
            <pubDate>Tue, 15 Sep 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[How Apache Doris 5.0 plans to use Variant across internal, Iceberg, and Paimon tables, with SQL examples and selection guidance.]]></description>
            <content:encoded><![CDATA[<header><div class="text-center mb-4"><a class="cursor-pointer hover:no-underline" lang="en" href="https://doris.apache.org/blog/">Blog</a><span class="px-2 text-[#8592A6]">/</span><span><span class="s-tags" lang="en"><span class="s-tag">Tech Sharing</span></span></span></div><h1 lang="en" class="blog-post-title text-[2rem] leading-normal lg:!text-[2.5rem] text-center" itemprop="headline">Apache Doris 5.0 Variant Across Internal and Open Lakehouse Tables</h1><div class="blog-info text-center flex justify-center text-sm text-black"><span class="authors"><span class="s-author text-black">Apache Doris &#xB7; Mingyu Chen</span></span><time datetime="2026-09-15T00:00:00.000Z" itemprop="datePublished" class="text-black ml-4">September 15, 2026</time></div></header><div id="__blog-post-container" class="markdown" itemprop="articleBody"><blockquote>
<p><strong>Preview: Apache Doris 5.0 multimodal lakehouse (4) | Scenario and solution</strong></p>
<p>Apache Doris introduced Variant as a column type in version 2.1 for storing semi-structured data such as JSON. Users do not need to define fields before creating a table. During ingestion, Doris automatically splits the data into typed subcolumns. This retains the flexibility of JSON ingestion while providing analytical performance close to columnar storage. Apache Doris 5.0 will extend the Variant type from internal tables to open lake formats such as Iceberg and Paimon. The same VARIANT type, SQL syntax, and execution engine will process Variant data across these formats. Using an Agent trace data pipeline as an example, this article explains the need for this capability, the business problems it addresses, and when to use Variant in internal tables or data lakes.</p>
</blockquote>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="1-agent-traces-the-divide-between-variant-producers-and-consumers">1. Agent traces: The divide between Variant producers and consumers<a href="https://doris.apache.org/blog/apache-doris-variant-open-lakehouse/#1-agent-traces-the-divide-between-variant-producers-and-consumers" class="hash-link" aria-label="Direct link to 1. Agent traces: The divide between Variant producers and consumers" title="Direct link to 1. Agent traces: The divide between Variant producers and consumers">&#x200B;</a></h2>
<p>JSON is a natural representation for an AI Agent execution trace. Protocols such as MCP and A2A use JSON-RPC, while tool-call parameters, model output, and span attributes for each step all contain nested structures. A complete trace can range from tens of KB to several MB and may be seven or eight levels deep. Tool lists and parameters also change as models evolve. Eight fields yesterday may become twelve today, so defining a stable schema in advance is often impossible.</p>
<p>Analytical systems have traditionally handled this type of data in three ways:</p>

























<table><thead><tr><th>Approach</th><th>Advantage</th><th>Cost</th></tr></thead><tbody><tr><td>Flatten data through ETL into a wide table</td><td>Fast queries</td><td>Every new upstream field requires changes to jobs and tables, followed by historical backfills</td></tr><tr><td>Store data as JSON strings or JSONB</td><td>Flexible ingestion</td><td>Every SQL query must parse the entire JSON document</td></tr><tr><td>Hard-code the structure with STRUCT or MAP</td><td>Better read performance</td><td>Still strongly typed and insufficiently flexible</td></tr></tbody></table>
<p>The Variant type addresses the trade-off between flexibility and query performance. Apache Doris has provided the Variant column type since version 2.1 for storing semi-structured data such as JSON:</p>
<ul>
<li>When creating a table, users declare a single VARIANT column without defining its fields in advance.</li>
<li>During ingestion, Doris automatically splits JSON into typed subcolumns, performs type inference and promotion, stores infrequently used fields in sparse columns, and allows indexes on subcolumns.</li>
<li>Queries access values by path and read only the relevant subcolumns instead of parsing the entire JSON document.</li>
</ul>
<p>Variant combines the ingestion flexibility of JSON with query performance close to columnar storage.</p>
<p>For Agent observability platforms, the recommended data model is:</p>
<ul>
<li>Store stable fields such as <code>trace_id</code>, <code>tool_name</code>, and latency as regular columns.</li>
<li>Store inputs, outputs, and tool parameters in a VARIANT column, allowing upstream systems to add fields without altering the table.</li>
<li>Use regular SQL with path-based value access for failure attribution, cost aggregation by tool, and effectiveness comparisons across model versions.</li>
<li>Use inverted indexes for full-text searches over text in model outputs.</li>
</ul>
<p>Later Apache Doris releases added Variant features such as Schema Template, secondary indexes at the subcolumn level, DOC mode for JSON documents hundreds of MB in size, and NestedGroup for searching nested arrays.</p>
<p>Changes in enterprise data architectures created another problem. Agent traces are produced by ingestion pipelines running on Flink or Spark. The data usually lands in Paimon first, then feeds training, evaluation, observability, and other workloads. Before version 5.0, Doris could process Variant data only in its own format. Consumers that wanted to analyze the data with Variant had to write and synchronize it to both internal tables and the lake. This duplicated storage and introduced synchronization delays and data inconsistencies.</p>
<p><img decoding="async" loading="lazy" alt="Figure 1: Dual-write divide between Agent trace producers and consumers" src="https://assets-cdn.selectdb.com/site/assets/shared/e992399f8408f2eae1a29c6de737984e.jpg" width="1200" height="630" class="img_ev3q"></p>
<p>Other Variant use cases have the same problem:</p>
<ul>
<li><strong>Event tracking:</strong> Event properties can be stored in a VARIANT column, allowing product teams to add properties without altering the table. The same event data is also a shared enterprise asset that algorithm teams need for training features. This requires another copy in Iceberg.</li>
<li><strong>IoT telemetry:</strong> Device properties vary by model and firmware. A wide table would be excessively sparse, while a VARIANT column allows one SQL query to aggregate data across device models. Complete datasets must also be retained for years, and object storage with an open format is the only way to reduce storage costs significantly. Real-time alerts and historical analysis must therefore access different systems, which fragments the user experience.</li>
</ul>
<p>Variant needs to follow the data. When data resides in the lake, Variant must be available there too, and the compute engine must support unified analysis of that Variant data.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="2-variant-standardization-bringing-semi-structured-data-into-the-one-copy-multiple-engines-model">2. Variant standardization: Bringing semi-structured data into the &quot;one copy, multiple engines&quot; model<a href="https://doris.apache.org/blog/apache-doris-variant-open-lakehouse/#2-variant-standardization-bringing-semi-structured-data-into-the-one-copy-multiple-engines-model" class="hash-link" aria-label="Direct link to 2. Variant standardization: Bringing semi-structured data into the &quot;one copy, multiple engines&quot; model" title="Direct link to 2. Variant standardization: Bringing semi-structured data into the &quot;one copy, multiple engines&quot; model">&#x200B;</a></h2>
<p>Semi-structured data in a lake traditionally had two options: storage as strings or conversion to STRUCT through ETL. As this data became more widely used, the performance and operational costs of those approaches became harder to ignore. Variant began moving toward open standardization in 2025:</p>
<ul>
<li>In March 2025, Apache Parquet 2.11 defined a binary encoding for Variant and introduced the Shredding specification. Writers can split frequently accessed fields into typed columns while retaining the remaining data in a binary value, giving the file itself a columnar shape. The specification was finalized in August of the same year.</li>
<li>In June 2025, the Apache Iceberg V3 specification was approved, making Variant a first-class table type. Apache Paimon has supported Variant and Shredding since version 1.4.</li>
<li>Spark 4.0/4.1, Flink 2.1, and DuckDB subsequently added support, while Trino began offering experimental support. Snowflake and Databricks also announced general availability of their respective support for Variant in open formats in 2026.</li>
</ul>
<p>The open lakehouse model of &quot;one copy of data shared by multiple engines&quot; is extending to semi-structured data. With a standard format, any compliant engine can read and write Variant data in a lake. We therefore decided to extend the Variant processing capabilities available for internal tables to standard Variant formats.</p>
<p><img decoding="async" loading="lazy" alt="Figure 2: Open standards allow multiple engines to share one copy of Variant data" src="https://assets-cdn.selectdb.com/site/assets/shared/388e58e15363ef5723e8bd5c5c9b3791.jpg" width="1200" height="630" class="img_ev3q"></p>
<p>An engine needs to solve three problems to use Variant effectively in a lake:</p>
<ol>
<li><strong>High-performance reads:</strong> The engine must be able to use the Shredded layout directly.</li>
<li><strong>Variant production:</strong> An engine that can read but not write Variant cannot write its analytical results back to the open lakehouse for reuse.</li>
<li><strong>Interoperability between internal and external formats:</strong> Variant should behave consistently across formats.</li>
</ol>
<p>The following sections describe the unified Variant solution planned for Apache Doris 5.0. A later article about Variant internals will explain how Doris reads the Shredded layout.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="3-doris-50-one-variant-type-one-sql-syntax-one-execution-engine">3. Doris 5.0: One Variant type, one SQL syntax, one execution engine<a href="https://doris.apache.org/blog/apache-doris-variant-open-lakehouse/#3-doris-50-one-variant-type-one-sql-syntax-one-execution-engine" class="hash-link" aria-label="Direct link to 3. Doris 5.0: One Variant type, one SQL syntax, one execution engine" title="Direct link to 3. Doris 5.0: One Variant type, one SQL syntax, one execution engine">&#x200B;</a></h2>
<p>Doris 5.0 will bring the Variant analytical capabilities of internal tables to open lake formats such as Iceberg and Paimon while keeping the user experience consistent across formats.</p>
<p><img decoding="async" loading="lazy" alt="Figure 3: Variant support in Doris 5.0" src="https://assets-cdn.selectdb.com/site/assets/shared/0e8bc81d41e3eca4d7b9d7147c35963d.jpg" width="1200" height="630" class="img_ev3q"></p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="31-three-layers-of-unification">3.1 Three layers of unification<a href="https://doris.apache.org/blog/apache-doris-variant-open-lakehouse/#31-three-layers-of-unification" class="hash-link" aria-label="Direct link to 3.1 Three layers of unification" title="Direct link to 3.1 Three layers of unification">&#x200B;</a></h3>
<ul>
<li>
<p><strong>Upper layer: Unified type and SQL syntax.</strong> Doris has one VARIANT type, with consistent SQL syntax and semantics for internal and external tables.</p>
<ul>
<li>Unified path access syntax: <code>payload[&apos;event&apos;][&apos;type&apos;]</code></li>
<li>Unified conversion logic: use <code>CAST</code> for type conversion and <code>VARIANT_TYPE</code> to inspect the actual type</li>
<li>Unified constructor: use <code>PARSE_TO_VARIANT</code> to construct values from JSON text</li>
<li>Unified nesting: ARRAY, MAP, and STRUCT support nested VARIANT values</li>
<li>Unified NULL semantics: SQL NULL is distinguished from JSON null</li>
</ul>
</li>
<li>
<p><strong>Middle layer: Unified execution operators.</strong> Data read from internal table files or Parquet files in the lake is converted into the execution engine&apos;s internal Variant column representation. The same operators then process the data, providing consistent behavior.</p>
<ul>
<li>Variant values from internal and lake tables can appear in the same SQL statement and participate in UNION, JOIN, and other operations.</li>
<li>Internal and external tables can write to each other, for example, <code>INSERT INTO LakeTable SELECT ... FROM DorisTable</code>.</li>
<li>Variant can participate directly in GROUP BY and DISTINCT, with deduplication based on logical values rather than byte representations.</li>
</ul>
</li>
<li>
<p><strong>Lower layer: Unified format access interfaces.</strong> Logical abstractions for Scan and Sink operators allow each format to implement only its own reader and writer. The Doris internal table format, for example, supports subcolumn splitting, inverted indexes, BloomFilters, real-time ingestion, and primary-key updates. Open lake formats support both Plain and Shredded layouts, with each format implementing its own write layout as described in Section 3.2. Format-specific differences remain at the lowest layer wherever possible, allowing most of the execution pipeline to be reused.</p>
</li>
</ul>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="32-capability-matrix">3.2 Capability matrix<a href="https://doris.apache.org/blog/apache-doris-variant-open-lakehouse/#32-capability-matrix" class="hash-link" aria-label="Direct link to 3.2 Capability matrix" title="Direct link to 3.2 Capability matrix">&#x200B;</a></h3>
<p>The following Variant capabilities for data lakes are planned for Doris 5.0:</p>



















































































<table><thead><tr><th>Area</th><th>Capability</th><th>Iceberg</th><th>Paimon</th></tr></thead><tbody><tr><td>Read</td><td>File layout</td><td>Plain, Shredded, and mixed within the same table</td><td>Plain, Shredded, and mixed within the same table</td></tr><tr><td>Read</td><td>Nested Variant (STRUCT / ARRAY / MAP)</td><td>Supported</td><td>Supported</td></tr><tr><td>Read</td><td>Path extraction, CAST, predicate filtering, and page-level pruning</td><td>Supported</td><td>Supported</td></tr><tr><td>Read</td><td>Existing lake-format capabilities</td><td>Time Travel, Deletion Vector, and schema evolution</td><td>Append tables and primary-key tables</td></tr><tr><td>Read</td><td>Asynchronous materialized views built on lake Variant tables</td><td>Supported</td><td>Supported</td></tr><tr><td>Write</td><td>INSERT INTO / INSERT OVERWRITE / INSERT ... SELECT</td><td>Supported (format-version 3 + Parquet)</td><td>Supported (Append tables, primary-key tables, and partitioned and bucketed tables)</td></tr><tr><td>Write</td><td>Row-level UPDATE / DELETE / MERGE INTO</td><td>Supported</td><td>Supported</td></tr><tr><td>Write</td><td>Nested Variant writes</td><td>Supported</td><td>Supported</td></tr><tr><td>Write</td><td>On-disk layout</td><td>Plain (see note below)</td><td>Written according to the Shredding Schema, specified explicitly or inferred automatically</td></tr><tr><td>Interoperability</td><td>Spark writes &#x2192; Doris reads; Doris writes &#x2192; Spark reads</td><td>Verified</td><td>Verified</td></tr><tr><td>Interoperability</td><td>Internal table &#x2194; lake table INSERT ... SELECT</td><td>Bidirectional</td><td>Bidirectional</td></tr><tr><td>Interoperability</td><td>Query internal and lake tables in the same SQL statement</td><td>Supported</td><td>Supported</td></tr></tbody></table>
<blockquote>
<p>Iceberg currently writes only the Plain layout. Reading the Shredded layout is fully supported. Shredded writes are planned for a later iteration, as described in the conclusion.</p>
</blockquote>
<blockquote>
<p>Availability: The lake Variant capabilities and SQL workflow below are planned for Doris 5.0. They describe the intended behavior rather than a currently released feature.</p>
</blockquote>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="33-example-unified-lakehouse-analysis-of-agent-traces">3.3 Example: Unified lakehouse analysis of Agent traces<a href="https://doris.apache.org/blog/apache-doris-variant-open-lakehouse/#33-example-unified-lakehouse-analysis-of-agent-traces" class="hash-link" aria-label="Direct link to 3.3 Example: Unified lakehouse analysis of Agent traces" title="Direct link to 3.3 Example: Unified lakehouse analysis of Agent traces">&#x200B;</a></h3>
<p>The following example uses an Agent observability platform.</p>
<p>First, Flink writes trace data to Paimon. Stable fields are stored as regular columns, while variable data is stored in a VARIANT column.</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token comment" style="color:hsl(230, 4%, 64%)">-- Flink writes the paimon.obs.agent_traces trace table:</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- (trace_id, tool_name, latency_ms, dt, payload VARIANT)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- 1. Analyze failures in lake tables using path extraction, type conversion, and predicates</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> tool_name</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token function" style="color:hsl(221, 87%, 60%)">COUNT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token operator" style="color:hsl(221, 87%, 60%)">*</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> failures</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> paimon</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">obs</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">agent_traces</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">WHERE</span><span class="token plain"> CAST</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">payload</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">[</span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;result&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">]</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">[</span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;status&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">]</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> STRING</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;error&apos;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  </span><span class="token operator" style="color:hsl(221, 87%, 60%)">AND</span><span class="token plain"> CAST</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">payload</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">[</span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;model&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">]</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">[</span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;version&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">]</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> STRING</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;v2&apos;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">GROUP</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> tool_name</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- 2. Load hot data into internal tables for real-time alerts and full-text search</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INSERT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INTO</span><span class="token plain"> internal</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">obs</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">agent_traces_hot</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">*</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> paimon</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">obs</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">agent_traces </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">WHERE</span><span class="token plain"> dt </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">CURRENT_DATE</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- 3. Write derived results and the VARIANT column back to the lake for other engines</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INSERT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INTO</span><span class="token plain"> paimon</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">obs</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">failed_traces</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> trace_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> tool_name</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> payload</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> internal</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">obs</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">agent_traces_hot</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">WHERE</span><span class="token plain"> CAST</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">payload</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">[</span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;result&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">]</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">[</span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;status&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">]</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> STRING</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;error&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>In this pipeline:</p>
<ul>
<li>The lake table and internal table use the same VARIANT type, so they do not require separate schemas.</li>
<li>Internal and lake tables use the same SQL query syntax.</li>
<li>Standard SQL <code>INSERT ... SELECT</code> statements handle data synchronization and write-back.</li>
</ul>
<p>The same pipeline also works for event tracking and IoT:</p>
<ul>
<li><strong>Event tracking:</strong> Events are shared as Iceberg Variant data. Spark creates features, while Doris produces reports. Both use one copy of the data and one schema-evolution process.</li>
<li><strong>IoT:</strong> The complete dataset remains in the lake for long-term retention. Hot data enters internal tables through <code>INSERT ... SELECT</code> for real-time alerting, while hot and cold data use the same data model.</li>
</ul>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="4-recommendations-for-choosing-a-variant-format">4. Recommendations for choosing a Variant format<a href="https://doris.apache.org/blog/apache-doris-variant-open-lakehouse/#4-recommendations-for-choosing-a-variant-format" class="hash-link" aria-label="Direct link to 4. Recommendations for choosing a Variant format" title="Direct link to 4. Recommendations for choosing a Variant format">&#x200B;</a></h2>
<p>The following comparison of Variant in internal and external tables can help users select a format.</p>
<p><img decoding="async" loading="lazy" alt="Figure 4: Choosing between internal Variant, lake Variant, and hot-cold collaboration" src="https://assets-cdn.selectdb.com/site/assets/shared/0f7b225317b8de6e91dea3c83f1ffdb0.jpg" width="1200" height="630" class="img_ev3q"></p>













































<table><thead><tr><th>Dimension</th><th>Variant in internal tables</th><th>Variant in the lake</th></tr></thead><tbody><tr><td>Storage and format</td><td>Doris proprietary format</td><td>Parquet Variant in Iceberg V3 or Paimon</td></tr><tr><td>Engines that can read and write</td><td>Doris</td><td>&#x2705; <strong>Any standards-compliant engine</strong></td></tr><tr><td>Query performance</td><td>&#x2705; <strong>Best performance through subcolumns and indexes</strong></td><td>Depends on the Shredding strategy; readers access subcolumns directly</td></tr><tr><td>Indexing and search</td><td>&#x2705; <strong>Inverted indexes, BloomFilter, DOC mode, and NestedGroup</strong></td><td>Parquet statistics with page-level pruning</td></tr><tr><td>Schema control</td><td>&#x2705; <strong>Schema Template, with Doris splitting subcolumns</strong></td><td>The writer&apos;s Shredding strategy</td></tr><tr><td>Ingestion latency and updates</td><td>&#x2705; <strong>Real-time ingestion and primary-key updates</strong></td><td>Batch or micro-batch commits; Iceberg row-level updates</td></tr><tr><td>Cost</td><td>Integrated or decoupled storage and compute</td><td>&#x2705; <strong>Object storage with low per-unit storage cost</strong></td></tr></tbody></table>
<p>Variant in internal tables provides more features and better read and write performance. Variant in the lake allows multiple engines to access the same data and offers lower storage costs.</p>
<p>The recommendations are:</p>





















<table><thead><tr><th>Scenario</th><th>Recommendation</th></tr></thead><tbody><tr><td>Data is primarily produced and consumed within Doris; workloads require subsecond real-time ingestion and updates, full-text search, or high-concurrency point lookups and filtering</td><td>Variant in internal tables</td></tr><tr><td>Data is an enterprise asset shared by multiple engines; ingestion is primarily batch or micro-batch; long-term retention and storage costs matter; Spark or Flink production pipelines already exist</td><td>Variant in the lake</td></tr><tr><td>Both scenarios apply</td><td>Put hot data in internal tables and retain the complete dataset in the lake; query both with one SQL statement; accelerate lake Variant tables with asynchronous materialized views; write processing results back to the lake</td></tr></tbody></table>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="5-conclusion-variant-follows-the-data">5. Conclusion: Variant follows the data<a href="https://doris.apache.org/blog/apache-doris-variant-open-lakehouse/#5-conclusion-variant-follows-the-data" class="hash-link" aria-label="Direct link to 5. Conclusion: Variant follows the data" title="Direct link to 5. Conclusion: Variant follows the data">&#x200B;</a></h2>
<p>Doris introduced Variant for internal tables in version 2.1 and plans to support open lake formats in version 5.0. Future work will strengthen Shredded writes for Variant and improve the performance of reading Variant from data lakes. These changes are intended to meet enterprise requirements for semi-structured data analysis and cover more use cases.</p>
<p>The next article, <em>Apache Doris Variant in the Lake: How Shredding Works and Performance Benchmarks</em>, will examine the implementation details of Variant and compare the performance characteristics of different formats. It will explain in more detail how Variant works and how to use it.</p></div>]]></content:encoded>
            <category>Tech Sharing</category>
        </item>
        <item>
            <title><![CDATA[Kwai Vector Search on Paimon with Apache Doris]]></title>
            <link>https://doris.apache.org/blog/kwai-paimon-vector-search-apache-doris/</link>
            <guid>https://doris.apache.org/blog/kwai-paimon-vector-search-apache-doris/</guid>
            <pubDate>Thu, 10 Sep 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[Kwai production practice with Apache Doris and Paimon vector indexes, including IVF-RQ, Top-K pushdown, test conditions, recall, and query latency.]]></description>
            <content:encoded><![CDATA[<header><div class="text-center mb-4"><a class="cursor-pointer hover:no-underline" lang="en" href="https://doris.apache.org/blog/">Blog</a><span class="px-2 text-[#8592A6]">/</span><span><span class="s-tags" lang="en"><span class="s-tag">Best Practice</span></span></span></div><h1 lang="en" class="blog-post-title text-[2rem] leading-normal lg:!text-[2.5rem] text-center" itemprop="headline">Kwai Vector Search on Paimon with Apache Doris</h1><div class="blog-info text-center flex justify-center text-sm text-black"><span class="authors"><span class="s-author text-black">Apache Doris &#xB7; Wenqiang Li; Kwai &#xB7; Junrui Li, Shiyao Yu, Fangyuan Deng</span></span><time datetime="2026-09-10T00:00:00.000Z" itemprop="datePublished" class="text-black ml-4">September 10, 2026</time></div></header><div id="__blog-post-container" class="markdown" itemprop="articleBody"><blockquote>
<p><strong>Introduction:</strong></p>
<p><strong>Kwai</strong> uses Apache Doris in production to query vector indexes directly on Apache Paimon tables. Vectors and business data remain in Paimon, while Doris SQL initiates retrieval and pushes execution down to the data lake. Existing ingestion pipelines and OLAP access patterns do not change. This article explains the indexing foundation in Paimon 2.0, the read path developed jointly by the Doris and Paimon communities, and benchmark results for tens of millions and hundreds of millions of vectors.</p>
</blockquote>
<p>As LLM and RAG applications have become more common, semantic search has become a standard data platform requirement. One common design synchronizes vectors, filter fields, and result fields into a standalone vector database. The main cost is not the initial synchronization but the ongoing maintenance. Synchronization pipelines must run continuously, which creates a data freshness window. Vectors and business fields are split across two systems, as are access control and governance. Teams also need additional safeguards to maintain consistency between the systems.</p>
<p>Kwai took a different approach. Vectors and business columns remain in Paimon tables, and the Vector Index in Paimon 2.0 handles retrieval. Doris reads indexes and data directly through Paimon Rust. It retrieves candidates and looks up rows in parallel by bucket. Users continue to write Doris SQL with the same syntax they use for Doris internal tables.</p>
<blockquote>
<p>Availability: Kwai has validated this integration in production, while the Doris 4.2 capabilities described here are scheduled for public release at the end of September.</p>
</blockquote>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="1-data-foundation-indexing-in-paimon-20">1. Data foundation: indexing in Paimon 2.0<a href="https://doris.apache.org/blog/kwai-paimon-vector-search-apache-doris/#1-data-foundation-indexing-in-paimon-20" class="hash-link" aria-label="Direct link to 1. Data foundation: indexing in Paimon 2.0" title="Direct link to 1. Data foundation: indexing in Paimon 2.0">&#x200B;</a></h2>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="11-physical-separation-of-indexes-and-data">1.1 Physical separation of indexes and data<a href="https://doris.apache.org/blog/kwai-paimon-vector-search-apache-doris/#11-physical-separation-of-indexes-and-data" class="hash-link" aria-label="Direct link to 1.1 Physical separation of indexes and data" title="Direct link to 1.1 Physical separation of indexes and data">&#x200B;</a></h3>
<p>The Vector Index in Paimon 2.0 works with ordinary Paimon tables and has two forms: the Global Vector Index for append tables and the PK Vector Index for primary-key tables. Both use the same index implementation and retrieval model, but they build indexes and retrieve matching rows differently. Kwai&apos;s business tables are primary-key tables, so the rest of this article focuses on the PK Vector Index.</p>
<p>Both forms store index files separately from data files. A Snapshot references a Data Manifest and an Index Manifest. The Index Manifest records each index file&apos;s type, field, location, and coverage. For append tables, it records the covered Row ID range. For primary-key tables, it records the covered source data files. Adding an index therefore does not require a different data layout, and the same table can still support batch processing, stream processing, and regular OLAP reads.</p>
<p>Figure 1 shows how index files relate to data files.</p>
<p><img decoding="async" loading="lazy" alt="Paimon 2.0 architecture with index files physically separated from data files. A Snapshot references the Data Manifest and Index Manifest, while index matches map back to source rows." src="https://assets-cdn.selectdb.com/site/assets/shared/213de6cb00c87ab2e55d11253a68e98c.jpg" width="1731" height="909" class="img_ev3q"></p>
<p><em>Figure 1: Index files and data files are stored separately. The same Snapshot links them through two types of Manifest. Index segments for primary-key tables are generated during compaction and record their source files.</em></p>
<p>Vector columns are declared as <code>ARRAY&lt;FLOAT&gt;</code> or fixed-length <code>VECTOR&lt;FLOAT, N&gt;</code>. For primary-key tables, table properties configure vector indexes, which are built automatically during compaction without a separate trigger. The following Spark SQL specifies the indexed column, index type, and distance metric when creating a primary-key table:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">TABLE</span><span class="token plain"> vector_items </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">item_id </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BIGINT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">embedding ARRAY</span><span class="token operator" style="color:hsl(221, 87%, 60%)">&lt;</span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FLOAT</span><span class="token operator" style="color:hsl(221, 87%, 60%)">&gt;</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">COMMENT</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;__VECTOR_FIELD;2048&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">payload STRING</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> TBLPROPERTIES </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;primary-key&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;item_id&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;bucket&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;32&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;deletion-vectors.enabled&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;true&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;pk-vector.index.columns&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;embedding&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;fields.embedding.pk-vector.index.type&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;ivf-rq&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;fields.embedding.pk-vector.distance.metric&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;l2&apos;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<ul>
<li>Spark SQL does not have a <code>VECTOR</code> type. The column comment <code>__VECTOR_FIELD;2048</code> declares <code>ARRAY&lt;FLOAT&gt;</code> as a fixed-length, 2,048-dimensional vector.</li>
<li>Build parameters such as <code>nlist</code> are passed as JSON through <code>fields.&lt;col&gt;.pk-vector.index.options</code>.</li>
<li>The reranking multiplier <code>refine_factor</code> can be set in either table properties or query options.</li>
</ul>
<p>After data is written, compaction merges files within a bucket into a level above Level 0 and generates an index segment for the vector column. A new Snapshot references the segment after it is registered in the Index Manifest. The segment records the source data files it covers, which allows matches to map back to physical row positions within those files. Newly written data does not belong to an index segment until the next compaction. Section 2.2 explains how retrieval handles this intermediate state.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="12-five-types-of-vector-indexes">1.2 Five types of vector indexes<a href="https://doris.apache.org/blog/kwai-paimon-vector-search-apache-doris/#12-five-types-of-vector-indexes" class="hash-link" aria-label="Direct link to 1.2 Five types of vector indexes" title="Direct link to 1.2 Five types of vector indexes">&#x200B;</a></h3>
<p>The Paimon 2.0 Vector Index currently supports five index implementations, each with different characteristics and trade-offs:</p>



































<table><thead><tr><th>Index</th><th>Main characteristic</th><th>Typical trade-off</th></tr></thead><tbody><tr><td>IVF-Flat</td><td>Stores the original vectors after clustering</td><td>Higher recall, but a larger index</td></tr><tr><td>IVF-PQ</td><td>Product quantization</td><td>Smaller index, but some quantization loss</td></tr><tr><td>IVF-SQ</td><td>8-bit scalar quantization of residuals</td><td>Balanced throughput, recall, and storage</td></tr><tr><td>IVF-RQ</td><td>Rotated residual quantization</td><td>Higher compression, but requires tuning around the quality inflection point</td></tr><tr><td>DiskANN</td><td>Graph search with persistently stored vectors for reranking</td><td>Suitable for local SSDs or a fully local cache</td></tr></tbody></table>
<p>The index types balance query performance, recall, index size, and build time differently. Storing hundreds of millions of 2,048-dimensional vectors at their original precision produces a correspondingly large index and increases the amount of data read from remote storage. RQ uses rotated residual quantization to achieve greater compression, though it must be tuned to meet quality targets. Kwai chose IVF-RQ as a balance between compression and recall. <strong>The measured Recall in Section 3.3 ranges from 96.0% to 99.6%.</strong></p>
<p>Figure 2 compares the five index types and shows Kwai&apos;s choice.</p>
<p><img decoding="async" loading="lazy" alt="Trade-offs among IVF-Flat, IVF-PQ, IVF-SQ, IVF-RQ, and DiskANN. Kwai chose IVF-RQ for 128 million 2,048-dimensional vectors, achieving measured Recall of 96.0% to 99.6%." src="https://assets-cdn.selectdb.com/site/assets/shared/55517edbec286a8e41a7421141fab1a5.jpg" width="1731" height="909" class="img_ev3q"></p>
<p><em>Figure 2: Each index type makes a different trade-off between index size and recall. Kwai chose IVF-RQ and used its higher compression to reduce remote reads.</em></p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="2-bringing-indexes-back-to-the-data-lake-how-doris-directly-queries-paimon-indexes">2. Bringing indexes back to the data lake: how Doris directly queries Paimon indexes<a href="https://doris.apache.org/blog/kwai-paimon-vector-search-apache-doris/#2-bringing-indexes-back-to-the-data-lake-how-doris-directly-queries-paimon-indexes" class="hash-link" aria-label="Direct link to 2. Bringing indexes back to the data lake: how Doris directly queries Paimon indexes" title="Direct link to 2. Bringing indexes back to the data lake: how Doris directly queries Paimon indexes">&#x200B;</a></h2>
<p>A compute engine needs the following capabilities to use indexes on lake data directly for retrieval:</p>
<ul>
<li>A high-performance data read path.</li>
<li>Awareness of index distribution and index coverage.</li>
<li>Optimized index access for common vector-retrieval workloads such as Top-K.</li>
</ul>
<p>Together, these capabilities allow the engine to retrieve and analyze lake data efficiently. Section 2.1 covers the read path. Section 2.2 explains index awareness and retrieval pushdown. Sections 2.3 and 2.4 describe two index-access optimizations for Top-K workloads.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="21-high-performance-reads-from-jni-to-paimon-rust">2.1 High-performance reads: from JNI to Paimon Rust<a href="https://doris.apache.org/blog/kwai-paimon-vector-search-apache-doris/#21-high-performance-reads-from-jni-to-paimon-rust" class="hash-link" aria-label="Direct link to 2.1 High-performance reads: from JNI to Paimon Rust" title="Direct link to 2.1 High-performance reads: from JNI to Paimon Rust">&#x200B;</a></h3>
<p>In earlier Doris versions, reading Paimon data in MOR (Merge-On-Read) scenarios required the Paimon Java SDK. Doris called the SDK through JNI to read and merge the data. This approach had two problems:</p>
<ul>
<li>Doris could not track and control JVM memory at query granularity. If a large query exhausted memory, Doris lacked fine-grained visibility and control over its usage.</li>
<li>MOR used substantial memory, and high concurrency could cause JVM OOM errors. Increasing the JVM heap reduced the native memory available to the BE.</li>
</ul>
<p>After testing both options, Kwai chose Paimon Rust. The official Paimon team maintains Paimon Rust and keeps its MOR and index reads in sync with the Java implementation. Tests found that Paimon Rust provided two to three times the read performance of Paimon Java and was approximately 10% slower than the native Doris reader. Most of the difference came from converting Arrow&apos;s in-memory format into Doris Blocks. Paimon Rust uses native memory, so Doris can include its consumption in the existing memory-control system and manage it together with other native memory.</p>
<p>At the code level, the Doris BE, which is the C++ execution process, calls the Paimon Rust Reader through a C ABI. Rust and C++ exchange results through the Arrow C Data Interface. Doris then converts those results into Doris Blocks and passes them to the execution layer. Because Arrow is a columnar format, C++ can consume the data produced by Rust directly by column without an intermediate row-by-row conversion.</p>
<p>Figure 3 shows this read path.</p>
<p><img decoding="async" loading="lazy" alt="Doris FE creates one scan unit per bucket. Doris BE calls the Paimon Rust Reader through a C ABI, receives Arrow data, converts it into Doris Blocks, and performs sorting and merging using tracked native memory." src="https://assets-cdn.selectdb.com/site/assets/shared/2f2dcdfeeb65a7f57878cc36829888b1.jpg" width="1731" height="909" class="img_ev3q"></p>
<p><em>Figure 3: Doris BE calls Paimon Rust through a C ABI. Paimon Rust returns results in Arrow&apos;s columnar format, which Doris converts into Blocks. Regular reads and vector retrieval use the same path.</em></p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="22-pushing-retrieval-down-to-the-data-lake">2.2 Pushing retrieval down to the data lake<a href="https://doris.apache.org/blog/kwai-paimon-vector-search-apache-doris/#22-pushing-retrieval-down-to-the-data-lake" class="hash-link" aria-label="Direct link to 2.2 Pushing retrieval down to the data lake" title="Direct link to 2.2 Pushing retrieval down to the data lake">&#x200B;</a></h3>
<p>Unlike a regular read, a vector Top-K query does not know which rows it needs before reading starts. It must identify those rows through the index first. Without the index, a vector Top-K query written as <code>ORDER BY ... LIMIT</code> becomes a full computation. Doris loads the entire vector column into BE memory, calculates distances row by row, and sorts the results. For 128 million rows with 2,048 dimensions, one query would need to transfer approximately 1 TB of vector data.</p>
<p>The query engine must push retrieval down to the index on the data lake. To do this correctly, it must account for four properties of vector indexes on Paimon primary-key tables:</p>
<ul>
<li>Indexes are organized by <code>(Partition, Bucket)</code>. A bucket is both the data-sharding unit and the indexing unit.</li>
<li>Paimon&apos;s background compaction process generates indexes, so indexes cover only compacted data. Newly written L0 files are not included in any index. Correct retrieval must merge three operations: index retrieval, exact fallback over uncovered files, and Deletion Vector mask computation.</li>
<li>An index segment is valid only when its set of covered source files still matches the bucket&apos;s current set of active files. Checking this condition requires the complete file set for the entire bucket.</li>
<li>Kwai&apos;s business tables are Paimon primary-key tables. Rows in primary-key tables can be updated and merged, so they do not have stable global Row IDs. Instead, the index stores physical coordinates: the data file and the row number within that file. Retrieval uses these physical row numbers to fetch rows from the data files.</li>
</ul>
<p>Doris uses the following index-query plan to account for these properties:</p>
<ul>
<li>The Doris FE, the Frontend responsible for query planning, enumerates scan units by bucket for the Paimon table and obtains the complete file list for each unit.</li>
<li>Doris dispatches scan units to different BE nodes. Multiple BEs process the file lists for their assigned buckets in parallel. Within each bucket, they perform retrieval, exact fallback, reranking, row lookup, and Deletion Vector application.</li>
<li>Doris&apos;s sort-and-merge operator computes the global Top-K across buckets.</li>
</ul>
<p>In this design, Paimon Rust performs vector retrieval, while Doris schedules the distributed work and merges the results.</p>
<p>Figure 4 shows whole-bucket dispatch and parallel processing by bucket.</p>
<p><img decoding="async" loading="lazy" alt="Doris FE dispatches complete buckets to BE nodes. Each BE performs index retrieval, exact fallback, and deletion masking within its bucket, while Doris merges the global Top-K across buckets." src="https://assets-cdn.selectdb.com/site/assets/shared/88f7021c9d562e780ba503a52d60eda7.jpg" width="1731" height="909" class="img_ev3q"></p>
<p><em>Figure 4: Each scan unit contains one complete bucket. The BE performs index retrieval, exact fallback, and deletion masking within that bucket. Doris then merges the Top-K across buckets.</em></p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="23-top-k-pushdown-and-index-only-scan">2.3 Top-K pushdown and index-only scan<a href="https://doris.apache.org/blog/kwai-paimon-vector-search-apache-doris/#23-top-k-pushdown-and-index-only-scan" class="hash-link" aria-label="Direct link to 2.3 Top-K pushdown and index-only scan" title="Direct link to 2.3 Top-K pushdown and index-only scan">&#x200B;</a></h3>
<p>A standard vector-retrieval SQL query sorts rows by distance and returns the first K. The Doris FE uses an optimizer rule to recognize this pattern and rewrite the execution plan:</p>
<ul>
<li>Add a retrieval-score column to the scan node.</li>
<li>Rewrite the distance expression in the original SQL as a conversion of this score, which avoids calculating the distance again.</li>
<li>Change the sort order from ascending distance to descending score.</li>
<li>When the vector column does not appear in the <code>SELECT</code> list, do not read the original vector column. This Index-Only Scan removes vector-column reads and transfers.</li>
</ul>
<p>The optimizer applies the rule when all of the following conditions hold:</p>
<ul>
<li>The distance function matches the metric configured for the index.</li>
<li>A vector index exists on the column.</li>
<li>The SQL contains no aggregation or <code>JOIN</code>.</li>
</ul>
<p>If any condition is not met, Doris uses a regular scan to preserve correct results.</p>
<p>The same rule handles queries with filters and pagination. The FE uses partition predicates for partition pruning and retains only buckets from relevant partitions. Predicates that can be converted into Paimon predicates are pushed down to Paimon Rust, which uses them to narrow the candidate set before retrieval. This provides pre-filtering. If the filter column is not indexed, the reader must scan that column. Doris functions such as <code>length(a) &gt; 1</code> cannot be pushed down, so Doris applies those predicates as post-filters to the retrieval results. For pagination, Doris combines <code>OFFSET</code> and <code>LIMIT</code> into a larger K value for pushdown, then applies the actual offset in the upper-level sort operator.</p>
<p>Users can write the same SQL they use for vector retrieval on Doris internal tables. They do not need to modify their queries to use vector indexes on Paimon tables.</p>
<p>Figure 5 shows how the optimizer identifies and rewrites the query.</p>
<p><img decoding="async" loading="lazy" alt="The optimizer rewrites eligible vector Top-K queries from distance ordering to descending score ordering. If the vector is not selected, it uses an Index-Only Scan; otherwise, or when any condition fails, it falls back to a regular scan." src="https://assets-cdn.selectdb.com/site/assets/shared/d692d345920ed30315a2e1ba55ebaf52.jpg" width="1731" height="909" class="img_ev3q"></p>
<p><em>Figure 5: A vector Top-K query that meets all three conditions is rewritten to sort by score. If the query does not select the vector column, Doris does not read it. If any condition is unmet, Doris uses a regular scan.</em></p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="24-late-materialization-for-large-top-k-queries-separating-retrieval-from-materialization">2.4 Late materialization for large Top-K queries: separating retrieval from materialization<a href="https://doris.apache.org/blog/kwai-paimon-vector-search-apache-doris/#24-late-materialization-for-large-top-k-queries-separating-retrieval-from-materialization" class="hash-link" aria-label="Direct link to 2.4 Late materialization for large Top-K queries: separating retrieval from materialization" title="Direct link to 2.4 Late materialization for large Top-K queries: separating retrieval from materialization">&#x200B;</a></h3>
<p>A typical Top-K SQL query looks like this:</p>
<div class="language-Plain language-plain codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-plain codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">select id, embedding from vec_table</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">order by l2_distance_approximate(embedding, [...])</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">limit &lt;K&gt;;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>This SQL retrieves the <code>id</code> and <code>embedding</code> columns in a single scan and then performs retrieval. When K is small, this execution method adds little overhead.</p>
<p>When K is large, the cost of a single scan grows with it. Each bucket must read all user columns for K candidate rows, although the global merge will discard most of those rows. With K = 1 million and a 2,048-dimensional vector column, each candidate row carries 8 KB of vector data (<code>2,048 &#xD7; 4</code> bytes). As more candidates are discarded, more of those reads are wasted.</p>
<p>Kwai currently rewrites these queries as self-joins. A subquery performs retrieval and returns only IDs, then joins the original table to fetch vectors for the matching rows, as shown in Section 3.2. During the join, Doris pushes the candidate ID set down to the Paimon read layer. The reader uses this set to exclude unrelated files and row groups. It then uses Parquet page-level indexes to skip unrelated pages and materializes the vector column only for matching rows. In the Section 3.3 results, returning only IDs with Top-K = 1 million takes 7.9 to 8.0 seconds, while returning vectors as well takes 65 to 76 seconds. Most of that difference comes from reading and materializing vectors for the 1 million result rows. This approach works, but it requires users to rewrite their SQL.</p>
<p>The next execution plan is still under development. It separates retrieval and materialization into three stages:</p>
<ul>
<li>Candidate stage: Each BE performs retrieval on its assigned buckets without reading user columns and produces only a candidate set.</li>
<li>Merge stage: All candidates are collected for global Top-K selection and reranking. The result is a list of rows to materialize, represented as data files and row ranges within those files. The list is grouped by data file, and matching row ranges are merged.</li>
<li>Materialization stage: Read user columns only for rows in the row list.</li>
</ul>
<p>The merge stage must run on a single node for algorithmic reasons. Reranking needs the global candidate set to calculate the correct Top-K, and grouping and merging row ranges also require the complete set. The aggregated candidate set is only on the order of megabytes, and this stage performs no hash or range repartitioning.</p>
<p>Figure 6 compares the one-pass scan with the three-stage plan.</p>
<p><img decoding="async" loading="lazy" alt="The current one-pass scan reads wide columns for K candidates in every bucket and requires a self-join. The three-stage plan under development separates candidate generation, global merging, and materialization of matching rows." src="https://assets-cdn.selectdb.com/site/assets/shared/470535138b2cf007285101e6810c508f.jpg" width="1731" height="909" class="img_ev3q"></p>
<p><em>Figure 6: A one-pass scan makes every bucket read wide columns for K candidates. The three-stage plan first produces candidates alone, then materializes matching rows after the global Top-K step.</em></p>
<p>The expected benefits are:</p>
<ul>
<li>As Top-K grows, more candidate rows are discarded, so the system can avoid more wide-column reads.</li>
<li>The materialization stage replaces the user-written self-join and removes that join from the execution plan.</li>
<li>The FE uses a cost model to choose between the two forms automatically. Users do not need to know which form it selects or change their SQL.</li>
</ul>
<p>Section 3 reports measured performance for the current one-pass form. Section 4 gives the current status of the three-stage implementation.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="3-performance-scale-and-results-in-kwais-production-environment">3. Performance: scale and results in Kwai&apos;s production environment<a href="https://doris.apache.org/blog/kwai-paimon-vector-search-apache-doris/#3-performance-scale-and-results-in-kwais-production-environment" class="hash-link" aria-label="Direct link to 3. Performance: scale and results in Kwai&apos;s production environment" title="Direct link to 3. Performance: scale and results in Kwai&apos;s production environment">&#x200B;</a></h2>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="31-deployment-and-benchmark-methodology">3.1 Deployment and benchmark methodology<a href="https://doris.apache.org/blog/kwai-paimon-vector-search-apache-doris/#31-deployment-and-benchmark-methodology" class="hash-link" aria-label="Direct link to 3.1 Deployment and benchmark methodology" title="Direct link to 3.1 Deployment and benchmark methodology">&#x200B;</a></h3>
<p>Kwai already uses Doris external tables in production to query vector indexes on Paimon tables. The deployment is configured as follows:</p>









































<table><thead><tr><th>Dimension</th><th>Choice</th></tr></thead><tbody><tr><td>Table type</td><td>Paimon primary-key table (PK Table)</td></tr><tr><td>Vector storage</td><td>Inline, in the same table as the business columns</td></tr><tr><td>Vector index</td><td>IVF-RQ</td></tr><tr><td>Vector dimensions</td><td>2,048 (real production data)</td></tr><tr><td>Read path</td><td>Paimon Rust + Doris BE</td></tr><tr><td>Storage acceleration</td><td>Remote Alluxio cache</td></tr><tr><td>Query interface</td><td>Doris SQL</td></tr><tr><td>Cluster size</td><td>64 CU</td></tr></tbody></table>
<p>The tests use the following dataset sizes:</p>























<table><thead><tr><th>Scale</th><th style="text-align:right">Rows</th><th style="text-align:right">Data volume</th><th style="text-align:right">Buckets</th></tr></thead><tbody><tr><td>Tens of millions</td><td style="text-align:right">16 million</td><td style="text-align:right">Approximately 150 GB</td><td style="text-align:right">32</td></tr><tr><td>Hundreds of millions</td><td style="text-align:right">128 million</td><td style="text-align:right">Approximately 1.1 TB</td><td style="text-align:right">256</td></tr></tbody></table>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="32-two-query-types">3.2 Two query types<a href="https://doris.apache.org/blog/kwai-paimon-vector-search-apache-doris/#32-two-query-types" class="hash-link" aria-label="Direct link to 3.2 Two query types" title="Direct link to 3.2 Two query types">&#x200B;</a></h3>
<p>The first query type returns only business identifiers. The vector index produces the Top-K directly:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">select</span><span class="token plain"> id</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">from</span><span class="token plain"> vec_table</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">order</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">by</span><span class="token plain"> l2_distance_approximate</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">embedding</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">[</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">]</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token comment" style="color:hsl(230, 4%, 64%)">/* 2,048-dimensional query vector */</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">limit</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">&lt;</span><span class="token plain">K</span><span class="token operator" style="color:hsl(221, 87%, 60%)">&gt;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"> </span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- K is 100, 10,000, or 1,000,000</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>This is a typical Index-Only Scan test case. It primarily measures the cost of retrieval itself.</p>
<p>The second query type returns both business identifiers and vectors. With the current implementation, users rewrite these queries as self-joins. A subquery retrieves the Top-K IDs, then joins the original table to fetch vectors for the matching rows:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">select</span><span class="token plain"> t1</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> embedding</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">from</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token keyword" style="color:hsl(301, 63%, 40%)">select</span><span class="token plain"> id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> embedding </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">from</span><span class="token plain"> vec_table</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> t1</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">join</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">select</span><span class="token plain"> id</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">from</span><span class="token plain"> vec_table</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">order</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">by</span><span class="token plain"> l2_distance_approximate</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">embedding</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">[</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">]</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token comment" style="color:hsl(230, 4%, 64%)">/* 2,048-dimensional query vector */</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">limit</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">&lt;</span><span class="token plain">K</span><span class="token operator" style="color:hsl(221, 87%, 60%)">&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> t2 </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">on</span><span class="token plain"> t1</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">id </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> t2</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>The &quot;Business identifier + vector&quot; column in the Section 3.3 table uses this self-join SQL. It primarily measures the cost of reading and materializing the vector column. After the three-stage plan described in Section 2.4 is implemented, users will be able to write the same query directly as:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">select</span><span class="token plain"> id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> embedding</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">from</span><span class="token plain"> vec_table</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">order</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">by</span><span class="token plain"> l2_distance_approximate</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">embedding</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">[</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">]</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token comment" style="color:hsl(230, 4%, 64%)">/* 2,048-dimensional query vector */</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">limit</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">&lt;</span><span class="token plain">K</span><span class="token operator" style="color:hsl(221, 87%, 60%)">&gt;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"> </span><span class="token comment" style="color:hsl(230, 4%, 64%)">-- K is 100, 10,000, or 1,000,000</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>The materialization stage will then replace the self-join, and the SQL will be identical to a query against a Doris internal table.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="33-measured-results-from-tens-of-millions-to-hundreds-of-millions-of-vectors">3.3 Measured results from tens of millions to hundreds of millions of vectors<a href="https://doris.apache.org/blog/kwai-paimon-vector-search-apache-doris/#33-measured-results-from-tens-of-millions-to-hundreds-of-millions-of-vectors" class="hash-link" aria-label="Direct link to 3.3 Measured results from tens of millions to hundreds of millions of vectors" title="Direct link to 3.3 Measured results from tens of millions to hundreds of millions of vectors">&#x200B;</a></h3>
<p>The following table reports query performance and recall for different parameter combinations. Both latency columns measure end-to-end latency. Queries that return only business identifiers use the first SQL statement in Section 3.2. Queries that also return vectors use the self-join SQL. The values are representative results from individual queries:</p>






















































<table><thead><tr><th style="text-align:right">Vector count</th><th style="text-align:right">Top-K</th><th style="text-align:right">Business identifier</th><th style="text-align:right">Business identifier + vector</th><th style="text-align:right">Recall</th></tr></thead><tbody><tr><td style="text-align:right">16 million</td><td style="text-align:right">100</td><td style="text-align:right">1.4 seconds</td><td style="text-align:right">2.4 seconds</td><td style="text-align:right">96.0%</td></tr><tr><td style="text-align:right">128 million</td><td style="text-align:right">100</td><td style="text-align:right">1.8 seconds</td><td style="text-align:right">2.5 seconds</td><td style="text-align:right">97.0%</td></tr><tr><td style="text-align:right">16 million</td><td style="text-align:right">10,000</td><td style="text-align:right">1.8 seconds</td><td style="text-align:right">2.3 seconds</td><td style="text-align:right">99.2%</td></tr><tr><td style="text-align:right">128 million</td><td style="text-align:right">10,000</td><td style="text-align:right">2.0 seconds</td><td style="text-align:right">4.6 seconds</td><td style="text-align:right">98.5%</td></tr><tr><td style="text-align:right">16 million</td><td style="text-align:right">1 million</td><td style="text-align:right">7.9 seconds</td><td style="text-align:right">65 seconds</td><td style="text-align:right">97.8%</td></tr><tr><td style="text-align:right">128 million</td><td style="text-align:right">1 million</td><td style="text-align:right">8.0 seconds</td><td style="text-align:right">76 seconds</td><td style="text-align:right">99.6%</td></tr></tbody></table>
<p>The table supports two conclusions:</p>
<ul>
<li>Index-retrieval latency changes little with data scale. When the row count grows from 16 million to 128 million, latency for returning only business identifiers increases by 0.4 seconds, 0.2 seconds, and 0.1 seconds across the three Top-K settings, respectively.</li>
<li>When Top-K = 1 million, vector-column materialization is the bottleneck, not retrieval.</li>
</ul>
<p>These are representative results from individual queries. The table does not cover QPS.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="34-comparing-vector-retrieval-on-paimon-tables-and-doris-internal-tables">3.4 Comparing vector retrieval on Paimon tables and Doris internal tables<a href="https://doris.apache.org/blog/kwai-paimon-vector-search-apache-doris/#34-comparing-vector-retrieval-on-paimon-tables-and-doris-internal-tables" class="hash-link" aria-label="Direct link to 3.4 Comparing vector retrieval on Paimon tables and Doris internal tables" title="Direct link to 3.4 Comparing vector retrieval on Paimon tables and Doris internal tables">&#x200B;</a></h3>
<p>Kwai also compared vector retrieval on Paimon tables with retrieval on Doris internal tables. The team loaded the same Paimon data into Doris internal tables and queried it through Doris&apos;s own vector indexes. The following table gives the results.</p>













































































































<table><thead><tr><th style="text-align:right">Vector count</th><th style="text-align:right">Top-K</th><th>Returned data</th><th style="text-align:right">Doris internal table (local cache)</th><th style="text-align:right">Paimon external table (Alluxio)</th><th style="text-align:right">External / internal</th></tr></thead><tbody><tr><td style="text-align:right">16 million</td><td style="text-align:right">100</td><td>Business identifier</td><td style="text-align:right">0.49 seconds</td><td style="text-align:right">1.4 seconds</td><td style="text-align:right">2.86&#xD7;</td></tr><tr><td style="text-align:right">16 million</td><td style="text-align:right">100</td><td>Business identifier + vector</td><td style="text-align:right">0.7 seconds</td><td style="text-align:right">2.4 seconds</td><td style="text-align:right">3.43&#xD7;</td></tr><tr><td style="text-align:right">128 million</td><td style="text-align:right">100</td><td>Business identifier</td><td style="text-align:right">0.7 seconds</td><td style="text-align:right">1.8 seconds</td><td style="text-align:right">2.57&#xD7;</td></tr><tr><td style="text-align:right">128 million</td><td style="text-align:right">100</td><td>Business identifier + vector</td><td style="text-align:right">0.8 seconds</td><td style="text-align:right">2.5 seconds</td><td style="text-align:right">3.13&#xD7;</td></tr><tr><td style="text-align:right">16 million</td><td style="text-align:right">10,000</td><td>Business identifier</td><td style="text-align:right">0.58 seconds</td><td style="text-align:right">1.8 seconds</td><td style="text-align:right">3.10&#xD7;</td></tr><tr><td style="text-align:right">16 million</td><td style="text-align:right">10,000</td><td>Business identifier + vector</td><td style="text-align:right">1.4 seconds</td><td style="text-align:right">2.3 seconds</td><td style="text-align:right">1.64&#xD7;</td></tr><tr><td style="text-align:right">128 million</td><td style="text-align:right">10,000</td><td>Business identifier</td><td style="text-align:right">0.7 seconds</td><td style="text-align:right">2.0 seconds</td><td style="text-align:right">2.86&#xD7;</td></tr><tr><td style="text-align:right">128 million</td><td style="text-align:right">10,000</td><td>Business identifier + vector</td><td style="text-align:right">1.1 seconds</td><td style="text-align:right">4.6 seconds</td><td style="text-align:right">4.18&#xD7;</td></tr><tr><td style="text-align:right">16 million</td><td style="text-align:right">1 million</td><td>Business identifier</td><td style="text-align:right">7.2 seconds</td><td style="text-align:right">7.9 seconds</td><td style="text-align:right">1.10&#xD7;</td></tr><tr><td style="text-align:right">16 million</td><td style="text-align:right">1 million</td><td>Business identifier + vector</td><td style="text-align:right">61 seconds</td><td style="text-align:right">65 seconds</td><td style="text-align:right">1.07&#xD7;</td></tr><tr><td style="text-align:right">128 million</td><td style="text-align:right">1 million</td><td>Business identifier</td><td style="text-align:right">7.2 seconds</td><td style="text-align:right">8.0 seconds</td><td style="text-align:right">1.11&#xD7;</td></tr><tr><td style="text-align:right">128 million</td><td style="text-align:right">1 million</td><td>Business identifier + vector</td><td style="text-align:right">56 seconds</td><td style="text-align:right">76 seconds</td><td style="text-align:right">1.36&#xD7;</td></tr></tbody></table>
<ul>
<li>External-table latency is 1.07 to 4.18 times internal-table latency. When the query returns only business identifiers, the absolute difference is 0.7 to 1.3 seconds.</li>
<li>At Top-K = 1 million, the difference narrows to 1.07 to 1.36 times. Most of the latency at this setting comes from row lookup and materialization. Both sides read the same amount of data, which reduces the effect of cache location.</li>
</ul>
<p>Figure 7 summarizes the results measured by Kwai.</p>
<p><img decoding="async" loading="lazy" alt="Benchmark overview for IVF-RQ with 2,048-dimensional vectors on 64 CUs. The datasets contain 16 million rows in 150 GB across 32 buckets and 128 million rows in 1.1 TB across 256 buckets. Recall is 96.0% to 99.6%; identifier-only latency is 1.4 to 2.0 seconds for Top-K from 10,000 to 100,000 and 8 seconds for Top-K 1 million; returning vectors at Top-K 1 million takes 65 to 76 seconds." src="https://assets-cdn.selectdb.com/site/assets/shared/d4a5f74486b15561b2ed59f08ee9a0b5.jpg" width="1731" height="909" class="img_ev3q"></p>
<p><em>Figure 7: Recall is 96.0% to 99.6% at both scales. Queries that return only business identifiers finish within 2.0 seconds for Top-K values up to 10,000. At Top-K = 1 million, materialization accounts for most of the latency.</em></p>
<p>Internal tables perform better, but returning only business identifiers adds just 0.7 to 1.3 seconds of query latency in absolute terms. In return, Kwai gets the following operational benefits:</p>
<ul>
<li>Better data freshness between writing data to Paimon and making it searchable.</li>
<li>Unified storage without redundant data copies.</li>
<li>No compute-resource overhead for transferring and converting data between different systems.</li>
<li>No separate access-control and governance systems to maintain.</li>
</ul>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="4-results-and-roadmap-of-joint-development-by-the-doris-and-paimon-communities">4. Results and roadmap of joint development by the Doris and Paimon communities<a href="https://doris.apache.org/blog/kwai-paimon-vector-search-apache-doris/#4-results-and-roadmap-of-joint-development-by-the-doris-and-paimon-communities" class="hash-link" aria-label="Direct link to 4. Results and roadmap of joint development by the Doris and Paimon communities" title="Direct link to 4. Results and roadmap of joint development by the Doris and Paimon communities">&#x200B;</a></h2>
<p>Kwai, the Apache Doris community, and the Apache Paimon community developed this read path together. Kwai has contributed more than 120 PRs to the Apache Paimon and Apache Paimon Rust communities. The Doris-side changes are planned for merger into the Doris community within the next two months.</p>
<p>Kwai is also working on the following changes to improve vector retrieval performance when Doris queries Paimon:</p>
<ul>
<li>Three-stage late materialization: The plan described in Section 2.4 separates candidate retrieval from vector-column materialization. At operating points such as Top-K = 1 million, the system will stop reading wide columns for candidate rows that are later discarded. Users will also no longer need to write self-joins manually.</li>
<li>Local index caching: Add local disk and memory caches within the calling process, with Doris providing consistent-hash distribution.</li>
<li>Full-text retrieval and Hybrid Search: The full-text retrieval path is already complete on the Paimon side. After the Doris-side integration is complete, users will be able to combine structured filtering, keyword matching, and semantic retrieval on the same lake table.</li>
<li>Completing retrieval semantics: Add similarity-range retrieval. Kwai has begun an internal grayscale rollout and plans to contribute the feature to the community after large-scale production validation. Retrieval parameters will also become overridable per query instead of remaining limited to table-level configuration.</li>
</ul>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="learn-more">Learn more<a href="https://doris.apache.org/blog/kwai-paimon-vector-search-apache-doris/#learn-more" class="hash-link" aria-label="Direct link to Learn more" title="Direct link to Learn more">&#x200B;</a></h2>
<p>The multimodal lakehouse capabilities for Paimon, Iceberg, Lance, and other formats have been merged into the <strong>Doris 4.2</strong> release branch. They are scheduled for official release with version 4.2 at the <strong>end of September</strong>.</p></div>]]></content:encoded>
            <category>Best Practice</category>
        </item>
        <item>
            <title><![CDATA[Apache Doris x Paimon 2.0: Closing the Agentic AI Data Loop]]></title>
            <link>https://doris.apache.org/blog/apache-doris-paimon-agentic-ai-data-loop/</link>
            <guid>https://doris.apache.org/blog/apache-doris-paimon-agentic-ai-data-loop/</guid>
            <pubDate>Wed, 09 Sep 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[A technical look at Apache Doris and Paimon 2.0 for Agentic AI, covering vector indexes, fresh business context, SQL queries, and feedback write-back.]]></description>
            <content:encoded><![CDATA[<header><div class="text-center mb-4"><a class="cursor-pointer hover:no-underline" lang="en" href="https://doris.apache.org/blog/">Blog</a><span class="px-2 text-[#8592A6]">/</span><span><span class="s-tags" lang="en"><span class="s-tag">Tech Sharing</span></span></span></div><h1 lang="en" class="blog-post-title text-[2rem] leading-normal lg:!text-[2.5rem] text-center" itemprop="headline">Apache Doris x Paimon 2.0: Closing the Agentic AI Data Loop</h1><div class="blog-info text-center flex justify-center text-sm text-black"><span class="authors"><span class="s-author text-black">Apache Doris &#xB7; Wenqiang Li</span></span><time datetime="2026-09-09T00:00:00.000Z" itemprop="datePublished" class="text-black ml-4">September 9, 2026</time></div></header><div id="__blog-post-container" class="markdown" itemprop="articleBody"><blockquote>
<p><strong>Abstract</strong></p>
<p><a href="https://doris.apache.org/blog/apache-doris-5-multimodal-lakehouse-preview/">Apache Doris 5.0 Multimodal Lakehouse Preview</a> (2) | Scenario solutions:</p>
<p>Agentic AI is moving enterprise AI beyond one-off question answering and into a continuous &quot;perceive-retrieve-analyze-act-feedback&quot; cycle. Paimon 2.0 manages changing business facts, multimodal data, and indexes in one system, while Doris uses unified SQL to connect vector retrieval, real-time analytics, and result write-back. Together, they give agents current, consistent, and verifiable business context.</p>
</blockquote>
<hr>
<p>Large models determine what an agent can understand. The data platform determines what the agent knows and can trust at a given moment, along with what it retains after taking action. Agentic AI is moving enterprise AI beyond one-off question answering and into a continuous &quot;perceive-retrieve-analyze-act-feedback&quot; cycle.</p>
<p>Agents need access to more than documents and knowledge bases. They also need current orders, inventory, device status, images, videos, vectors, model outputs, and historical results. A real request requires more than semantic retrieval. It may combine vector and full-text search with structured filtering, cross-table joins, metric computation, and permission checks. This creates two requirements for the data platform. The underlying data must support continuous updates and schema evolution in an open format. The query engine must connect multimodal retrieval, real-time analytics, and result write-back in one execution pipeline.</p>
<p>Apache Paimon 2.0 and Apache Doris address these requirements at different layers. Paimon 2.0 manages continuously changing business facts, multimodal content, model features, and indexes. Doris provides unified SQL for reads, writes, vector retrieval, relational computation, and application serving. Together, they supply agents with current, consistent, and verifiable business context.</p>
<p><img decoding="async" loading="lazy" alt="Open data loop for Agentic AI: Paimon 2.0 manages evolving data and indexes, while Doris unifies retrieval, analytics, and serving" src="https://assets-cdn.selectdb.com/site/assets/shared/d7d657a8ccc3204b8685d083c45b6b81.jpg" width="1731" height="909" class="img_ev3q"></p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="1-core-challenges-of-agentic-ai">1. Core challenges of Agentic AI<a href="https://doris.apache.org/blog/apache-doris-paimon-agentic-ai-data-loop/#1-core-challenges-of-agentic-ai" class="hash-link" aria-label="Direct link to 1. Core challenges of Agentic AI" title="Direct link to 1. Core challenges of Agentic AI">&#x200B;</a></h2>
<p>Traditional BI primarily answers, &quot;What happened in the past?&quot; Traditional RAG primarily answers, &quot;Which documents are relevant to this question?&quot; Agentic AI must answer additional questions: Does the current state permit an action? Do separate pieces of evidence support the same conclusion? What happened after similar actions in the past? How will this action become part of the context for the next request? Consider an industrial fault-diagnosis agent that receives a new defect image. Returning a few visually similar historical images is not enough.</p>
<p>The agent must also determine whether those defects came from the same equipment model and production stage. It needs to check whether sensor metrics were abnormal before or after the event, whether the equipment is currently under maintenance, whether similar problems are occurring in a cluster, and which remediation method improved the yield of subsequent batches. Requests of this kind expose four data challenges.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="11-context-continuously-growing-multimodal-data">1.1 Context: continuously growing multimodal data<a href="https://doris.apache.org/blog/apache-doris-paimon-agentic-ai-data-loop/#11-context-continuously-growing-multimodal-data" class="hash-link" aria-label="Direct link to 1.1 Context: continuously growing multimodal data" title="Direct link to 1.1 Context: continuously growing multimodal data">&#x200B;</a></h3>
<p>A business record is rarely completed in one operation. Orders, equipment records, and user states may arrive first. Images, videos, and logs appear later. Different jobs then add OCR results, captions, embeddings, model scores, and human-generated labels asynchronously. Model upgrades add new versions of features to the same data. Agents therefore need more than a static wide table. They need a data asset that can keep acquiring fields, content, features, and indexes.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="12-retrieval-produces-candidates-business-analysis-produces-answers">1.2 Retrieval produces candidates; business analysis produces answers<a href="https://doris.apache.org/blog/apache-doris-paimon-agentic-ai-data-loop/#12-retrieval-produces-candidates-business-analysis-produces-answers" class="hash-link" aria-label="Direct link to 1.2 Retrieval produces candidates; business analysis produces answers" title="Direct link to 1.2 Retrieval produces candidates; business analysis produces answers">&#x200B;</a></h3>
<p>Vector retrieval can find semantically or visually similar objects, but it cannot determine inventory, permissions, equipment status, time ranges, or business outcomes on its own. To produce context on which an agent can act, the system must combine vector or full-text retrieval with structured filtering, joins, aggregations, window computations, and business-specific ranking.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="13-agents-need-current-and-consistent-context">1.3 Agents need current and consistent context<a href="https://doris.apache.org/blog/apache-doris-paimon-agentic-ai-data-loop/#13-agents-need-current-and-consistent-context" class="hash-link" aria-label="Direct link to 1.3 Agents need current and consistent context" title="Direct link to 1.3 Agents need current and consistent context">&#x200B;</a></h3>
<p>When business facts and model features are spread across lake tables, object storage, vector databases, and search systems, each system may have different update times, versions, and deletion states. A stale index may still return a delisted product, a device under maintenance, or a withdrawn document and pass it to an agent.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="14-agent-actions-must-feed-back-into-the-data-loop">1.4 Agent actions must feed back into the data loop<a href="https://doris.apache.org/blog/apache-doris-paimon-agentic-ai-data-loop/#14-agent-actions-must-feed-back-into-the-data-loop" class="hash-link" aria-label="Direct link to 1.4 Agent actions must feed back into the data loop" title="Direct link to 1.4 Agent actions must feed back into the data loop">&#x200B;</a></h3>
<p>Agents produce classifications, summaries, risk scores, tool-call results, and processing states. Human review adds final labels. If those results remain in the application layer, the next analysis cannot use the latest feedback. The data platform must support reads and write-back while preserving transactional consistency. Agentic AI therefore needs more than a vector database. It needs a complete data pipeline in which multimodal data can evolve, indexes can expand their coverage, business facts remain current, retrieval results can be analyzed, and action results can be written back.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="2-paimon-20-continuously-evolving-the-data-required-by-agents">2. Paimon 2.0: continuously evolving the data required by agents<a href="https://doris.apache.org/blog/apache-doris-paimon-agentic-ai-data-loop/#2-paimon-20-continuously-evolving-the-data-required-by-agents" class="hash-link" aria-label="Direct link to 2. Paimon 2.0: continuously evolving the data required by agents" title="Direct link to 2. Paimon 2.0: continuously evolving the data required by agents">&#x200B;</a></h2>
<p>Paimon has traditionally used Flink to ingest database CDC and message streams continuously. It maintains real-time lake tables on object storage and supports updates, deletions, snapshots, and incremental reads. Paimon 2.0 expands that scope from &quot;continuously updated structured rows&quot; to &quot;continuously growing multimodal data assets.&quot;</p>
<ul>
<li><code>BLOB</code> stores large objects such as images, videos, and audio in separate files. Queries do not need to read the object contents when the column is not selected.</li>
<li><code>VECTOR&lt;t, n&gt;</code> provides fixed-dimension semantics and a specialized storage layout for embeddings.</li>
<li><code>VARIANT</code> stores events, model outputs, and tool-call parameters with flexible structures, while allowing frequently used fields to be extracted into typed subcolumns.</li>
<li>Data Evolution allows models to add or update only changed columns without repeatedly rewriting unchanged large objects and business fields.</li>
<li>Global Row ID aligns data files, BLOBs, vectors, indexes, and deletion states with the same logical record.</li>
<li>Global Index incorporates scalar, full-text, and vector indexes into the lake table&apos;s metadata and snapshot system.</li>
</ul>
<p>These capabilities do not force every type of data into the same file format. Each modality can use a suitable physical layout while remaining consistent with the same table, snapshot, and logical record. The system can identify newly written data and the current index coverage, then address freshness by backfilling indexes or selecting an appropriate query mode.</p>
<p>Paimon 2.0 handles how agent data is stored, updated, evolved, and indexed. It does not, by itself, perform cross-table joins, global Top-K computation, real-time metric calculation, permission checks, or high-concurrency serving. Turning this open data into context that agents can use also requires Doris&apos;s query and execution capabilities.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="3-doris-and-paimon-integration-turning-open-data-into-agent-context">3. Doris and Paimon integration: turning open data into agent context<a href="https://doris.apache.org/blog/apache-doris-paimon-agentic-ai-data-loop/#3-doris-and-paimon-integration-turning-open-data-into-agent-context" class="hash-link" aria-label="Direct link to 3. Doris and Paimon integration: turning open data into agent context" title="Direct link to 3. Doris and Paimon integration: turning open data into agent context">&#x200B;</a></h2>
<p>Doris support for Paimon 2.0 goes beyond scanning Paimon files as ordinary Parquet files. The integration connects three paths: snapshot-consistent lake-table reads, multimodal retrieval through Vector Index, and standard SQL writes to Paimon.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="31-reading-the-latest-business-facts-while-preserving-paimon-table-semantics">3.1 Reading the latest business facts while preserving Paimon table semantics<a href="https://doris.apache.org/blog/apache-doris-paimon-agentic-ai-data-loop/#31-reading-the-latest-business-facts-while-preserving-paimon-table-semantics" class="hash-link" aria-label="Direct link to 3.1 Reading the latest business facts while preserving Paimon table semantics" title="Direct link to 3.1 Reading the latest business facts while preserving Paimon table semantics">&#x200B;</a></h3>
<p>Doris discovers databases and tables through the Paimon Catalog and caches their metadata. Within one SQL statement, it binds a consistent snapshot and schema. The query planner understands manifests, Primary Key merging, Deletion Vector, incremental ranges, Time Travel, Branch, and Tag, so it does not treat Paimon Primary Key tables as ordinary file scans. Agents can retrieve a consistent business state from a specified snapshot and use incremental queries to detect changes in orders, inventory, equipment, and user states.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="32-vector-retrieval-bringing-vector-index-into-the-doris-query-plan">3.2 Vector retrieval: bringing Vector Index into the Doris query plan<a href="https://doris.apache.org/blog/apache-doris-paimon-agentic-ai-data-loop/#32-vector-retrieval-bringing-vector-index-into-the-doris-query-plan" class="hash-link" aria-label="Direct link to 3.2 Vector retrieval: bringing Vector Index into the Doris query plan" title="Direct link to 3.2 Vector retrieval: bringing Vector Index into the Doris query plan">&#x200B;</a></h3>
<p>Doris FE plans and distributes splits, while BE calls the Paimon Rust Reader through the C ABI. A vector query first reads the Vector Index, searches index shards in parallel, and merges the candidates. It then pushes the candidate range down to files, Row Groups, and Parquet Pages. The reader loads vectors, BLOB metadata, and other wide columns only after confirming matches. Results from Rust enter C++ through the Arrow C Data Interface and are converted into Doris Blocks.</p>
<p>The candidate set then enters the Doris MPP engine for scalar filtering, cross-table joins, aggregation, permission checks, reranking, and global Top-K computation. Vector retrieval is a candidate-generation stage within a distributed SQL plan, not a separate system beside Doris. Paimon Vector Index finds relevant data, while Doris determines whether that data is valid, important, and actionable in the current business context.</p>
<p>Community work and Kwai&apos;s production deployments have validated this path. Paimon external tables connect to Doris through the Rust Reader, with data scales ranging from millions to billions of records and Top-K values ranging from 100 to 1 million. Candidate pushdown and on-demand materialization limit the cost of reading wide vectors.</p>
<p><img decoding="async" loading="lazy" alt="Vector Index in the Doris query plan: Paimon retrieves and prunes candidates, while Doris performs business filtering, joins, reranking, and global Top-K" src="https://assets-cdn.selectdb.com/site/assets/shared/c8a3bd3266cb82a8f16556fefa510ab9.jpg" width="1200" height="630" class="img_ev3q"></p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="33-real-time-writes-writing-to-paimon-with-standard-sql">3.3 Real-time writes: writing to Paimon with standard SQL<a href="https://doris.apache.org/blog/apache-doris-paimon-agentic-ai-data-loop/#33-real-time-writes-writing-to-paimon-with-standard-sql" class="hash-link" aria-label="Direct link to 3.3 Real-time writes: writing to Paimon with standard SQL" title="Direct link to 3.3 Real-time writes: writing to Paimon with standard SQL">&#x200B;</a></h3>
<p>An Agentic AI data pipeline cannot stop after reading data. If aggregation results, model labels, risk scores, and human-review states produced by Doris still require separate Spark or Flink jobs for write-back, the architecture again has fragmented transactional boundaries and additional operational pipelines.</p>
<p>For Doris 4.2, the Paimon Catalog is planned to expand from read-only access to integrated read and write support, including:</p>
<ul>
<li><code>INSERT INTO ... SELECT</code> and <code>INSERT ... VALUES</code> for appending query results or application data to Paimon.</li>
<li><code>INSERT OVERWRITE</code> for overwriting non-partitioned tables or data in static or dynamic partitions.</li>
<li><code>UPDATE</code>, <code>DELETE</code>, and <code>MERGE</code> for updating business states, model labels, and human feedback in Primary Key tables.</li>
<li><code>CREATE TABLE</code> and schema evolution for adding, deleting, renaming, and changing the types of fields.</li>
<li>Variant reads and writes, allowing model results and tool-call parameters with continuously changing structures to enter open lake tables directly.</li>
</ul>
<p>Doris distributes data across BEs according to Paimon&apos;s partitioning and bucket rules, and the BEs generate files in parallel. The FE then collects Commit Messages from multiple writers and creates an atomically visible Paimon snapshot. When a failure or retry occurs, the commit coordinator handles termination, cleanup, deduplication, and idempotent recovery. This prevents partially visible data and duplicate commits. Results produced by agents can return to the same open dataset and become context for later queries and decisions.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="4-execution-framework-how-an-agent-request-completes-retrieval-analysis-and-write-back">4. Execution framework: how an agent request completes retrieval, analysis, and write-back<a href="https://doris.apache.org/blog/apache-doris-paimon-agentic-ai-data-loop/#4-execution-framework-how-an-agent-request-completes-retrieval-analysis-and-write-back" class="hash-link" aria-label="Direct link to 4. Execution framework: how an agent request completes retrieval, analysis, and write-back" title="Direct link to 4. Execution framework: how an agent request completes retrieval, analysis, and write-back">&#x200B;</a></h2>
<p><img decoding="async" loading="lazy" alt="Doris and Paimon vector-search execution flow" src="https://assets-cdn.selectdb.com/site/assets/shared/e520e72ac84152379bb686927d1f252d.jpg" width="1731" height="909" class="img_ev3q"></p>
<p>For vector retrieval in an agent request, Paimon Vector Index first narrows the candidates. Doris then performs the business analysis. After a vector query enters Doris, execution proceeds in three stages:</p>
<ol>
<li>
<p><strong>Plan the context.</strong> Doris FE parses the Vector SQL, binds the Paimon snapshot and schema used by the query, and generates parallel splits.</p>
</li>
<li>
<p><strong>Retrieve and read on demand.</strong> BE invokes Paimon Rust through the C ABI. Vector Index produces Top-K candidates, after which the reader prunes files, Row Groups, and Pages according to the candidate range and materializes only matching columns.</p>
</li>
<li>
<p><strong>Generate the business answer.</strong></p>
<ol>
<li>Arrow data is converted into Doris Blocks and enters the MPP engine for joins, filters, aggregation, reranking, and global Top-K computation. The result is then returned to the agent through SQL, an API, or a tool call.</li>
<li>When an agent or human confirmation produces new labels, states, or processing results, Doris starts another write path. Nereids generates a DML plan, data is routed to parallel writers on the BEs, and Commit Messages are returned to the FE for aggregation and atomic commit as a new Paimon snapshot. The new results then become available for the next round of incremental reads, index backfilling, and agent analysis.</li>
<li>With further native integration, Doris will directly consume Paimon Global Index Results, use Global Row IDs to read matching rows, and understand index coverage, the <code>fast</code> / <code>full</code> / <code>detail</code> freshness modes, and the Deletion Vector of the current snapshot. Manifests, index shards, vector pages, and matching data pages will also be managed separately through a tiered local cache.</li>
</ol>
</li>
</ol>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="5-production-use-kwai-brings-vector-retrieval-back-to-paimon-lake-tables">5. Production use: Kwai brings vector retrieval back to Paimon lake tables<a href="https://doris.apache.org/blog/apache-doris-paimon-agentic-ai-data-loop/#5-production-use-kwai-brings-vector-retrieval-back-to-paimon-lake-tables" class="hash-link" aria-label="Direct link to 5. Production use: Kwai brings vector retrieval back to Paimon lake tables" title="Direct link to 5. Production use: Kwai brings vector retrieval back to Paimon lake tables">&#x200B;</a></h2>
<p><img decoding="async" loading="lazy" alt="Kwai&amp;#39;s large-scale vector retrieval architecture using Apache Doris and Paimon 2.0" src="https://assets-cdn.selectdb.com/site/assets/shared/8939ddeec3e5e66f8705545fe0d337ac.jpg" width="1731" height="909" class="img_ev3q"></p>
<p>In Kwai&apos;s production environment, vectors and business data remain in Paimon, while Doris handles retrieval, row lookup, and analysis. Kwai needed to provide large-scale vector retrieval on its existing Paimon real-time lakehouse while keeping business data, vectors, permission fields, and update states consistent.</p>
<p>Copying vectors, filter fields, and return fields into a separate vector database would create a second copy of the business data and another synchronization pipeline that would need long-term maintenance. As model versions, business states, and deletion states change, the retrieval system could return stale results that no longer match the current business state.</p>
<p>Kwai chose to keep vectors and business data in Paimon Primary Key tables and connect vector retrieval to Doris external-table queries:</p>
<ol>
<li>Paimon tables store business fields and 2,048-dimensional vectors inline. An IVF-RQ Vector Index retrieves candidates, while remote Alluxio provides caching for data and index reads.</li>
<li>Users continue to use Doris SQL. Doris FE plans and distributes splits, and BE invokes the Paimon Rust Reader through the C ABI.</li>
<li>Paimon Rust executes vector retrieval in parallel and merges the candidates. Candidate ranges are pushed down to files, Row Groups, and Parquet Pages, avoiding the need to scan and decode the complete vector column in advance.</li>
<li>When only business identifiers are required, queries can skip materializing wide vectors. When vectors need to be returned, candidate identifiers are used to look up the corresponding rows, reading only matching pages and records.</li>
<li>Read results are converted into Doris Blocks through the Arrow C Data Interface and continue through MPP computations such as filtering, joins, aggregation, and Top-K.</li>
</ol>
<p>Production validation covered datasets with tens of millions and hundreds of millions of records. Public tests used 16 million and 128 million real 2,048-dimensional vectors, with Top-K values of 100, 10,000, and 1 million. Recall through the Paimon external-table path ranged from 96.0% to 99.6%. When comparing &quot;Paimon external tables with remote Alluxio caching&quot; against &quot;Doris internal tables with local caching,&quot; query latency was 1.07 to 4.18 times that of the latter. At a Top-K of 1 million, the gap narrowed to 1.07 to 1.36 times.</p>
<p>These results show that users can keep open data in Paimon and use Doris SQL for vector retrieval and business analysis, even with hundreds of millions of high-dimensional vectors and Top-K values as large as 1 million. They do not have to copy the entire dataset into Doris internal tables or another vector database first.</p>
<p>For Agentic AI, retrieval results can be joined directly with the latest business state in Paimon. Doris can then apply permission filters, compute metrics, and perform relational analysis. Agents receive similar objects together with context that matches current business facts and can be verified before the system acts on it.</p>
<blockquote>
<p>Availability: The Paimon capabilities used in these examples are in the Doris 4.2 release branch and are scheduled for public release at the end of September. Use the examples as preview syntax until that release is available.</p>
</blockquote>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="6-getting-started">6. Getting started<a href="https://doris.apache.org/blog/apache-doris-paimon-agentic-ai-data-loop/#6-getting-started" class="hash-link" aria-label="Direct link to 6. Getting started" title="Direct link to 6. Getting started">&#x200B;</a></h2>
<p>Teams already using Flink and Paimon do not need to change their existing data pipeline as a first step. They can create a Paimon Catalog in Doris:</p>
<div class="language-SQL language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> CATALOG paimon_catalog PROPERTIES </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;type&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;paimon&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;warehouse&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;s3://example-bucket/warehouse&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;s3.endpoint&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;https://object-storage.example.com&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;s3.region&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;region-id&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;s3.access_key&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;YOUR_ACCESS_KEY&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;s3.secret_key&apos;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;YOUR_SECRET_KEY&apos;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>Perform structured analysis through Doris SQL:</p>
<div class="language-SQL language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> device_model</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> defect_type</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token function" style="color:hsl(221, 87%, 60%)">COUNT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token operator" style="color:hsl(221, 87%, 60%)">*</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> defect_count</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> paimon_catalog</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">quality</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">inspection_records</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">WHERE</span><span class="token plain"> event_time </span><span class="token operator" style="color:hsl(221, 87%, 60%)">&gt;=</span><span class="token plain"> </span><span class="token function" style="color:hsl(221, 87%, 60%)">NOW</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">-</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INTERVAL</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">30</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DAY</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">GROUP</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> device_model</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> defect_type</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ORDER</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> defect_count </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DESC</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>In the community-developed vector retrieval path, express Top-K queries through Doris SQL:</p>
<div class="language-SQL language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> id</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> paimon_catalog</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">quality</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">vector_items</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ORDER</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> l2_distance_approximate</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">embedding</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">[</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">]</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">LIMIT</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">100</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>After the analysis is complete, write the aggregated results directly back to Paimon:</p>
<div class="language-SQL language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">INSERT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INTO</span><span class="token plain"> paimon_catalog</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">quality</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">daily_defect_summary</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DATE</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">event_time</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> device_model</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> defect_type</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token function" style="color:hsl(221, 87%, 60%)">COUNT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token operator" style="color:hsl(221, 87%, 60%)">*</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> paimon_catalog</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">quality</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">inspection_records</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">GROUP</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DATE</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">event_time</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> device_model</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> defect_type</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>For Primary Key tables that require continuous state corrections, use <code>MERGE</code> to incorporate human reviews or new model results:</p>
<div class="language-SQL language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">MERGE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INTO</span><span class="token plain"> paimon_catalog</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">quality</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">inspection_records </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> target</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">USING</span><span class="token plain"> review_results </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> source</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ON</span><span class="token plain"> target</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">record_id </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> source</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">record_id</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">WHEN</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">MATCHED</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">THEN</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">UPDATE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SET</span><span class="token plain"> review_status </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> source</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">review_status</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">               defect_type </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> source</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">defect_type</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">WHEN</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">NOT</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">MATCHED</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">THEN</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INSERT</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">record_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> review_status</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> defect_type</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">VALUES</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">source</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">record_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> source</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">review_status</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> source</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">defect_type</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="7-conclusion-using-business-facts-as-they-emerge">7. Conclusion: using business facts as they emerge<a href="https://doris.apache.org/blog/apache-doris-paimon-agentic-ai-data-loop/#7-conclusion-using-business-facts-as-they-emerge" class="hash-link" aria-label="Direct link to 7. Conclusion: using business facts as they emerge" title="Direct link to 7. Conclusion: using business facts as they emerge">&#x200B;</a></h2>
<p>The data problem in Agentic AI is broader than adding a vector field or deploying a vector database. The system must keep changing business facts, multimodal content, model features, retrieval indexes, and action results consistent. It must then turn that data into verifiable context when an agent needs it.</p>
<p>Paimon 2.0 provides an open foundation for storing, updating, evolving, and indexing this data. Apache Doris connects Paimon snapshot reads, Vector Index, MPP OLAP, and standard SQL writes. This allows agents to maintain a continuous &quot;perceive changes-retrieve evidence-analyze and decide-take action-write back feedback&quot; loop.</p>
<p>Doris users do not need to maintain a separate closed copy of their data for AI workloads. The data can remain in Paimon while Doris handles retrieval and analysis. Doris can then write query results and agent feedback back to the open lake tables. Paimon allows the data used by agents to evolve continuously, while Doris turns that data into current, verifiable business context on which agents can act.</p>
<p>We will publish more articles about the Apache Doris 5.0 multimodal lakehouse and open formats such as Iceberg and Paimon. The series will cover the underlying technical principles, performance evaluations, and typical deployment scenarios.</p>
<hr>
<p>Multimodal lakehouse capabilities for Iceberg, Paimon, Lance, and other formats have now been merged into the Doris 4.2 release branch and are scheduled for official release with version 4.2 at the end of September.</p></div>]]></content:encoded>
            <category>Tech Sharing</category>
        </item>
        <item>
            <title><![CDATA[Apache Doris x Lance for Autonomous Driving and Robotics Analytics]]></title>
            <link>https://doris.apache.org/blog/apache-doris-lance-physical-ai-analytics/</link>
            <guid>https://doris.apache.org/blog/apache-doris-lance-physical-ai-analytics/</guid>
            <pubDate>Tue, 08 Sep 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[How Apache Doris and Lance support hard-case mining for autonomous driving and failure analysis for robotics with open multimodal datasets.]]></description>
            <content:encoded><![CDATA[<header><div class="text-center mb-4"><a class="cursor-pointer hover:no-underline" lang="en" href="https://doris.apache.org/blog/">Blog</a><span class="px-2 text-[#8592A6]">/</span><span><span class="s-tags" lang="en"><span class="s-tag">Tech Sharing</span></span></span></div><h1 lang="en" class="blog-post-title text-[2rem] leading-normal lg:!text-[2.5rem] text-center" itemprop="headline">Apache Doris x Lance for Autonomous Driving and Robotics Analytics</h1><div class="blog-info text-center flex justify-center text-sm text-black"><span class="authors"><span class="s-author text-black">Apache Doris &#xB7; Wenqiang Li</span></span><time datetime="2026-09-08T00:00:00.000Z" itemprop="datePublished" class="text-black ml-4">September 8, 2026</time></div></header><div id="__blog-post-container" class="markdown" itemprop="articleBody"><blockquote>
<p><strong>Abstract:</strong></p>
<p>Apache Doris 5.0 Multimodal Lakehouse Preview (1) | Scenario solutions: Autonomous vehicles and embodied intelligence systems generate massive volumes of multimodal data every day. The practical problem is finding high-value episodes quickly and identifying the scenarios, versions, and tasks associated with failures. This article explains how Apache Doris and Lance combine semantic search, structured filtering, and OLAP analytics for hard-case mining, failure attribution, and closed-loop training and evaluation on an open data architecture.</p>
</blockquote>
<p>Autonomous vehicles generate video, point clouds, vehicle states, and model outputs every day. Each robot task also produces multiple camera streams, joint states, action trajectories, language instructions, and execution results. Storing this data is only part of the problem. Teams must also answer the questions that determine how efficiently they can iterate on their models:</p>
<ul>
<li>Which segments contain scenarios similar to the current accident?</li>
<li>Has the intervention rate of the new model increased at night, in construction zones, or around irregularly shaped obstacles?</li>
<li>Which types of robot tasks are most likely to fail, and what similar visual or action patterns appear before failure?</li>
<li>How can selected high-value episodes be passed to annotation, training, and regression evaluation?</li>
</ul>
<p>Traditional data warehouses handle structured aggregation well. Vector databases specialize in image similarity search, while object storage holds large numbers of files at low cost. Physical AI needs these capabilities to work together, so semantic search, structured filtering, business metrics, and raw evidence can be used in the same analytical workflow.</p>
<p>Apache Doris support for Lance Catalog provides that connection. Lance stores open multimodal datasets and vector indexes designed for AI. Doris queries the data directly and performs predicate pushdown, parallel scans, vector retrieval, global Top-K selection, and OLAP aggregation within a single SQL execution framework. Teams do not need to copy the data into a dedicated analytical replica first, and their AI data assets remain available to more than one compute system.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="1-why-physical-ai-needs-semantic-search-and-analytics-not-vector-search-alone">1. Why physical AI needs semantic search and analytics, not vector search alone<a href="https://doris.apache.org/blog/apache-doris-lance-physical-ai-analytics/#1-why-physical-ai-needs-semantic-search-and-analytics-not-vector-search-alone" class="hash-link" aria-label="Direct link to 1. Why physical AI needs semantic search and analytics, not vector search alone" title="Direct link to 1. Why physical AI needs semantic search and analytics, not vector search alone">&#x200B;</a></h2>
<p>Data for autonomous driving and embodied intelligence is naturally organized around episodes. An episode is a reconstructable physical process rather than a single image: sensors observe the environment, a model makes a decision, a control system executes an action, and the physical world produces an outcome.</p>
<p>In autonomous driving, finding images similar to the five seconds before an accident is only the first step. Engineering teams must further constrain the search by vehicle model, sensor version, road type, weather, model version, and time range. They then need to compare intervention rates, false-positive rates, or planning deviations among the candidate segments. The same applies to embodied intelligence. A failed grasp involves visual semantics, but it must also be examined in the context of the task type, robot arm model, policy version, joint states, action trajectory, and final outcome.</p>
<p>Finding high-value data therefore requires at least three layers of computation:</p>
<ol>
<li>Use structured conditions to narrow the search space to the correct business context.</li>
<li>Use vector similarity to find related scenarios that the labeling system does not yet cover.</li>
<li>Use aggregation, joins, sorting, and window analysis to turn candidate segments into model evaluation findings and actionable datasets.</li>
</ol>
<p>Lance and Doris handle different parts of this process. Lance manages AI datasets, random access, and vector indexes. Doris brings the retrieval results into an explainable, composable SQL analytics system.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="2-overall-architecture-lance-manages-ai-data-assets-and-doris-provides-unified-queries-and-analytics">2. Overall architecture: Lance manages AI data assets, and Doris provides unified queries and analytics<a href="https://doris.apache.org/blog/apache-doris-lance-physical-ai-analytics/#2-overall-architecture-lance-manages-ai-data-assets-and-doris-provides-unified-queries-and-analytics" class="hash-link" aria-label="Direct link to 2. Overall architecture: Lance manages AI data assets, and Doris provides unified queries and analytics" title="Direct link to 2. Overall architecture: Lance manages AI data assets, and Doris provides unified queries and analytics">&#x200B;</a></h2>
<p><img decoding="async" loading="lazy" alt="Apache Doris and Lance in the Physical AI data architecture" src="https://assets-cdn.selectdb.com/site/assets/shared/67c98e7629aa2e5be5b0442f83102ceb.jpg" width="1200" height="630" class="img_ev3q"></p>
<p><strong>Figure 1. Apache Doris and Lance in the Physical AI data architecture</strong></p>
<p>In this architecture, upstream systems continue to use tools such as the Lance SDK, Ray, and Spark to generate and maintain Lance datasets. These datasets include features, embeddings, labels, model outputs, and existing Lance vector indexes. The data can reside in a local file system, S3-compatible object storage, or OSS.</p>
<p>Apache Doris uses Lance Catalog to discover datasets and schemas. During a query, Doris fixes the snapshot, divides fragments or index segments, runs scans and searches in parallel, and performs global Top-K selection and OLAP computation.</p>
<p>Apache Doris covers a layer that can otherwise be fragmented across separate tools before and after training. Engineers, algorithm teams, business analysts, and agents can use the same system to find data, validate models, locate problems, and construct the next training dataset.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="3-autonomous-driving-find-similar-video-and-build-a-closed-hard-case-mining-loop">3. Autonomous driving: Find similar video and build a closed hard-case mining loop<a href="https://doris.apache.org/blog/apache-doris-lance-physical-ai-analytics/#3-autonomous-driving-find-similar-video-and-build-a-closed-hard-case-mining-loop" class="hash-link" aria-label="Direct link to 3. Autonomous driving: Find similar video and build a closed hard-case mining loop" title="Direct link to 3. Autonomous driving: Find similar video and build a closed hard-case mining loop">&#x200B;</a></h2>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="31-finding-high-value-scenarios-is-the-bottleneck">3.1 Finding high-value scenarios is the bottleneck<a href="https://doris.apache.org/blog/apache-doris-lance-physical-ai-analytics/#31-finding-high-value-scenarios-is-the-bottleneck" class="hash-link" aria-label="Direct link to 3.1 Finding high-value scenarios is the bottleneck" title="Direct link to 3.1 Finding high-value scenarios is the bottleneck">&#x200B;</a></h3>
<p>In autonomous driving development, hard-case mining means finding high-value scenarios within massive volumes of driving data where models are prone to false positives, false negatives, abnormal braking, or human intervention. These segments make up only a small proportion of all fleet data, but they directly affect model safety and coverage of long-tail scenarios.</p>
<p>Collecting the data is usually easier than finding the right records within the full set of driving data. The main bottlenecks and corresponding solutions include:</p>
<ul>
<li><strong>Anomalous segments are rare, and their context is scattered.</strong> Vehicles continuously generate data from multiple cameras, point clouds, localization systems, vehicle states, and model outputs. An anomaly may exist only in a segment lasting a few seconds and may occur across different vehicle models, roads, weather conditions, and sensor versions. Doris can first narrow the search by business conditions such as time, vehicle model, road, weather, and model version.</li>
<li><strong>Existing labels cannot cover all semantics.</strong> Queries based only on time, vehicle, or labels can easily miss semantically similar segments that have not yet been labeled. Lance stores episode metadata, embeddings, and vector indexes, and Doris reuses those indexes to retrieve similar scenarios.</li>
<li><strong>Similarity results are not yet engineering conclusions.</strong> Vector similarity search alone may return results from irrelevant business contexts and cannot directly determine issue frequency, model-version regressions, or sample value. Once the candidate results enter Doris, distributed statistics and version comparisons can identify the episodes that should be included in annotation, training, and evaluation.</li>
</ul>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="32-a-practical-hard-case-mining-workflow">3.2 A practical hard-case mining workflow<a href="https://doris.apache.org/blog/apache-doris-lance-physical-ai-analytics/#32-a-practical-hard-case-mining-workflow" class="hash-link" aria-label="Direct link to 3.2 A practical hard-case mining workflow" title="Direct link to 3.2 A practical hard-case mining workflow">&#x200B;</a></h3>
<p>Suppose a team wants to find segments that are visually and semantically similar to an emergency-braking event involving an irregularly shaped obstacle. The event occurred on urban roads, and the team wants to determine whether the problem is concentrated in a particular perception model version:</p>
<ol>
<li>The Lance dataset stores <code>episode_id</code>, time, road and weather labels, vehicle model, model version, intervention or emergency-braking results, image or segment embeddings, and raw media location information.</li>
<li>Doris pushes down conditions such as time range, urban roads, vehicle model, and model version to narrow the search space before generating vector candidates.</li>
<li>Doris reuses existing Lance vector indexes and searches them in parallel. Fragments not covered by an index are automatically supplemented with Flat Search.</li>
<li>Each parallel task returns local candidates, which Doris merges into a global Top-K result.</li>
<li>SQL aggregates intervention rates, emergency-braking rates, and sample counts by model version, weather, and road type to produce a hard-case distribution.</li>
<li>Candidate <code>episode_id</code> values are sent for human review, annotation, inclusion in a training dataset, or regression evaluation. The Lance SDK reads the raw media precisely.</li>
</ol>
<p><img decoding="async" loading="lazy" alt="Closed-loop hard-case mining for autonomous driving" src="https://assets-cdn.selectdb.com/site/assets/shared/c6824edff6dc067893385019688955ff.jpg" width="1200" height="630" class="img_ev3q"></p>
<p><strong>Figure 2. Autonomous-driving hard-case mining: from fleet data to model iteration</strong></p>
<p>This workflow does not require every capability to live in one storage format. Instead, it keeps similar scenarios connected to their business context. Algorithm engineers receive more than a page of similar images. They can determine which versions exhibit similar problems, whether a regression is occurring, how many vehicles and road conditions are affected, and which episodes are most useful for the next training cycle.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="33-find-similar-scenarios-with-a-single-sql-query">3.3 Find similar scenarios with a single SQL query<a href="https://doris.apache.org/blog/apache-doris-lance-physical-ai-analytics/#33-find-similar-scenarios-with-a-single-sql-query" class="hash-link" aria-label="Direct link to 3.3 Find similar scenarios with a single SQL query" title="Direct link to 3.3 Find similar scenarios with a single SQL query">&#x200B;</a></h3>
<p>Suppose an upstream tool has already created a <code>scene_embedding</code> index in the Lance dataset. Doris can start a search through <code>vector_search()</code>:</p>
<div class="language-SQL language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    episode_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    event_time</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    road_type</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    weather</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    model_version</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    intervention</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    _distance</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> vector_search</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;table&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;lance_ai.autodrive.scene_episodes&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;column&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;scene_embedding&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;query_vector&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;[0.12, -0.08, 0.31, ...]&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;top_k&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;200&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;metric&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;cosine&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;nprobes&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;20&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;refine_factor&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;10&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;filter&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;road_type = &apos;urban&apos; AND event_time &gt;= &apos;2026-08-01&apos;&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;use_index&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ORDER</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> _distance </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ASC</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> episode_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>Here, <code>filter</code> performs pre-filtering. It first restricts the search to the correct scenario range, then generates vector candidates. This behavior usually fits the semantics of hard-case mining better than post-filtering with <code>WHERE</code> outside the TVF. A smaller <code>_distance</code> value indicates greater similarity. Adding a unique key explicitly as the second sort field produces a stable return order when distances are equal.</p>
<p>Vector candidates can also feed standard SQL aggregation. For example, the following query calculates the distribution of interventions in similar scenarios by model version:</p>
<div class="language-SQL language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">WITH</span><span class="token plain"> similar_scenes </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> model_version</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> weather</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> intervention</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> _distance</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> vector_search</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;table&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;lance_ai.autodrive.scene_episodes&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;column&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;scene_embedding&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;query_vector&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;[0.12, -0.08, 0.31, ...]&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;top_k&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;1000&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;metric&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;cosine&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;filter&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;road_type = &apos;urban&apos;&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">        </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;use_index&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    model_version</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    weather</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token function" style="color:hsl(221, 87%, 60%)">COUNT</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token operator" style="color:hsl(221, 87%, 60%)">*</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> scene_count</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token function" style="color:hsl(221, 87%, 60%)">SUM</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token keyword" style="color:hsl(301, 63%, 40%)">CASE</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">WHEN</span><span class="token plain"> intervention </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">THEN</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">1</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ELSE</span><span class="token plain"> </span><span class="token number" style="color:hsl(35, 99%, 36%)">0</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">END</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">AS</span><span class="token plain"> intervention_count</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> similar_scenes</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">GROUP</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> model_version</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> weather</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ORDER</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> intervention_count </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DESC</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="4-embodied-intelligence-make-every-episode-searchable-comparable-and-reviewable">4. Embodied intelligence: Make every episode searchable, comparable, and reviewable<a href="https://doris.apache.org/blog/apache-doris-lance-physical-ai-analytics/#4-embodied-intelligence-make-every-episode-searchable-comparable-and-reviewable" class="hash-link" aria-label="Direct link to 4. Embodied intelligence: Make every episode searchable, comparable, and reviewable" title="Direct link to 4. Embodied intelligence: Make every episode searchable, comparable, and reviewable">&#x200B;</a></h2>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="41-robot-data-requires-cross-frequency-alignment-random-access-and-cross-episode-analytics">4.1 Robot data requires cross-frequency alignment, random access, and cross-episode analytics<a href="https://doris.apache.org/blog/apache-doris-lance-physical-ai-analytics/#41-robot-data-requires-cross-frequency-alignment-random-access-and-cross-episode-analytics" class="hash-link" aria-label="Direct link to 4.1 Robot data requires cross-frequency alignment, random access, and cross-episode analytics" title="Direct link to 4.1 Robot data requires cross-frequency alignment, random access, and cross-episode analytics">&#x200B;</a></h3>
<p>An embodied intelligence task typically produces data in several forms and at different frequencies. Robot arm states and control signals may be collected at hundreds of hertz, while multiple cameras record environmental changes at tens of frames per second. Other data includes language instructions, frame-level labels, intermediate model results, and information about task success, failure, and retries.</p>
<p>If this data is stored separately in video files, columnar files, and JSON, teams must maintain timestamp alignment and version mappings across those files. They must also repeatedly implement data-assembly logic for training, playback, and problem analysis. A random read may require locating the video segment first, then finding the corresponding state and action records. When schemas or features change, separate copies of the data can become inconsistent.</p>
<p>Training frameworks focus on reading batches of samples at high throughput. Research and development analytics has a different job: locating similar failures among millions of episodes, comparing policy and hardware versions, and determining whether problems originate in perception, planning, control, or execution. Random access alone cannot provide this type of cross-episode aggregation and attribution. Traditional data warehouse full-table scans are also unsuitable for all multimodal sample access.</p>
<p>Lance organizes states, actions, features, embeddings, and media location information by episode and timeline while preserving random-access paths for training and review. Doris performs conditional filtering, vector retrieval, and cross-episode aggregation over the supported fields. With this division of responsibilities, the same robot data can support model training, unified analysis, and review.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="42-from-failed-tasks-to-a-closed-training-data-loop">4.2 From failed tasks to a closed training-data loop<a href="https://doris.apache.org/blog/apache-doris-lance-physical-ai-analytics/#42-from-failed-tasks-to-a-closed-training-data-loop" class="hash-link" aria-label="Direct link to 4.2 From failed tasks to a closed training-data loop" title="Direct link to 4.2 From failed tasks to a closed training-data loop">&#x200B;</a></h3>
<p>For failures involving robot arms attempting to grasp transparent or reflective objects, teams can use the following workflow:</p>
<ol>
<li>Data from multiple cameras, joint states, action trajectories, instructions, policy versions, and task results enters Lance by episode.</li>
<li>An upstream model generates visual or trajectory embeddings and creates vector indexes in Lance.</li>
<li>Doris first performs pre-filtering by robot model, task type, policy version, and <code>success = false</code>.</li>
<li>Vector search finds images or action segments similar to the target failure pattern.</li>
<li>Doris aggregates failure reasons, retry counts, task duration, hardware versions, and policy versions to determine whether the issue is related to perception, planning, control, or hardware.</li>
<li>High-value episodes are sent for review, relabeling, and training. The corrected model is then subjected to regression validation against the same dataset.</li>
</ol>
<p><img decoding="async" loading="lazy" alt="Robot Episode analysis workflow" src="https://assets-cdn.selectdb.com/site/assets/shared/4cd9dbac14be1f53473cff0a59a668e8.jpg" width="1200" height="630" class="img_ev3q"></p>
<p><strong>Figure 3. Embodied-intelligence episode analysis: from multi-frequency sensors to a closed training loop</strong></p>
<p>This workflow also works well for agentic data processing. An agent can use SQL to define the task scope, invoke vector search to locate similar failures, and generate distribution statistics and a list of candidate episodes. Each step retains its filter conditions, SQL, and data versions. Reviewers can inspect how the results were produced instead of relying on a model to search file directories or a vector database without a traceable procedure.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="43-example-search-for-robot-failure-patterns">4.3 Example: Search for robot failure patterns<a href="https://doris.apache.org/blog/apache-doris-lance-physical-ai-analytics/#43-example-search-for-robot-failure-patterns" class="hash-link" aria-label="Direct link to 4.3 Example: Search for robot failure patterns" title="Direct link to 4.3 Example: Search for robot failure patterns">&#x200B;</a></h3>
<p>The upstream system generates <code>query_vector</code> with the same embedding model used for <code>frame_embedding</code>. For example, it can pass a reference image, a representative video frame, or an action trajectory to the model and then provide the resulting floating-point array to <code>vector_search()</code>. The query vector&apos;s dimensions, numeric type, and normalization method must match the vector column in the dataset and the settings used when the index was created. The <code>[-0.04, 0.27, 0.18, ...]</code> value in this example only demonstrates the parameter format.</p>
<div class="language-SQL language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    episode_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    robot_model</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    policy_version</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    task_type</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    failure_reason</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    retry_count</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    _distance</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> vector_search</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;table&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;lance_ai.robotics.task_episodes&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;column&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;frame_embedding&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;query_vector&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;[-0.04, 0.27, 0.18, ...]&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;top_k&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;300&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;metric&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;cosine&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;filter&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;task_type = &apos;pick&apos; AND success = false&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;use_index&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ORDER</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> _distance </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ASC</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> episode_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>The results can then be aggregated by <code>policy_version</code>, <code>robot_model</code>, or <code>failure_reason</code>. The query can instead return <code>episode_id</code> and media location fields, allowing an application to use the Lance SDK to open the corresponding video frames, point clouds, or other Blob content for review.</p>
<blockquote>
<p>Availability: Lance Catalog support is in the Doris 4.2 release branch and is scheduled for public release at the end of September. The SQL below shows the planned public syntax.</p>
</blockquote>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="5-how-to-use-lance-catalog-in-apache-doris">5. How to use Lance Catalog in Apache Doris<a href="https://doris.apache.org/blog/apache-doris-lance-physical-ai-analytics/#5-how-to-use-lance-catalog-in-apache-doris" class="hash-link" aria-label="Direct link to 5. How to use Lance Catalog in Apache Doris" title="Direct link to 5. How to use Lance Catalog in Apache Doris">&#x200B;</a></h2>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="51-connect-to-a-lance-dataset-in-object-storage">5.1 Connect to a Lance dataset in object storage<a href="https://doris.apache.org/blog/apache-doris-lance-physical-ai-analytics/#51-connect-to-a-lance-dataset-in-object-storage" class="hash-link" aria-label="Direct link to 5.1 Connect to a Lance dataset in object storage" title="Direct link to 5.1 Connect to a Lance dataset in object storage">&#x200B;</a></h3>
<p>The following example uses S3-compatible object storage. In production environments, supply access keys through secure credential management rather than writing them directly into shared scripts.</p>
<div class="language-SQL language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">CREATE</span><span class="token plain"> CATALOG lance_ai PROPERTIES </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;type&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;lance&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;lance.catalog.type&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;filesystem&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;warehouse&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;s3://&lt;bucket&gt;/physical-ai&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;s3.endpoint&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;https://&lt;object-storage-endpoint&gt;&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;s3.region&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;&lt;region&gt;&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;s3.access_key&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;&lt;access-key&gt;&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;s3.secret_key&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;&lt;secret-key&gt;&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>Doris also supports local file systems, OSS, and Lance REST Catalogs authenticated with Bearer Tokens, API Keys, or custom headers. Filesystem Catalog maps namespaces by directory: a first-level directory under the warehouse root corresponds to a Doris database, and a <code>.lance</code> directory corresponds to a table.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="52-discover-datasets-schemas-and-existing-indexes">5.2 Discover datasets, schemas, and existing indexes<a href="https://doris.apache.org/blog/apache-doris-lance-physical-ai-analytics/#52-discover-datasets-schemas-and-existing-indexes" class="hash-link" aria-label="Direct link to 5.2 Discover datasets, schemas, and existing indexes" title="Direct link to 5.2 Discover datasets, schemas, and existing indexes">&#x200B;</a></h3>
<div class="language-SQL language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">SHOW</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DATABASES</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> lance_ai</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SHOW</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">TABLES</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> lance_ai</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">autodrive</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">DESC</span><span class="token plain"> lance_ai</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">autodrive</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">scene_episodes</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SHOW</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">INDEX</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> lance_ai</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">autodrive</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">scene_episodes</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p><code>SHOW INDEX</code> displays indexes that tools in the Lance ecosystem have already created.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="53-run-vector-queries-through-the-catalog">5.3 Run vector queries through the Catalog<a href="https://doris.apache.org/blog/apache-doris-lance-physical-ai-analytics/#53-run-vector-queries-through-the-catalog" class="hash-link" aria-label="Direct link to 5.3 Run vector queries through the Catalog" title="Direct link to 5.3 Run vector queries through the Catalog">&#x200B;</a></h3>
<div class="language-SQL language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> episode_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> event_time</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> model_version</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> _distance</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> vector_search</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;table&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;lance_ai.autodrive.scene_episodes&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;column&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;scene_embedding&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;query_vector&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;[0.12, -0.08, 0.31, ...]&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;top_k&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;200&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;metric&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;cosine&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;filter&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;road_type = &apos;urban&apos;&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;use_index&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ORDER</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> _distance </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ASC</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> episode_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>Catalog creation, dataset discovery, and vector search all remain within the same Catalog namespace. <code>filter</code> restricts candidates to urban-road scenarios before candidate generation, while <code>_distance</code> returns the similarity distance. The query vector&apos;s dimensions and distance metric must match those used by the upstream system to generate embeddings and create the Lance index.</p>
<p>Pre-filtering and post-filtering differ in when their conditions take part in candidate generation.</p>
<ul>
<li>A condition in the <code>filter</code> parameter of <code>vector_search()</code> is a pre-filter. Lance first filters the data and then performs vector retrieval within that subset. Therefore, <code>top_k</code> represents the Top-K results among the filtered data. This is suitable for conditions such as road type, time range, vehicle model, tenant, or data permissions that must constrain the search space.</li>
<li>A condition in <code>WHERE</code> outside the TVF is a post-filter. Vector search produces candidates first, and Doris then filters those candidates. This is suitable for expressions that Lance cannot currently push down or for scenarios that require semantic retrieval before business filtering. However, the final result may contain fewer than <code>top_k</code> entries, and the system will not automatically expand the retrieval range to fill the requested count.</li>
</ul>
<p>A query can combine both approaches. Put strong constraints that define the search scope in <code>filter</code>, place complex calculations or remaining conditions in the outer <code>WHERE</code>, and use <code>EXPLAIN</code> to confirm which conditions have been pushed down.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="54-use-explain-to-confirm-predicate-pushdown-and-index-use">5.4 Use EXPLAIN to confirm predicate pushdown and index use<a href="https://doris.apache.org/blog/apache-doris-lance-physical-ai-analytics/#54-use-explain-to-confirm-predicate-pushdown-and-index-use" class="hash-link" aria-label="Direct link to 5.4 Use EXPLAIN to confirm predicate pushdown and index use" title="Direct link to 5.4 Use EXPLAIN to confirm predicate pushdown and index use">&#x200B;</a></h3>
<p>Before running a query, use <code>EXPLAIN</code> with the same <code>vector_search()</code> query. In the execution plan, <code>lancePushdownPredicate</code> indicates that pre-search conditions have been pushed down, while <code>lanceSearchIndexSegments</code> indicates that Lance index segments have been planned. Doris supplements new fragments not covered by the index with Flat Search so that the query includes all data in the current snapshot.</p>
<div class="language-SQL language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">EXPLAIN</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> episode_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> _distance</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> vector_search</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;table&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;lance_ai.autodrive.scene_episodes&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;column&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;scene_embedding&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;query_vector&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;[0.12, -0.08, 0.31, ...]&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;top_k&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;200&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;metric&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;cosine&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;filter&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;road_type = &apos;urban&apos;&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;use_index&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;true&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ORDER</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">BY</span><span class="token plain"> _distance </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">ASC</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> episode_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="55-use-a-tvf-for-temporary-reads-without-creating-a-catalog">5.5 Use a TVF for temporary reads without creating a Catalog<a href="https://doris.apache.org/blog/apache-doris-lance-physical-ai-analytics/#55-use-a-tvf-for-temporary-reads-without-creating-a-catalog" class="hash-link" aria-label="Direct link to 5.5 Use a TVF for temporary reads without creating a Catalog" title="Direct link to 5.5 Use a TVF for temporary reads without creating a Catalog">&#x200B;</a></h3>
<p>If you only need to analyze a specific Lance dataset temporarily and do not want to manage it through a Catalog, you can use the S3 TVF directly. The TVF is suitable for path-based reads and scalar analysis. If you need to reuse datasets, schemas, and vector indexes from a Catalog, use the Lance Catalog and <code>vector_search()</code> described above.</p>
<div class="language-SQL language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">SELECT</span><span class="token plain"> episode_id</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> event_time</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> model_version</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">FROM</span><span class="token plain"> s3</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;uri&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;s3://&lt;bucket&gt;/physical-ai/autodrive/scene_episodes.lance&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;s3.endpoint&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;https://&lt;object-storage-endpoint&gt;&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;s3.region&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;&lt;region&gt;&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;s3.access_key&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;&lt;access-key&gt;&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;s3.secret_key&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;&lt;secret-key&gt;&quot;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;format&quot;</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&quot;lance&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">WHERE</span><span class="token plain"> event_time </span><span class="token operator" style="color:hsl(221, 87%, 60%)">&gt;=</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;2026-08-01&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="6-conclusion-connect-ai-data-to-decisions">6. Conclusion: Connect AI data to decisions<a href="https://doris.apache.org/blog/apache-doris-lance-physical-ai-analytics/#6-conclusion-connect-ai-data-to-decisions" class="hash-link" aria-label="Direct link to 6. Conclusion: Connect AI data to decisions" title="Direct link to 6. Conclusion: Connect AI data to decisions">&#x200B;</a></h2>
<p>Autonomous driving and embodied intelligence systems will continue to produce large amounts of data. The scarce resource is the set of high-value episodes that can explain model problems, cover long-tail scenarios, and inform the next iteration.</p>
<p>Apache Doris and Lance provide a direct path from multimodal assets to business decisions while retaining open formats. Lance organizes and indexes AI data and supports random access. Doris makes the data filterable, searchable, aggregatable, and understandable by both people and agents through unified SQL.</p>
<p>With this workflow, finding similar scenarios leads directly to questions about which version is affected, how often the issue occurred, whether it is a regression, and which training dataset should include it. Multimodal data can then participate in the closed loop for model iteration and business decision-making.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="61-doris-and-lance-development-roadmap">6.1 Doris and Lance development roadmap<a href="https://doris.apache.org/blog/apache-doris-lance-physical-ai-analytics/#61-doris-and-lance-development-roadmap" class="hash-link" aria-label="Direct link to 6.1 Doris and Lance development roadmap" title="Direct link to 6.1 Doris and Lance development roadmap">&#x200B;</a></h3>
<p>The multimodal lakehouse capabilities for Iceberg, Paimon, Lance, and other formats have currently been merged into the Doris 4.2 release branch and are planned for official release with version 4.2 at the end of September.</p>
<p>Future work will focus on the performance, stability, and usability of Doris and Lance in the following areas:</p>
<ul>
<li>Establishing reproducible benchmarks across different data volumes, vector dimensions, Top-K values, filter selectivity, index coverage, concurrency levels, and cold or warm caches.</li>
<li>Measuring P50, P95, and P99 latency, throughput, recall, bytes scanned, object-storage requests, network traffic, peak CPU usage, and peak memory usage.</li>
<li>Continuing to optimize split balancing, large Top-K merges, high-dimensional vectors, lookups of wide result columns, object-storage reads, and cache paths.</li>
<li>Providing scenario-specific recommendations for parameters such as <code>nprobes</code>, <code>refine_factor</code>, <code>ef</code>, and <code>use_index</code>, and developing capacity-planning and troubleshooting guides.</li>
<li>Improving Lance table-management capabilities.</li>
<li>Supporting data export to Lance files.</li>
</ul></div>]]></content:encoded>
            <category>Tech Sharing</category>
        </item>
        <item>
            <title><![CDATA[Apache Doris 5.0 Preview(1): A Unified Multimodal Lakehouse for Real-Time Analytics]]></title>
            <link>https://doris.apache.org/blog/apache-doris-5-multimodal-lakehouse-preview/</link>
            <guid>https://doris.apache.org/blog/apache-doris-5-multimodal-lakehouse-preview/</guid>
            <pubDate>Fri, 04 Sep 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[Explore the Apache Doris 5.0 multimodal lakehouse preview, including open-format integration, Variant and vector analytics, Physical AI, and agent use cases.]]></description>
            <content:encoded><![CDATA[<header><div class="text-center mb-4"><a class="cursor-pointer hover:no-underline" lang="en" href="https://doris.apache.org/blog/">Blog</a><span class="px-2 text-[#8592A6]">/</span><span><span class="s-tags" lang="en"><span class="s-tag">Tech Sharing</span></span></span></div><h1 lang="en" class="blog-post-title text-[2rem] leading-normal lg:!text-[2.5rem] text-center" itemprop="headline">Apache Doris 5.0 Preview(1): A Unified Multimodal Lakehouse for Real-Time Analytics</h1><div class="blog-info text-center flex justify-center text-sm text-black"><span class="authors"><span class="s-author text-black">Apache Doris &#xB7; Mingyu Chen</span></span><time datetime="2026-09-04T00:00:00.000Z" itemprop="datePublished" class="text-black ml-4">September 4, 2026</time></div></header><div id="__blog-post-container" class="markdown" itemprop="articleBody"><blockquote>
<p>Overview</p>
<p>This article covers the core changes planned for Apache Doris 5.0 for the multimodal lakehouse:</p>
<ol>
<li>
<p>Core concept: Extend unified search to the open lakehouse and use Doris to build a unified platform for multimodal data analytics.</p>
</li>
<li>
<p>Integration with open formats: Provide read and write integration with mainstream open formats such as Iceberg, Paimon, and Lance.</p>
</li>
<li>
<p>Multimodal data analytics: Adapt Doris to multimodal data types such as Variant, Vector, GEO, and Blob.</p>
</li>
<li>
<p>Use cases: Build a unified real-time multimodal data analytics platform for more AI scenarios, including real-time context for agents and embodied intelligence.</p>
</li>
</ol>
</blockquote>
<hr>
<p>For more than a decade, most data platforms have been organized around structured tables and SQL. Data is consolidated in a data warehouse, where stable batch processing and OLAP queries support reporting and business analysis.</p>
<p>AI changes the assumptions behind this architecture.</p>
<p>Enterprises now need to process business tables, JSON, logs, documents, images, audio, video, embeddings, and model outputs together. The set of data consumers has also grown beyond analysts to include applications and AI agents. A real-world request often combines structured filtering with full-text and vector retrieval, then joins the results with the latest business status, permissions, and historical metrics.</p>
<p>The traditional approach spreads these capabilities across separate systems. Object storage holds raw content, lakehouses hold table data and metadata, search engines handle full-text retrieval, vector databases provide semantic retrieval, OLAP systems perform metric analysis, and the application layer assembles the results. Each system solves a specific problem, but users are responsible for data consistency, version alignment, access governance, and result fusion across them.</p>
<p>Open formats are also expanding beyond structured data. AI workloads now include dynamic attributes, blobs, embeddings, and model results. Iceberg, Paimon, and Lance serve long-term analytical facts, real-time updated data, and AI datasets, respectively, so enterprises can select the appropriate format for each workload. In this article, a multimodal lakehouse refers to structured, semi-structured, and multimodal data stored collectively in these open formats.</p>
<p>For the multimodal lakehouse, Doris 5.0 will focus unification on query and execution instead of requiring users to move all data into one storage system. Data can remain in the open format best suited to it, while Doris provides unified search, analytics, and real-time serving.</p>
<p><img decoding="async" loading="lazy" alt="Apache Doris 5.0 unified query and compute architecture for the multimodal lakehouse" src="https://assets-cdn.selectdb.com/site/assets/shared/587dbd2068256c0425d19e7ca812157d.jpg" width="1200" height="630" class="img_ev3q"></p>
<p>Figure 1: Overall architecture of an open-format multimodal lakehouse. Iceberg, Paimon, Lance, and Fluss hold different types of open data assets. At the unified query and compute layer, Doris understands format semantics and connects hybrid search, cross-source joins, MPP OLAP, real-time serving, and access control in one execution pipeline.</p>
<blockquote>
<p>Availability: The Iceberg, Paimon, and Lance capabilities discussed here are in the Doris 4.2 release branch and are scheduled for public release at the end of September. The broader Doris 5.0 work remains a preview.</p>
</blockquote>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="from-4x-to-50-extending-unified-search-to-the-open-lakehouse">From 4.x to 5.0: Extending unified search to the open lakehouse<a href="https://doris.apache.org/blog/apache-doris-5-multimodal-lakehouse-preview/#from-4x-to-50-extending-unified-search-to-the-open-lakehouse" class="hash-link" aria-label="Direct link to From 4.x to 5.0: Extending unified search to the open lakehouse" title="Direct link to From 4.x to 5.0: Extending unified search to the open lakehouse">&#x200B;</a></h2>
<p>Apache Doris 4.x already provides high-performance unified search and analytics for structured, semi-structured, and vector data in internal tables. Users can combine SQL analytics, full-text search, vector search, and real-time updates in one system. For open lake formats such as Iceberg and Paimon, Doris has primarily supported queries and analysis of structured data.</p>
<p>Doris 5.0 will continue this work by extending capabilities already proven on internal tables to the open lakehouse. Variant data in Iceberg and Paimon will become part of a unified read and write pipeline. Paimon and Lance will gain native full-text and vector search. A new Fluss Catalog will support joint queries across real-time data in Fluss and historical data tiered to Paimon, which will further improve data freshness for analytics.</p>
<p><img decoding="async" loading="lazy" alt="Evolution of Doris capabilities from 4.x to 5.0" src="https://assets-cdn.selectdb.com/site/assets/shared/4dd13edec3c384121d671bfaa75a7c65.jpg" width="1200" height="630" class="img_ev3q"></p>
<p>Figure 2: Capability evolution from 4.x to 5.0. Doris 4.x provides unified search and OLAP on internal tables, along with structured SQL for Iceberg and Paimon. Doris 5.0 extends unified querying to the open lakehouse with Variant reads and writes, native vector search, and joint queries across real-time Fluss data and historical Paimon data.</p>
<p>Doris 5.0 will provide the following capabilities across open formats and the unified execution layer:</p>
<ul>
<li>Iceberg: Building on mature support for reads, writes, time travel, row-level updates, and table lifecycle management, Doris will add reads and writes for Iceberg V3 Variant data in both plain and shredded layouts.</li>
<li>Paimon: The Paimon Catalog will move from read-only access to full read and write support, including <code>INSERT</code>, <code>INSERT OVERWRITE</code>, <code>UPDATE</code>, <code>DELETE</code>, <code>MERGE</code>, DDL, and reads and writes for Variant, full-text indexes, and vector indexes. It will provide a unified entry point for real-time lakehouses and evolving multimodal data.</li>
<li>Lance: Doris will introduce native read and retrieval capabilities for multimodal AI, including Catalog support, parallel scans, column pruning, predicate pushdown, vector and full-text search, and vector index management.</li>
<li>Fluss: A new Fluss Catalog will support reads from log tables and primary-key tables. Through Union Read, it will jointly query real-time incremental data in Fluss and historical data tiered to Paimon.</li>
<li>Unified Doris execution: Doris will connect internal tables, open lake tables, full-text and vector retrieval, cross-source joins, aggregations, window calculations, and permission filtering in one SQL pipeline.</li>
</ul>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="from-multiple-systems-to-a-unified-platform">From multiple systems to a unified platform<a href="https://doris.apache.org/blog/apache-doris-5-multimodal-lakehouse-preview/#from-multiple-systems-to-a-unified-platform" class="hash-link" aria-label="Direct link to From multiple systems to a unified platform" title="Direct link to From multiple systems to a unified platform">&#x200B;</a></h2>
<p>The difficulty of assembling multiple systems goes beyond the number of systems involved. The same business entity may have different update times, versions, and permission boundaries in each system. A product that has been delisted, a device currently under maintenance, or a document that has been withdrawn may still appear in a stale vector index and be passed to an agent.</p>
<p>Placing unification at the query and execution layer makes the division of responsibilities clearer. Open formats continue to store long-term data and multimodal assets. Doris internal tables hold real-time business facts that require high concurrency and low latency. The Doris MPP engine performs retrieval, filtering, joins, and analytics in one query, so applications no longer need to move and assemble results across multiple systems. The same layer evaluates business state and applies permission filters for each entity, preventing stale candidates from bypassing these checks and reaching an agent.</p>
<p><img decoding="async" loading="lazy" alt="Evolution from a traditional multi-system architecture to unified execution with Apache Doris" src="https://assets-cdn.selectdb.com/site/assets/shared/3ec9ea36ad34fe9149962312b258d87d.jpg" width="1200" height="630" class="img_ev3q"></p>
<p>Figure 3: Evolution of the multimodal lakehouse data architecture. The architecture moves from traditional multi-system assembly to unified execution with Doris. Data remains in the appropriate open formats, while Doris unifies querying, computing, and serving.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="olap-from-retrieving-candidates-to-determining-business-outcomes">OLAP: From retrieving candidates to determining business outcomes<a href="https://doris.apache.org/blog/apache-doris-5-multimodal-lakehouse-preview/#olap-from-retrieving-candidates-to-determining-business-outcomes" class="hash-link" aria-label="Direct link to OLAP: From retrieving candidates to determining business outcomes" title="Direct link to OLAP: From retrieving candidates to determining business outcomes">&#x200B;</a></h3>
<p>Vector or full-text search discovers candidates. Answering the business question usually requires joins, aggregations, window calculations, and multidimensional ranking as well.</p>
<p>For example, image-based product search cannot return products based only on visual similarity. It must also account for inventory, regional availability, price, conversion rate, and return rate. Equipment fault diagnosis cannot stop at finding similar logs. It must compare models, firmware versions, sensor metrics, and repair outcomes.</p>
<p>Whether candidates come from Doris internal tables or open lake tables, Doris can pass search results directly into its MPP OLAP execution pipeline. This allows the query to turn a &quot;similar&quot; result into a business conclusion that is currently valid, complies with the relevant rules, and is worth acting on.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="variant-full-text-and-vector-combining-different-forms-of-evidence-in-one-sql-query">Variant, full text, and vector: Combining different forms of evidence in one SQL query<a href="https://doris.apache.org/blog/apache-doris-5-multimodal-lakehouse-preview/#variant-full-text-and-vector-combining-different-forms-of-evidence-in-one-sql-query" class="hash-link" aria-label="Direct link to Variant, full text, and vector: Combining different forms of evidence in one SQL query" title="Direct link to Variant, full text, and vector: Combining different forms of evidence in one SQL query">&#x200B;</a></h3>
<p>Model-generated data rarely fits a stable wide-table schema. OCR results, captions, labels, tool-call parameters, and evaluation results change as model versions evolve. Variant provides a flexible way to store semi-structured data. Full-text search supports precise keyword and rule matching, while vector search broadens semantic recall. Structured conditions constrain time, status, permissions, and business scope.</p>
<p>Doris 5.0 will make Variant data, full-text indexes, and vector indexes in open lake tables available within the same SQL query. Users will not need to copy multimodal data into additional indexing systems solely to make it searchable.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="physical-ai-from-a-single-record-to-a-complete-episode">Physical AI: From a single record to a complete episode<a href="https://doris.apache.org/blog/apache-doris-5-multimodal-lakehouse-preview/#physical-ai-from-a-single-record-to-a-complete-episode" class="hash-link" aria-label="Direct link to Physical AI: From a single record to a complete episode" title="Direct link to Physical AI: From a single record to a complete episode">&#x200B;</a></h2>
<p>Data generated by autonomous driving systems, robots, and industrial equipment records a continuous process of observation, decision, action, and feedback rather than a collection of static documents. The smallest unit of analysis is therefore no longer an image. It is an Episode that contains time, space, device state, model version, and business outcome.</p>
<p>An Episode involving a robotic arm&apos;s failed grasp might contain RGB-D images, 3D poses, joint and torque data, planned trajectories, control commands, model outputs, device logs, and the final sorting result. Images describe the environment, trajectories describe the action, sensor data records the execution process, and the business outcome shows whether the task succeeded.</p>
<p>Open formats allow teams to retain this data over the long term, evolve it, and share it among different tools. Doris organizes these forms of evidence by Episode into an interactive query. The query first filters by time, device, and status, then retrieves similar situations through full-text and vector search, and finally joins model versions with business outcomes to compare failure rates, retry rates, and task duration.</p>
<p><img decoding="async" loading="lazy" alt="Closed-loop Physical AI Episode analysis" src="https://assets-cdn.selectdb.com/site/assets/shared/5c87054fd05edd259b81abfc0cda6739.jpg" width="1200" height="630" class="img_ev3q"></p>
<p>Figure 4: Closed-loop Physical AI Episode analysis. Doris organizes multisensor evidence, model context, and business outcomes into a reusable data feedback loop.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="agentic-ai-using-real-time-analytics-to-connect-models-with-business-context">Agentic AI: Using real-time analytics to connect models with business context<a href="https://doris.apache.org/blog/apache-doris-5-multimodal-lakehouse-preview/#agentic-ai-using-real-time-analytics-to-connect-models-with-business-context" class="hash-link" aria-label="Direct link to Agentic AI: Using real-time analytics to connect models with business context" title="Direct link to Agentic AI: Using real-time analytics to connect models with business context">&#x200B;</a></h2>
<p>Large language models can understand general knowledge, but they do not inherently know the enterprise&apos;s current state. They cannot know whether an order has been canceled, whether inventory is sufficient, whether a device is online, whether a customer still has permission, or whether a particular anomaly is currently surging without access to current enterprise data.</p>
<p>The challenge for an agent is therefore broader than generating SQL. It needs a continuous supply of fresh, trustworthy, explainable, and permission-compliant data context.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="real-time-writes-bringing-business-changes-directly-into-the-open-lakehouse">Real-time writes: Bringing business changes directly into the open lakehouse<a href="https://doris.apache.org/blog/apache-doris-5-multimodal-lakehouse-preview/#real-time-writes-bringing-business-changes-directly-into-the-open-lakehouse" class="hash-link" aria-label="Direct link to Real-time writes: Bringing business changes directly into the open lakehouse" title="Direct link to Real-time writes: Bringing business changes directly into the open lakehouse">&#x200B;</a></h3>
<p>Doris integration with Iceberg has already progressed from querying a data source to writing efficiently to an open data foundation. <code>INSERT</code>, <code>INSERT OVERWRITE</code>, CTAS, and row-level updates are already available. Doris 5.0 will bring the same write capabilities to Paimon and add Variant writes for both Iceberg and Paimon.</p>
<p>Users will be able to use unified SQL to write structured and Variant data directly to open tables. They will not need to write the data to Doris internal tables first or build another synchronization pipeline. Real-time business events, tool-call parameters, and continuously changing model results can be stored directly as open data assets.</p>
<p>Within the execution pipeline, Doris BEs generate data files through distributed parallel execution. The FE coordinates snapshots and atomic commits, and it handles idempotent retries and failure cleanup. Doris manages efficient writes, commit consistency, and schema evolution through a common implementation, so applications do not need to assemble open-table transactions themselves.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="real-time-analytics-building-agent-context-from-the-latest-open-data">Real-time analytics: Building agent context from the latest open data<a href="https://doris.apache.org/blog/apache-doris-5-multimodal-lakehouse-preview/#real-time-analytics-building-agent-context-from-the-latest-open-data" class="hash-link" aria-label="Direct link to Real-time analytics: Building agent context from the latest open data" title="Direct link to Real-time analytics: Building agent context from the latest open data">&#x200B;</a></h3>
<p>Orders, device states, behavioral events, and model-derived results written to Iceberg or Paimon can be shared among different compute engines. Doris queries the latest data directly, combines it with real-time business facts in internal tables, and applies cross-table joins and permission filtering to construct fresh, verifiable business context for agents.</p>
<p>For event streams with stricter freshness requirements, the new Fluss Catalog uses Union Read to combine real-time increments in Fluss with historical data tiered to Paimon and queries them as a single table. The resulting agent context includes both the complete history and changes that have just occurred.</p>
<p><img decoding="async" loading="lazy" alt="Real-time feedback loop for Agentic AI" src="https://assets-cdn.selectdb.com/site/assets/shared/47b40c4da5f6727fcc520cec9e8c1646.jpg" width="1200" height="630" class="img_ev3q"></p>
<p>Figure 5: A real-time Agentic AI feedback loop using open formats selected according to workload requirements. Doris provides read, write, and Variant capabilities for Iceberg or Paimon selected by the user, along with read and multimodal search capabilities for Lance. It then constructs agent context through unified SQL and MPP OLAP.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="multimodal-lakehouse-use-cases-with-doris">Multimodal lakehouse use cases with Doris<a href="https://doris.apache.org/blog/apache-doris-5-multimodal-lakehouse-preview/#multimodal-lakehouse-use-cases-with-doris" class="hash-link" aria-label="Direct link to Multimodal lakehouse use cases with Doris" title="Direct link to Multimodal lakehouse use cases with Doris">&#x200B;</a></h2>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="scenario-1-real-time-decision-making-for-customer-service-agents">Scenario 1: Real-time decision-making for customer service agents<a href="https://doris.apache.org/blog/apache-doris-5-multimodal-lakehouse-preview/#scenario-1-real-time-decision-making-for-customer-service-agents" class="hash-link" aria-label="Direct link to Scenario 1: Real-time decision-making for customer service agents" title="Direct link to Scenario 1: Real-time decision-making for customer service agents">&#x200B;</a></h3>
<p>Knowledge documents, product images, and samples of similar faults are stored in Lance. Orders, support tickets, and historical service data are stored in Iceberg and Paimon. The latest inventory, warranty, and customer status data is loaded into Doris internal tables.</p>
<p>After an agent receives a customer question, Doris performs semantic retrieval, keyword matching, permission and status filtering, then joins the results with repair success rates and inventory data. The result is more than &quot;the most similar document.&quot; It is a resolution that the current customer can act on.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="scenario-2-selecting-high-value-episodes-for-physical-ai">Scenario 2: Selecting high-value Episodes for Physical AI<a href="https://doris.apache.org/blog/apache-doris-5-multimodal-lakehouse-preview/#scenario-2-selecting-high-value-episodes-for-physical-ai" class="hash-link" aria-label="Direct link to Scenario 2: Selecting high-value Episodes for Physical AI" title="Direct link to Scenario 2: Selecting high-value Episodes for Physical AI">&#x200B;</a></h3>
<p>Autonomous driving or robotics teams store video, point clouds, and embeddings in Lance. They write continuously changing model outputs and task results to Paimon as Variant data, while retaining historical evaluation results in Iceberg. These teams need to answer a question beyond &quot;Which Episodes are similar?&quot; They need to know, &quot;Which Episodes are worth investing in for annotation, training, and review?&quot;</p>
<p>After the query pipeline described above filters the Episodes, high-confidence anomalies enter training and regression datasets. Episodes with inconsistent evidence go to manual review. Failure and intervention rates aggregated by model version then show whether a new strategy has improved a specific scenario.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="scenario-3-from-similar-defects-to-root-cause-analysis-in-industrial-quality-inspection">Scenario 3: From similar defects to root-cause analysis in industrial quality inspection<a href="https://doris.apache.org/blog/apache-doris-5-multimodal-lakehouse-preview/#scenario-3-from-similar-defects-to-root-cause-analysis-in-industrial-quality-inspection" class="hash-link" aria-label="Direct link to Scenario 3: From similar defects to root-cause analysis in industrial quality inspection" title="Direct link to Scenario 3: From similar defects to root-cause analysis in industrial quality inspection">&#x200B;</a></h3>
<p>A quality engineer uploads an image of a defect. Doris retrieves visually similar samples from Lance, matches defect descriptions in Variant and full-text fields, and joins the results with continuously updated equipment events in Paimon and with batch, process, and repair history in Iceberg.</p>
<p>The system then determines whether defects are occurring in clusters, which equipment and batches are affected, how accurately different model versions identify the defect, and whether yields recover in subsequent batches. This expands a similar-image search into a complete closed-loop quality analysis.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="conclusion-keep-data-in-open-formats-and-use-doris-for-search-and-analytics">Conclusion: Keep data in open formats and use Doris for search and analytics<a href="https://doris.apache.org/blog/apache-doris-5-multimodal-lakehouse-preview/#conclusion-keep-data-in-open-formats-and-use-doris-for-search-and-analytics" class="hash-link" aria-label="Direct link to Conclusion: Keep data in open formats and use Doris for search and analytics" title="Direct link to Conclusion: Keep data in open formats and use Doris for search and analytics">&#x200B;</a></h2>
<p>Doris has one primary direction for the multimodal lakehouse: extend the unified search and real-time analytics capabilities already proven on internal tables to data in Iceberg, Paimon, Lance, and Fluss. Data can remain in open formats for search and analytics. Structured data, Variant data, full-text data, and vectors do not need to reside in separate systems. Doris will provide the unified execution and serving layer above this data:</p>
<ul>
<li>Use unified SQL to access Doris internal tables and multiple open formats.</li>
<li>Use Variant, full-text search, vector search, and structured filtering to query different forms of data.</li>
<li>Use MPP OLAP to turn retrieved results into business metrics and decisions.</li>
<li>Use real-time writes to supply the latest business state that agents otherwise lack.</li>
<li>Use unified permission filtering so applications and agents see only the data they are authorized to access.</li>
</ul>
<p>A series of articles about Doris 5.0 will examine these capabilities for open formats such as Iceberg, Paimon, Lance, and Fluss. The articles will cover their technical principles, performance benchmarks, and representative implementation scenarios.</p>
<p>The multimodal lakehouse capabilities for Iceberg, Paimon, and Lance have been merged into the Doris 4.2 release branch and are scheduled for official release with version 4.2 at the end of September. Additional capabilities, including Fluss support, have also entered the Doris main branch and are planned for release with Doris 5.0 at the end of the year.</p></div>]]></content:encoded>
            <category>Tech Sharing</category>
        </item>
        <item>
            <title><![CDATA[dbt-for-apache-doris 1.1.0 Released: Five Business Demos to Get Started with Doris Data Engineering]]></title>
            <link>https://doris.apache.org/blog/dbt-for-apache-doris-1.1.0-five-demos/</link>
            <guid>https://doris.apache.org/blog/dbt-for-apache-doris-1.1.0-five-demos/</guid>
            <pubDate>Tue, 01 Sep 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[dbt-for-apache-doris 1.1.0 targets dbt Core 1.12, manages Apache Doris asynchronous materialized views through the standard dbt materialized_view, and covers Table, View, Incremental, Snapshot, Seed, and Data Test workflows. Five business demos show how dbt and Apache Doris handle daily order summaries, late-arriving orders, and more.]]></description>
            <content:encoded><![CDATA[<header><div class="text-center mb-4"><a class="cursor-pointer hover:no-underline" lang="en" href="https://doris.apache.org/blog/">Blog</a><span class="px-2 text-[#8592A6]">/</span><span><span class="s-tags" lang="en"><span class="s-tag">Tech Sharing</span></span></span></div><h1 lang="en" class="blog-post-title text-[2rem] leading-normal lg:!text-[2.5rem] text-center" itemprop="headline">dbt-for-apache-doris 1.1.0 Released: Five Business Demos to Get Started with Doris Data Engineering</h1><div class="blog-info text-center flex justify-center text-sm text-black"><span class="authors"><span class="s-author text-black">Junwei Chen</span></span><time datetime="2026-09-01T00:00:00.000Z" itemprop="datePublished" class="text-black ml-4">September 1, 2026</time></div></header><div id="__blog-post-container" class="markdown" itemprop="articleBody"><p><a href="https://github.com/velodb/dbt-for-apache-doris" target="_blank" rel="noopener noreferrer">dbt-for-apache-doris</a> 1.1.0 was released on August 12, 2026. It targets dbt Core 1.12, manages Apache Doris asynchronous materialized views through the standard dbt <code>materialized_view</code> materialization, and covers the everyday workflows: Table, View, Incremental, Snapshot, Seed, and Data Test.</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">python -m pip install &quot;dbt-for-apache-doris==1.1.0&quot;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<p>The rest of this post covers what each of the two systems is responsible for, what the adapter supports today, and five demos that run a full pipeline in Doris.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="1-dbt-doris-and-what-110-adds">1. dbt, Doris, and what 1.1.0 adds<a href="https://doris.apache.org/blog/dbt-for-apache-doris-1.1.0-five-demos/#1-dbt-doris-and-what-110-adds" class="hash-link" aria-label="Direct link to 1. dbt, Doris, and what 1.1.0 adds" title="Direct link to 1. dbt, Doris, and what 1.1.0 adds">&#x200B;</a></h2>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="11-what-is-dbt">1.1 What is dbt<a href="https://doris.apache.org/blog/dbt-for-apache-doris-1.1.0-five-demos/#11-what-is-dbt" class="hash-link" aria-label="Direct link to 1.1 What is dbt" title="Direct link to 1.1 What is dbt">&#x200B;</a></h3>
<p>dbt (data build tool) is an open-source data transformation framework that handles the T of ELT inside a data warehouse. Every model is a SQL <code>SELECT</code> statement, and models reference each other with <code>ref()</code>. dbt compiles them into the target database&apos;s table creation and write statements, runs them in dependency order, and materializes each one as a table, view, incremental table, or snapshot according to its configuration.</p>
<p>It exists because the transformation layer spent years without much engineering discipline:</p>
<ul>
<li>SQL is scattered across schedulers, repos, and personal machines. Dependencies are maintained by hand, and nobody can say for certain what a change will break.</li>
<li>Nothing is tested automatically, so a wrong metric usually surfaces when someone in the business questions a number on a report.</li>
<li>There is no version control, no code review, and no separation between development and production, which makes changes hard to trace afterwards.</li>
<li>The same boilerplate for creating tables, writing incrementally, and keeping history gets rewritten in every project.</li>
</ul>
<p>dbt&apos;s answer is models as code, a dependency graph derived from <code>ref()</code>, declarative Data Tests, built-in materializations (Table, View, Incremental, Snapshot), generated documentation and lineage, and a package ecosystem of Jinja macros such as <code>dbt_utils</code>.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="12-what-dbt-and-doris-solve-together">1.2 What dbt and Doris solve together<a href="https://doris.apache.org/blog/dbt-for-apache-doris-1.1.0-five-demos/#12-what-dbt-and-doris-solve-together" class="hash-link" aria-label="Direct link to 1.2 What dbt and Doris solve together" title="Direct link to 1.2 What dbt and Doris solve together">&#x200B;</a></h3>
<p>dbt does not compute anything itself. Every transformation is pushed down to the target database, so that database sets the ceiling for the project. Apache Doris is an MPP real-time analytical database that speaks the MySQL protocol and runs aggregations, multi-table JOINs, and window functions in place. <code>dbt-for-apache-doris</code> connects the two: dbt organizes, orchestrates, and validates the transformation logic; Doris stores the data and executes the SQL.</p>
<p>Putting them together settles a few things that data teams otherwise handle by convention. Table conventions become part of the code, since Doris Key models, partitions, buckets, and table properties are declared in the model&apos;s <code>config()</code> and go through version control and code review with everything else, rather than living in someone&apos;s memory. Late-arriving data gets a defined path too: a write to a Doris Unique Key table is an Upsert, and dbt Incremental <code>merge</code> sits directly on that semantic, so replaying the same batch produces the same table and a failed job can simply be run again.</p>
<p>Pre-aggregation stops being a separate system. Doris asynchronous materialized views join the dbt dependency graph through the standard <code>materialized_view</code> materialization, with build and refresh strategy in the model configuration, so they change and get tested alongside the models they read from. The computation never leaves Doris. dbt only ships SQL, so no second engine is needed to move data around. Quality checks run in the same place: Data Tests, Unit Tests, and Model Contracts all execute against Doris at build time, which is a better moment to catch a broken metric than the morning after a report goes out.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="13-adapter-feature-support">1.3 Adapter feature support<a href="https://doris.apache.org/blog/dbt-for-apache-doris-1.1.0-five-demos/#13-adapter-feature-support" class="hash-link" aria-label="Direct link to 1.3 Adapter feature support" title="Direct link to 1.3 Adapter feature support">&#x200B;</a></h3>
<ol>
<li>
<p><strong>Materializations</strong></p>













































<table><thead><tr><th>Capability</th><th>Status</th><th>Current scope and boundaries</th></tr></thead><tbody><tr><td>Table</td><td>&#x2705;</td><td>Duplicate Key CTAS; configurable HASH bucketing and bucket count, RANGE / LIST partitioning, table properties, Contracts, docs, Grants, and Hooks. Unique Key tables are created by Incremental <code>merge</code></td></tr><tr><td>View</td><td>&#x2705;</td><td>Standard lifecycle, Contracts, docs, Grants, and Hooks; switching relation types is not zero-downtime</td></tr><tr><td>Incremental</td><td>&#x2705;</td><td>Four strategies, <code>append</code>, <code>merge</code>, <code>insert_overwrite</code>, and <code>microbatch</code>, plus every <code>on_schema_change</code> mode (strategy details in the next table)</td></tr><tr><td>Snapshot</td><td>&#x2705;</td><td><code>check</code> / <code>timestamp</code> strategies, hard-delete handling, schema evolution, atomic replacement and recovery; jobs targeting the same relation must be serialized by the scheduler</td></tr><tr><td>Materialized view</td><td>&#x2705;</td><td>Standard dbt <code>materialized_view</code>, implemented as a Doris Async MV; covers the build / refresh lifecycle, task waiting, configuration changes, atomic replacement and recovery; dbt jobs targeting the same relation must be serialized</td></tr><tr><td>Seed</td><td>&#x2705;</td><td>CSV loading, type inference, <code>column_types</code>, and <code>ref()</code></td></tr><tr><td>Ephemeral</td><td>&#x2705;</td><td>Compiled and inlined by dbt Core</td></tr></tbody></table>
</li>
<li>
<p><strong>Incremental strategies and Doris target tables</strong>. When no strategy is specified explicitly, models configured with a <code>unique_key</code> use <code>merge</code> and all others use <code>append</code>.</p>






























<table><thead><tr><th>Strategy</th><th>Doris target table</th><th>Behavior</th></tr></thead><tbody><tr><td><code>append</code></td><td>Duplicate Key table</td><td>Appends rows with <code>INSERT INTO</code></td></tr><tr><td><code>merge</code></td><td>Unique Key table (MoW or MoR)</td><td>Full-row <code>INSERT INTO</code> Upsert based on Unique Key semantics; requires <code>unique_key</code>, does not generate <code>MERGE INTO</code></td></tr><tr><td><code>insert_overwrite</code></td><td>Any writable Doris table</td><td><code>INSERT OVERWRITE</code> of the whole table, specified partitions, or dynamic partitions; does not accept <code>unique_key</code></td></tr><tr><td><code>microbatch</code></td><td>Duplicate Key table with exact RANGE partitions</td><td>Each dbt time window overwrites one named partition; supports hour / day / month / year windows, and batches run serially</td></tr></tbody></table>
</li>
<li>
<p><strong>dbt engineering capabilities</strong></p>























































<table><thead><tr><th>Capability</th><th>Status</th><th>Current scope and boundaries</th></tr></thead><tbody><tr><td>Sources and freshness</td><td>&#x2705;</td><td><code>loaded_at_field</code>, filter, and <code>loaded_at_query</code>; cross-database access is implemented as database-as-schema, not through an External Catalog</td></tr><tr><td>Data Test</td><td>&#x2705;</td><td>Singular, Generic, and Ephemeral tests, plus <code>store_failures</code></td></tr><tr><td>Unit Test</td><td>&#x2705;</td><td>Inline and CSV fixtures, case-insensitive column names, invalid-input validation, reserved-word quoting, and data type fixtures adapted to Doris</td></tr><tr><td>Model Contract</td><td>&#x2705;</td><td>Column name and type constraints for Table, View, and Incremental; not mapped to database primary keys or NOT NULL constraints</td></tr><tr><td>Persisted docs</td><td>&#x2705;</td><td>Table / column comments for Table, View, Incremental, Snapshot, Seed, and Async MV; updating a View comment, or a comment that contains both kinds of quotes, may require a rebuild or full refresh</td></tr><tr><td>Grants</td><td>&#x2705;</td><td>Reconciles Doris table-level privileges for Table, View, Incremental, Seed, Snapshot, and Async MV, supporting <code>user</code> and <code>user@host</code> grantees; role grantees are not handled</td></tr><tr><td>Hooks</td><td>&#x2705;</td><td>pre-hook and post-hook for every materialization; Doris does not provide transactional rollback for hook side effects</td></tr><tr><td>Metadata and dbt docs catalog</td><td>&#x2705;</td><td>Relation discovery and documentation catalog for Doris databases, tables, views, columns, comments, and Async MVs</td></tr><tr><td>Cross-database Sources</td><td>&#x2705;</td><td>References Sources in other Doris databases, including definitions that only declare a database; three-part External Catalog names are not supported</td></tr></tbody></table>
</li>
</ol>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="14-whats-new-in-110">1.4 What&apos;s new in 1.1.0<a href="https://doris.apache.org/blog/dbt-for-apache-doris-1.1.0-five-demos/#14-whats-new-in-110" class="hash-link" aria-label="Direct link to 1.4 What&apos;s new in 1.1.0" title="Direct link to 1.4 What&apos;s new in 1.1.0">&#x200B;</a></h3>
<p>1.1.0 is the first release of <code>dbt-for-apache-doris</code> from its own repository, and the first published to PyPI. It targets dbt Core 1.12 on Python 3.10 and above, manages Doris Async Materialized Views through the standard dbt <code>materialized_view</code> materialization, and ships with explicit version constraints and a stated support boundary.</p>
<p>A <code>materialized_view</code> model maps to a Doris Async MV, and the build mode, refresh strategy, and task waiting are all written in the model configuration:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:hsl(230, 1%, 98%);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="background-color:hsl(230, 1%, 98%);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">{{ config</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    materialized</span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;materialized_view&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    refresh_trigger</span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;manual&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    wait_for_refresh</span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token boolean" style="color:hsl(35, 99%, 36%)">true</span><span class="token plain"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> }}</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">select</span><span class="token plain"> order_date</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token function" style="color:hsl(221, 87%, 60%)">sum</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">amount</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">as</span><span class="token plain"> sales</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">from</span><span class="token plain"> {{ ref</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token string" style="color:hsl(119, 34%, 47%)">&apos;orders&apos;</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> }}</span><br></span><span class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">group</span><span class="token plain"> </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">by</span><span class="token plain"> order_date</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"/></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg></span></button></div></div></div>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="2-five-demos">2. Five demos<a href="https://doris.apache.org/blog/dbt-for-apache-doris-1.1.0-five-demos/#2-five-demos" class="hash-link" aria-label="Direct link to 2. Five demos" title="Direct link to 2. Five demos">&#x200B;</a></h2>
<p>Each demo starts from a business question:</p>















































<table><thead><tr><th>#</th><th>Demo</th><th>Business question</th><th>Transformation and result</th><th>Key capabilities</th></tr></thead><tbody><tr><td>01</td><td>Daily order summary</td><td>How many valid orders and how much revenue per day and per month?</td><td>Filter out cancelled, returned, and failed orders; produce a daily Table and a monthly Async MV</td><td>Source, Table, Data Test, partitioning and bucketing, Async MV</td></tr><tr><td>02</td><td>Customer geography analysis</td><td>Which states are customers, orders, and revenue concentrated in?</td><td>Read addresses and orders from two Doris databases; output state-level business metrics</td><td>Cross-database Source, View, <code>ref()</code>, Table</td></tr><tr><td>03</td><td>Ad data integration</td><td>How to unify Google, Meta, and TikTok data?</td><td>Load three kinds of CSV with Seeds, align fields, and deduplicate; output daily channel details</td><td>Seed, <code>dbt_utils</code>, <code>QUALIFY</code>, Data Test</td></tr><tr><td>04</td><td>Late-arriving orders</td><td>How to absorb late corrections and avoid duplicate orders?</td><td>Identify order versions and maintain the current state with Incremental <code>merge</code></td><td>Incremental, Unique Key, idempotency</td></tr><tr><td>05</td><td>Customer history tracking</td><td>How to keep the history of attribute changes and hard deletes?</td><td>Two Snapshot rounds produce SCD Type 2 history and a current customer dimension table</td><td>Snapshot, Hard Delete, <code>ref()</code>, Data Test</td></tr></tbody></table>
<blockquote>
<p>The demos are selected and adapted from the Snowflake Labs <a href="https://github.com/Snowflake-Labs/data-eng-bench" target="_blank" rel="noopener noreferrer"><code>data-eng-bench</code></a> scenarios (the original project is licensed under the Apache License 2.0). We rewrote the profiles, SQL, fixtures, verifiers, and notebooks for Apache Doris and <code>dbt-for-apache-doris</code>.</p>
<p>Demo repository: <a href="https://github.com/velodb/dbt-for-apache-doris/tree/main/examples" target="_blank" rel="noopener noreferrer">https://github.com/velodb/dbt-for-apache-doris/tree/main/examples</a></p>
</blockquote>
<p>Two of them are walked through below. For the other three, customer geography analysis, ad data integration, and customer history tracking, the <a href="https://github.com/velodb/dbt-for-apache-doris/tree/main/examples/doris-demos" target="_blank" rel="noopener noreferrer">Doris dbt demos README</a> has the business description, the model list, and the exact commands.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="21-demo-01-order-summary-and-asynchronous-materialized-views">2.1 Demo 01: Order summary and asynchronous materialized views<a href="https://doris.apache.org/blog/dbt-for-apache-doris-1.1.0-five-demos/#21-demo-01-order-summary-and-asynchronous-materialized-views" class="hash-link" aria-label="Direct link to 2.1 Demo 01: Order summary and asynchronous materialized views" title="Direct link to 2.1 Demo 01: Order summary and asynchronous materialized views">&#x200B;</a></h3>
<p>The demo starts from 6 orders in Doris, drops the <code>CANCELLED</code>, <code>RETURNED</code>, and <code>FAILED</code> ones, and builds <code>daily_order_summary</code>. Data Tests check that dates are unique and key columns are not null, and <code>monthly_order_summary_mv</code> then aggregates the daily table through <code>ref()</code>.</p>
<p><img decoding="async" loading="lazy" alt="Demo 01 transformation flow: on the dbt side, source(), Table, ref(), and materialized_view; the orders source is filtered into daily_order_summary, checked by Data Tests, and aggregated into monthly_order_summary_mv; on the Doris side, Duplicate Key, Range Partition, Hash Bucket, and Async MV" src="https://assets-cdn.selectdb.com/site/assets/shared/85d79f22e1996d42f084ea796ccb01a1.jpg" width="1731" height="909" class="img_ev3q"></p>
<p><em>Figure 1: The chain from raw orders to the monthly asynchronous materialized view. The top row is what dbt handles: model dependencies, materialization, and tests. The bottom row is what Doris provides for the table model and the materialized view.</em></p>
<p>Three orders survive the filter, for a monthly revenue of <code>220.20</code>. dbt owns the model dependencies (<code>source()</code> through <code>ref()</code>), the materializations, and the Data Tests. Doris decides how the two result tables are stored and how fast they answer:</p>

























<table><thead><tr><th>Doris capability</th><th>What it does here</th></tr></thead><tbody><tr><td>Duplicate Key model</td><td><code>daily_order_summary</code> is created with <code>order_date</code> as its sort key. Rows are stored as written, with no aggregation or merging. Date range queries use the prefix index, so daily report queries hit it directly. dbt <code>table</code> rebuilds the whole table with CTAS on every run, so the result is reproducible</td></tr><tr><td>RANGE partitioning (by <code>order_date</code>)</td><td>The model pre-creates the <code>p202608</code> partition and the catch-all <code>pmax</code> partition through <code>partition_by_init</code>. A monthly query scans one partition, and old data can be archived or dropped by month</td></tr><tr><td>HASH bucketing (by <code>order_date</code>)</td><td>Data is distributed across BE nodes by the bucket key and computed in parallel. The demo runs on a single node with 1 bucket; production raises the bucket count as data grows</td></tr><tr><td>Asynchronous materialized view (Async MV)</td><td><code>monthly_order_summary_mv</code> pre-aggregates on top of the daily table, so the monthly dashboard reads precomputed results and does not re-aggregate on every open. <code>build_mode=&apos;immediate&apos;</code> produces data as soon as the view is built, <code>refresh_method=&apos;auto&apos;</code> lets Doris choose between a full refresh and a partition-level one, and <code>refresh_trigger=&apos;manual&apos;</code> makes each dbt run trigger a refresh and wait for it; a scheduled refresh (<code>schedule</code>) or a refresh on base table commit (<code>commit</code>) works as well. The materialized view itself also takes Keys, bucketing, and table properties</td></tr></tbody></table>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="22-demo-04-incremental-updates-for-late-arriving-orders">2.2 Demo 04: Incremental updates for late-arriving orders<a href="https://doris.apache.org/blog/dbt-for-apache-doris-1.1.0-five-demos/#22-demo-04-incremental-updates-for-late-arriving-orders" class="hash-link" aria-label="Direct link to 2.2 Demo 04: Incremental updates for late-arriving orders" title="Direct link to 2.2 Demo 04: Incremental updates for late-arriving orders">&#x200B;</a></h3>
<p>The demo writes orders 101, 102, and 103, then receives two late events: the amount of order 101 is corrected from <code>100.00</code> to <code>125.00</code>, and a new order 104 arrives.</p>
<p>Two steps absorb them:</p>
<ol>
<li><code>order_version_history</code> uses window functions to identify the current version of each order.</li>
<li><code>incremental_daily_sales</code> takes <code>order_id</code> as its business key and runs Incremental <code>merge</code> on top of the Upsert semantics of the Doris Unique Key model.</li>
</ol>
<p><img decoding="async" loading="lazy" alt="Demo 04 transformation flow: late events for orders 101 and 104 enter the order events table, order_version_history identifies order versions, incremental_daily_sales is updated by Incremental merge with unique_key = order_id and stays unchanged on re-run, and reconciliation models are checked by Data Tests; on the Doris side, window functions, Unique Key upsert, and Hash Bucket" src="https://assets-cdn.selectdb.com/site/assets/shared/8392180d4202d9e0b321ad5002d31e38.jpg" width="1728" height="910" class="img_ev3q"></p>
<p><em>Figure 2: Late events reach the source table, then version identification and Incremental <code>merge</code> update the current orders; a re-run with no new data leaves the result alone. The top row is what dbt handles, the bottom row is what Doris provides.</em></p>
<p>Run it again with no new data and nothing moves. <code>incremental_daily_sales</code> holds 4 orders, order 101 now at <code>125.00</code>, and revenue for August 1 in the downstream <code>daily_sales_summary</code> becomes <code>245.00</code>. The same project also builds data quality, arrival latency, and revenue reconciliation models. dbt&apos;s part is the incremental model definition, the <code>is_incremental()</code> filter, and the uniqueness test on <code>order_id</code>. The &quot;no duplicates, safe to re-run&quot; property comes from Doris:</p>





























<table><thead><tr><th>Doris capability</th><th>What it does here</th></tr></thead><tbody><tr><td>Unique Key model</td><td><code>incremental_daily_sales</code> is created with <code>order_id</code> as its Unique Key. A new version of an order overwrites the old one on write, so the table always holds exactly one row per order and the <code>unique</code> test passes. The adapter enables Merge-on-Write by default, so deduplication happens at write time and queries have nothing left to merge</td></tr><tr><td>Upsert on write (Incremental <code>merge</code>)</td><td>The adapter performs a full-row Upsert with a plain <code>INSERT INTO</code>, with no <code>MERGE INTO</code> and no delete-then-insert. The correction to order 101 and the new order 104 take the same write path, and re-running with no new data leaves the result unchanged, which is what makes backfills and retries safe</td></tr><tr><td>HASH bucketing (by <code>order_id</code>)</td><td>The bucket key matches the primary key, so every version of an order lands in the same tablet, and primary key deduplication and updates complete inside it without comparing across nodes</td></tr><tr><td>Window functions</td><td><code>order_version_history</code> uses <code>row_number()</code> and <code>lead()</code> inside Doris to mark the current version of each order and compute <code>valid_from</code> / <code>valid_to</code>. The version history is auditable, and no external program is involved</td></tr><tr><td>Online schema change</td><td>The model sets <code>on_schema_change=&apos;append_new_columns&apos;</code>. When an upstream model adds a column, the adapter syncs the table structure with <code>ALTER TABLE ... ADD COLUMN</code> and waits for the change to finish, so the incremental table never needs a rebuild</td></tr></tbody></table>
<p>All five demos run as JupyterLab notebooks, one step per cell, so you can stop at any cell and look at what Doris wrote. They live in the repository&apos;s <code>examples/</code> directory, with <a href="https://github.com/velodb/dbt-for-apache-doris/tree/main/examples/doris-demos" target="_blank" rel="noopener noreferrer"><code>examples/doris-demos</code></a> as the entry point; its README has the full run instructions.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="links">Links<a href="https://doris.apache.org/blog/dbt-for-apache-doris-1.1.0-five-demos/#links" class="hash-link" aria-label="Direct link to Links" title="Direct link to Links">&#x200B;</a></h2>
<ul>
<li>GitHub repository: <a href="https://github.com/velodb/dbt-for-apache-doris" target="_blank" rel="noopener noreferrer">https://github.com/velodb/dbt-for-apache-doris</a></li>
<li>1.1.0 release: <a href="https://github.com/velodb/dbt-for-apache-doris/releases/tag/v1.1.0" target="_blank" rel="noopener noreferrer">https://github.com/velodb/dbt-for-apache-doris/releases/tag/v1.1.0</a></li>
<li>PyPI: <a href="https://pypi.org/project/dbt-for-apache-doris/1.1.0/" target="_blank" rel="noopener noreferrer">https://pypi.org/project/dbt-for-apache-doris/1.1.0/</a></li>
<li>Demo entry point: <a href="https://github.com/velodb/dbt-for-apache-doris/tree/main/examples/doris-demos" target="_blank" rel="noopener noreferrer">https://github.com/velodb/dbt-for-apache-doris/tree/main/examples/doris-demos</a></li>
<li>Apache Doris all-in-one image: <a href="https://doris.apache.org/community/developer-guide/all-in-one-image/">https://doris.apache.org/community/developer-guide/all-in-one-image</a></li>
</ul></div>]]></content:encoded>
            <category>Tech Sharing</category>
        </item>
        <item>
            <title><![CDATA[Dynamic JSON in Agent Workloads: Apache Doris vs ClickHouse, Elasticsearch, and OpenSearch]]></title>
            <link>https://doris.apache.org/blog/dynamic-json-in-agent-workloads-apache-doris-clickhouse-elasticsearch-and-opensearch/</link>
            <guid>https://doris.apache.org/blog/dynamic-json-in-agent-workloads-apache-doris-clickhouse-elasticsearch-and-opensearch/</guid>
            <pubDate>Thu, 27 Aug 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[AI agent logs create wide, fast-changing JSON payloads that are difficult to analyze with predictable latency. We compare how Apache Doris, ClickHouse, Elasticsearch, and OpenSearch perform in such scenario.]]></description>
            <content:encoded><![CDATA[<header><div class="text-center mb-4"><a class="cursor-pointer hover:no-underline" lang="en" href="https://doris.apache.org/blog/">Blog</a><span class="px-2 text-[#8592A6]">/</span><span><span class="s-tags" lang="en"><span class="s-tag">Tech Sharing</span></span></span></div><h1 lang="en" class="blog-post-title text-[2rem] leading-normal lg:!text-[2.5rem] text-center" itemprop="headline">Dynamic JSON in Agent Workloads: Apache Doris vs ClickHouse, Elasticsearch, and OpenSearch</h1><div class="blog-info text-center flex justify-center text-sm text-black"><span class="authors"><span class="s-author text-black">velodb.io &#xB7; Max Li</span></span><time datetime="2026-08-27T00:00:00.000Z" itemprop="datePublished" class="text-black ml-4">August 27, 2026</time></div></header><div id="__blog-post-container" class="markdown" itemprop="articleBody"><blockquote>
<a class="blog-item-link" rel="noopener noreferrer" target="_blank" href="https://www.velodb.io/blog/dynamic-json-in-agent-workloads-apache-doris-clickhouse-elasticsearch-and-opensearch">AI agent logs create wide, fast-changing JSON payloads that are difficult to analyze with predictable latency. We compare how Apache Doris, ClickHouse, Elasticsearch, and OpenSearch perform in such scenario. <span lang="en" style="color:var(--ifm-color-primary);display:inline-flex;align-items:center;gap:4px">Read the original (English)<!-- --> <svg width="1rem" height="1rem" viewBox="0 0 18 18" fill="none"><path d="M14.8497 8.99993L14.8497 14.5349C14.8497 14.8332 14.6079 15.0749 14.3097 15.0749H3.68966C3.39142 15.0749 3.14966 14.8332 3.14966 14.5349V3.46493C3.14966 3.16669 3.39142 2.92493 3.68966 2.92493H8.53166" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M11.4746 2.92493H14.3096C14.6078 2.92493 14.8496 3.16669 14.8496 3.46493V6.29993" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M13.9944 3.82495L8.90322 8.91612" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg></span></a>
</blockquote></div>]]></content:encoded>
            <category>Tech Sharing</category>
        </item>
        <item>
            <title><![CDATA[PostgreSQL CDC to Apache Doris: Real-Time Sync with One SQL Statement]]></title>
            <link>https://doris.apache.org/blog/postgresql-cdc-to-apache-doris-real-time-sync-with-one-sql-statement/</link>
            <guid>https://doris.apache.org/blog/postgresql-cdc-to-apache-doris-real-time-sync-with-one-sql-statement/</guid>
            <pubDate>Fri, 21 Aug 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[Apache Doris offers native CDC for PostgreSQL, replacing separate CDC, Kafka, Flink, or Spark components with one built-in streaming job.]]></description>
            <content:encoded><![CDATA[<header><div class="text-center mb-4"><a class="cursor-pointer hover:no-underline" lang="en" href="https://doris.apache.org/blog/">Blog</a><span class="px-2 text-[#8592A6]">/</span><span><span class="s-tags" lang="en"><span class="s-tag">Tech Sharing</span></span></span></div><h1 lang="en" class="blog-post-title text-[2rem] leading-normal lg:!text-[2.5rem] text-center" itemprop="headline">PostgreSQL CDC to Apache Doris: Real-Time Sync with One SQL Statement</h1><div class="blog-info text-center flex justify-center text-sm text-black"><span class="authors"><span class="s-author text-black">velodb.io &#xB7; Dylan Wu</span></span><time datetime="2026-08-21T00:00:00.000Z" itemprop="datePublished" class="text-black ml-4">August 21, 2026</time></div></header><div id="__blog-post-container" class="markdown" itemprop="articleBody"><blockquote>
<a class="blog-item-link" rel="noopener noreferrer" target="_blank" href="https://www.velodb.io/blog/postgresql-cdc-to-apache-doris-real-time-sync-with-one-sql-statement">Apache Doris offers native CDC for PostgreSQL, replacing separate CDC, Kafka, Flink, or Spark components with one built-in streaming job. <span lang="en" style="color:var(--ifm-color-primary);display:inline-flex;align-items:center;gap:4px">Read the original (English)<!-- --> <svg width="1rem" height="1rem" viewBox="0 0 18 18" fill="none"><path d="M14.8497 8.99993L14.8497 14.5349C14.8497 14.8332 14.6079 15.0749 14.3097 15.0749H3.68966C3.39142 15.0749 3.14966 14.8332 3.14966 14.5349V3.46493C3.14966 3.16669 3.39142 2.92493 3.68966 2.92493H8.53166" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M11.4746 2.92493H14.3096C14.6078 2.92493 14.8496 3.16669 14.8496 3.46493V6.29993" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M13.9944 3.82495L8.90322 8.91612" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg></span></a>
</blockquote></div>]]></content:encoded>
            <category>Tech Sharing</category>
        </item>
        <item>
            <title><![CDATA[From Spark to Apache Doris: How Kwai Made A/B Testing Metrics 145x Faster at Scale]]></title>
            <link>https://doris.apache.org/blog/from-spark-to-apache-doris-how-kwai-made-a-b-testing-metrics-145x-faster-at-scale/</link>
            <guid>https://doris.apache.org/blog/from-spark-to-apache-doris-how-kwai-made-a-b-testing-metrics-145x-faster-at-scale/</guid>
            <pubDate>Wed, 12 Aug 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[Kwai migrated its company-wide A/B testing metrics pipeline from Spark to Apache Doris. The rebuild delivered 145x faster metrics computation and cut resource consumption by 72%.]]></description>
            <content:encoded><![CDATA[<header><div class="text-center mb-4"><a class="cursor-pointer hover:no-underline" lang="en" href="https://doris.apache.org/blog/">Blog</a><span class="px-2 text-[#8592A6]">/</span><span><span class="s-tags" lang="en"><span class="s-tag">Best Practice</span></span></span></div><h1 lang="en" class="blog-post-title text-[2rem] leading-normal lg:!text-[2.5rem] text-center" itemprop="headline">From Spark to Apache Doris: How Kwai Made A/B Testing Metrics 145x Faster at Scale</h1><div class="blog-info text-center flex justify-center text-sm text-black"><span class="authors"><span class="s-author text-black">Kwai &#xB7; Siwei Zeng</span></span><time datetime="2026-08-12T00:00:00.000Z" itemprop="datePublished" class="text-black ml-4">August 12, 2026</time></div></header><div id="__blog-post-container" class="markdown" itemprop="articleBody"><blockquote>
<a class="blog-item-link" rel="noopener noreferrer" target="_blank" href="https://www.velodb.io/blog/from-spark-to-apache-doris-how-kwai-made-a-b-testing-metrics-145x-faster-at-scale">Kwai migrated its company-wide A/B testing metrics pipeline from Spark to Apache Doris. The rebuild delivered 145x faster metrics computation and cut resource consumption by 72%. <span lang="en" style="color:var(--ifm-color-primary);display:inline-flex;align-items:center;gap:4px">Read the original (English)<!-- --> <svg width="1rem" height="1rem" viewBox="0 0 18 18" fill="none"><path d="M14.8497 8.99993L14.8497 14.5349C14.8497 14.8332 14.6079 15.0749 14.3097 15.0749H3.68966C3.39142 15.0749 3.14966 14.8332 3.14966 14.5349V3.46493C3.14966 3.16669 3.39142 2.92493 3.68966 2.92493H8.53166" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M11.4746 2.92493H14.3096C14.6078 2.92493 14.8496 3.16669 14.8496 3.46493V6.29993" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M13.9944 3.82495L8.90322 8.91612" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg></span></a>
</blockquote></div>]]></content:encoded>
            <category>Best Practice</category>
        </item>
    </channel>
</rss>