live wire
▸EKOS submits 70.15% on BIRD’s hidden test and 88.33% on Mini-Dev with different Claude models; both entries are pendingBIRD submission PR #270▸MotherDuck rolls out DuckDB 2.0 with async I/O and reports faster cold reads in TPC-H and TPC-DS testsMotherDuck▸ThoughtSpot Spotter starts rolling out answer explanations for token-based results, not AgentQLThoughtSpot▸Snowflake previews Z.ai GLM 5.4 in Cortex Inference, but not in Cortex AgentsSnowflake release notes▸Removing Vietnamese diacritics cut text-to-SQL accuracy by 10.3–37.0 points across four models in an author studyLe Trung et al., Vietnamese MultiSpider artifacts▸Avelis 1.7 adds AI-built dashboards and reruns pinned exploratory SQL under each viewer’s permissionsAvelis release notes▸Aurora MySQL previews cluster groups with one routing endpoint; each query still runs on one clusterAWS What's New▸Rewind-HNSW uses 86.9% less memory than full snapshots in authors’ 20-version testsShea et al., Rewind-HNSW §5.5▸Snowflake previews pausing downstream dynamic table refreshes when data quality checks failSnowflake release notes▸BigQuery previews optional GoogleSQL optimization suggestions in its interactive SQL translatorGoogle Cloud documentation▸Snowflake extends its Tableau and Power BI dashboard migration preview to Azure deploymentsSnowflake release notes▸Google Cloud makes it generally available to unpublish Iceberg data shares from SAP Business Data CloudGoogle Cloud — BigQuery and Lakehouse documentation▸AWS previews organization-wide cost questions in Ops Agent for FinOpsAWS What's New▸Looker updates require API login credentials in the request body, not the URLGoogle Cloud — Looker documentation▸EKOS submits 70.15% on BIRD’s hidden test and 88.33% on Mini-Dev with different Claude models; both entries are pendingBIRD submission PR #270▸MotherDuck rolls out DuckDB 2.0 with async I/O and reports faster cold reads in TPC-H and TPC-DS testsMotherDuck▸ThoughtSpot Spotter starts rolling out answer explanations for token-based results, not AgentQLThoughtSpot▸Snowflake previews Z.ai GLM 5.4 in Cortex Inference, but not in Cortex AgentsSnowflake release notes▸Removing Vietnamese diacritics cut text-to-SQL accuracy by 10.3–37.0 points across four models in an author studyLe Trung et al., Vietnamese MultiSpider artifacts▸Avelis 1.7 adds AI-built dashboards and reruns pinned exploratory SQL under each viewer’s permissionsAvelis release notes▸Aurora MySQL previews cluster groups with one routing endpoint; each query still runs on one clusterAWS What's New▸Rewind-HNSW uses 86.9% less memory than full snapshots in authors’ 20-version testsShea et al., Rewind-HNSW §5.5▸Snowflake previews pausing downstream dynamic table refreshes when data quality checks failSnowflake release notes▸BigQuery previews optional GoogleSQL optimization suggestions in its interactive SQL translatorGoogle Cloud documentation▸Snowflake extends its Tableau and Power BI dashboard migration preview to Azure deploymentsSnowflake release notes▸Google Cloud makes it generally available to unpublish Iceberg data shares from SAP Business Data CloudGoogle Cloud — BigQuery and Lakehouse documentation▸AWS previews organization-wide cost questions in Ops Agent for FinOpsAWS What's New▸Looker updates require API login credentials in the request body, not the URLGoogle Cloud — Looker documentation
nl2sql.ai
guideSQL CORRECTNESS

DuckDB UNNEST can put spend on the wrong campaign when lists are out of order

Side-by-side UNNEST pairs values by position, not by key. Equal list lengths don’t prove that the pairs are right.

By The News Desk· Nov 30, 2026the quick take — two AI hosts go live when you do

A query that asks for spend by campaign can return plausible totals for the wrong campaigns if it flattens two independently assembled lists. DuckDB’s UNNEST documentation says that multiple list expressions in the same SELECT are aligned by position. The shorter list is padded with NULL. Neither operation checks that a spend value belongs to the campaign it lands beside.

Equal lengths don’t catch the error

Suppose a campaign list is ordered spring, summer, but a separate spend export is ordered summer, spring, with amounts 90 and 30. A generated query that combines the arrays might look like this:

SELECT unnest(['spring', 'summer']) AS campaign,
       unnest([90, 30]) AS spend;

By DuckDB’s documented rule, the first pair is spring, 90 and the second is summer, 30. The correct attribution in this example is the reverse. Both lists contain two entries and the spend still totals 120, so checking the lengths or the grand total would miss the error. If the amount list contained only [90], the same rule would put 90 beside spring and pad summer with NULL; the padding would not tell you which campaign the 90 actually belonged to.

Keep the key with the amount

If the source is nested, preserve the campaign key and spend in the same record. DuckDB documents that recursive UNNEST can flatten a list of structs into rows and columns:

SELECT unnest([
  {'campaign': 'summer', 'spend': 90},
  {'campaign': 'spring', 'spend': 30}
], recursive := true);

If you already have two keyed tables, join on the campaign ID at the intended reporting grain rather than relying on row order. If the spend list has lost its keys and the source never guaranteed alignment, recover the mapping upstream rather than guessing. For a text-to-SQL regression test, reverse one keyed input’s order and check the amount for each campaign, not just the total. A query that preserves the keys should still report 30 for spring and 90 for summer.

Filed by The News Desk. Corrections: desk@nl2sql.ai · Our standards →

comments · 0

    Comments are moderated before they appear. Your email is used once to confirm it is you — never shown, never sold. Corrections and questions get an answer from the desk when we have one.