The Same DuckDB Table, Two Definitions, Two Opposite Trends A developer reproduced AVA's synthetic retail dataset totals in DuckDB, showing that the same 18,971-line-item table yields opposite net-sales trends depending on the metric definition: finance net sales fell 13.87% from August to September 2026 (CNY 4,293,025.42 to 3,697,575.18), while trading net sales rose 15.77% (CNY 6,740,687.05 to 7,803,998.06). The totals, published in the dataset README, were cross-checked via a direct Python pass over the CSV and AVA's CLI, which runs queries on DuckDB through @antv/ava@4.0.5. The walkthrough stresses that AVA's query command does not call a model or rewrite SQL from a semantic file, so the finance or trading definition must appear explicitly in the statement executed. DuckDB is often the right tool when you want local SQL over files, without standing up a database server. This walkthrough stays in that world: one CSV, explicit DuckDB SQL, and totals you can check. The catch is not the engine. It is the metric. I used AVA's official synthetic retail dataset — 18,971 line items, 15,510 orders, snapshot date 2026-10-05 — from the retail-semantics https://github.com/antvis/AVA/tree/ai/data/retail-semantics folder on the ai branch of antvis/AVA https://github.com/antvis/AVA . Under the project's finance definition, net sales fell from CNY 4,293,025.42 in August 2026 to CNY 3,697,575.18 in September, a drop of CNY 595,450.24, or 13.87%. Under the trading definition, net sales rose from CNY 6,740,687.05 to CNY 7,803,998.06, an increase of CNY 1,063,311.01, or 15.77%. Those totals are published in the dataset README and were independently cross-checked there. I reproduced them in two ways on 2 December 2026: a direct pass over the CSV in Python, and AVA's CLI, which runs the queries on its default Node.js engine, DuckDB. Both routes matched. This is a follow-up to Give Your Coding Agent Inspectable Data Analysis Without a Second Model Key https://dev.to/yvonneyx/give-your-coding-agent-inspectable-data-analysis-without-a-second-model-key-466m , which used an 8-row sample. The idea is the same: if you cannot read the SQL, you cannot trust the trend. The file is synthetic. It is not a real company. It also has no inventory, traffic, or advertising events, so a change in net sales is not evidence of a stockout or a campaign. AVA https://ava.antv.vision 4.0 is an open-source TypeScript framework from AntV for data analysis and visualization in JavaScript applications and AI agents. In the Node.js SDK, omitting engine selects DuckDB. The engine creates an in-memory DuckDB instance, registers your sources as tables or views, and executes SQL you provide with query or ava query on the CLI . That is documented in the engine overview https://ava.antv.vision/documentation/engines/overview/ and the DuckDB engine guide https://ava.antv.vision/documentation/engines/duckdb/ . This walkthrough used @antv/ava@4.0.5 , which depends on @duckdb/node-api . A local install on 2 December 2026 resolved @duckdb/node-api@2.0.0-r.1 . I am not treating that npm tag as identical to a specific DuckDB LTS blog announcement. query does not call a model and does not rewrite your SQL from a semantic file. If you want the finance or trading definition, it has to appear in the statement you run. Commands such as analyze and suggest are different: they need model configuration. The earlier article covers that boundary. DuckDB inside AVA is also not a full-privilege SQL shell. The engine guide describes several safeguards for model-generated SQL, and they apply here too: SELECT including WITH ; writes and multi-statement queries are rejected maxRows / maxResultBytes on returned rows The CSV is about 4.6 MB. Download it from the official repository default branch name: ai : curl -fsSL -o sales.csv \ https://raw.githubusercontent.com/antvis/AVA/ai/data/retail-semantics/sales.csv You need Node.js 22.13 or later. You can install the CLI globally with npm install -g @antv/ava , or use a project-local binary: npm install @antv/ava@4.0.5 npx ava source sales.csv session.json DATASET ID=$ node -p 'JSON.parse require "fs" .readFileSync "session.json", "utf8" .datasetId' npx ava schema "$DATASET ID" schema.json Redirecting source matters: the CLI prints a guide in a terminal and JSON when piped or redirected. Read schema.json before writing SQL. For this single CSV, the DuckDB loader exposes one table named data . The schema language is duckdb-sql . There are 29 columns, including paid at , completed at , status , order kind , business model , selling store name , channel , product name , line paid amount , refund amount , and commission rate . In this snapshot, every self operated line has commission rate of 1 , and every consignment line has 0.03 . That is why the official finance formula — which always multiplies by commission rate — matches the prose that company-owned lines recognize the full paid amount minus refund, while consignment lines recognize commission only. Do not assume those rates on another file; read the data. Both definitions come from the published semantic files in the same folder. I am quoting the rules and the net revenue expressions, not inventing a third metric. Finance semantic-finance.json : net sales are recognized revenue on external customer orders that have been fulfilled. Keep order kind = 'customer sale' and status = 'completed' . Attribute the line to the calendar month of completed at . Refunds in the 2026-10-05 snapshot are applied back to the original fulfillment month, not to refunded at . The official net revenue expression is: SUM CASE WHEN order kind = 'customer sale' AND status IN 'completed' THEN ROUND CAST line paid amount AS DECIMAL 18, 2 CAST commission rate AS DECIMAL 6, 4 , 2 - ROUND COALESCE CAST refund amount AS DECIMAL 18, 2 , 0 CAST commission rate AS DECIMAL 6, 4 , 2 ELSE 0 END Trading semantic-trading.json : net sales are net payments from external customers. Keep order kind = 'customer sale' and status in completed , shipped , or paid . Attribute the line to the calendar month of paid at . Company-owned and consignment lines both use the full line payment minus refund, with no commission multiplier. Paid but not-yet-fulfilled orders are included. Refunds are applied back to the original payment month. SUM CASE WHEN order kind = 'customer sale' AND status IN 'completed', 'shipped', 'paid' THEN CAST line paid amount AS DECIMAL 18, 2 - COALESCE CAST refund amount AS DECIMAL 18, 2 , 0 ELSE 0 END Attribution is also defined: use selling store for sales responsibility. fulfillment is where the order was fulfilled, and a centralized warehouse should not reassign the selling store. Save this as query-finance-months.sql : SELECT date trunc 'month', CAST completed at AS DATE AS month, SUM CASE WHEN order kind = 'customer sale' AND status IN 'completed' THEN ROUND CAST line paid amount AS DECIMAL 18, 2 CAST commission rate AS DECIMAL 6, 4 , 2 - ROUND COALESCE CAST refund amount AS DECIMAL 18, 2 , 0 CAST commission rate AS DECIMAL 6, 4 , 2 ELSE 0 END AS net revenue FROM data WHERE CAST completed at AS DATE = DATE '2026-08-01' AND CAST completed at AS DATE < DATE '2026-10-01' GROUP BY 1 ORDER BY 1; And this as query-trading-months.sql : SELECT date trunc 'month', CAST paid at AS DATE AS month, SUM CASE WHEN order kind = 'customer sale' AND status IN 'completed', 'shipped', 'paid' THEN CAST line paid amount AS DECIMAL 18, 2 - COALESCE CAST refund amount AS DECIMAL 18, 2 , 0 ELSE 0 END AS net revenue FROM data WHERE CAST paid at AS DATE = DATE '2026-08-01' AND CAST paid at AS DATE < DATE '2026-10-01' GROUP BY 1 ORDER BY 1; npx ava query "$DATASET ID" --dsl @query-finance-months.sql npx ava query "$DATASET ID" --dsl @query-trading-months.sql You should see: | Definition | August CNY | September CNY | Change CNY | Change | |---|---|---|---|---| | Finance | 4,293,025.42 | 3,697,575.18 | −595,450.24 | −13.87% | | Trading | 6,740,687.05 | 7,803,998.06 | +1,063,311.01 | +15.77% | The CLI returns month as a timestamp, such as 2026-08-01 00:00:00 . The net revenue type in this run was DECIMAL 38,2 . Nothing in DuckDB "chose" a trend. The two statements include different statuses, use different date columns, and treat consignment income differently. If an agent only prints "sales were down in September," you cannot tell which of those choices it made. The finance semantic file says to locate change by absolute amount, keep offsetting gains, and use selling store, channel, and product together. This query lists the five largest finance declines at that grain: WITH monthly AS SELECT selling store name, channel, product name, date trunc 'month', CAST completed at AS DATE AS month, SUM CASE WHEN order kind = 'customer sale' AND status IN 'completed' THEN ROUND CAST line paid amount AS DECIMAL 18, 2 CAST commission rate AS DECIMAL 6, 4 , 2 - ROUND COALESCE CAST refund amount AS DECIMAL 18, 2 , 0 CAST commission rate AS DECIMAL 6, 4 , 2 ELSE 0 END AS net revenue FROM data WHERE CAST completed at AS DATE = DATE '2026-08-01' AND CAST completed at AS DATE < DATE '2026-10-01' GROUP BY 1, 2, 3, 4 SELECT selling store name, channel, product name, SUM CASE WHEN month = DATE '2026-08-01' THEN net revenue ELSE 0 END AS august cny, SUM CASE WHEN month = DATE '2026-09-01' THEN net revenue ELSE 0 END AS september cny, SUM CASE WHEN month = DATE '2026-09-01' THEN net revenue ELSE 0 END - SUM CASE WHEN month = DATE '2026-08-01' THEN net revenue ELSE 0 END AS change cny FROM monthly GROUP BY 1, 2, 3 ORDER BY change cny LIMIT 5; The first row is 深圳南山店 / 线上商城 / 电动升降桌: August CNY 1,790,783.35, September CNY 1,232,006.98, change CNY −558,776.37. That single combination accounts for most of the CNY 595,450.24 finance decline. Grouping only by selling store name shows that 广州天河店 moved the other way, from CNY 518,590.81 to CNY 585,304.12, or +CNY 66,713.31, which offsets part of the drop. Both figures match the dataset README. The file still cannot tell you why those combinations moved. There is no stock or media table to join. npx ava dispose "$DATASET ID" Sessions expire after 30 idle minutes. If that happens, load the source again and use the new dataset ID. It is not a benchmark of DuckDB, and it is not a claim that AVA replaces the DuckDB CLI for every workflow. If you already have a DuckDB script, you can run the same SQL there and compare. AVA's value in this path is a Node.js session around DuckDB, with inspectable query results, and — separately, when you want it — an agent skill that is supposed to show you the statement it ran. It is also not a head-to-head with PandasAI https://docs.pandas-ai.com/v3/introduction . PandasAI is a Python library for asking questions of data in natural language. AVA's README describes AVA as a JavaScript-ecosystem counterpart, but there is no official PandasAI Node.js SDK in the PandasAI documentation I reviewed, and this article does not run both tools on the same question. A fair comparison belongs in a later piece, with documented features and no invented integration. This article was drafted with AI assistance and reviewed against AVA's official documentation and the published retail-semantics files. The queries were executed locally with @antv/ava@4.0.5 on 2 December 2026, and the monthly totals were also recomputed directly from the CSV. I am affiliated with work on AVA's developer content.