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 PRACTITIONER GUIDE

PostgreSQL’s range_merge can count an outage as uptime

Two service windows can span five hours but cover only four. A SQL agent needs to know which duration the question asks for.

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

Ask a SQL agent how long a service was available, and a query that subtracts the earliest start from the latest end can give a plausible but wrong answer. In a hypothetical log with service from 09:00 to 11:00 and again from noon to 14:00, the elapsed span is five hours. The windows cover only four. The hour in between is not uptime.

Merge the coverage, not just the endpoints

The distinction is built into PostgreSQL’s range functions. range_merge returns the smallest single range that contains its inputs. PostgreSQL’s own integer example merges [1,2) and [3,4) into [1,4), including the gap. That is useful when a question asks for the span from the first recorded start to the last recorded end. It is not the right measure when the question asks for the amount of time covered by the recorded windows.

For coverage, range_agg computes the union of non-null ranges as a multirange. The range reference documents how to expand that multirange with unnest and extract the lower and upper bounds of each piece. In this example, the union keeps the two windows separate, so summing their durations excludes the gap:

WITH service_windows(w) AS (
  VALUES
    (tsrange(TIMESTAMP '2026-11-28 09:00', TIMESTAMP '2026-11-28 11:00', '[)')),
    (tsrange(TIMESTAMP '2026-11-28 12:00', TIMESTAMP '2026-11-28 14:00', '[)'))
), covered AS (
  SELECT range_agg(w) AS windows FROM service_windows
)
SELECT sum(upper(piece) - lower(piece)) AS covered_time
FROM covered CROSS JOIN LATERAL unnest(windows) AS u(piece);

The expected result is four hours, based on the documented range behavior and the example inputs. The query measures time covered by the supplied windows; it cannot establish whether an unrecorded interval was an outage or a gap in the logs.

Give the agent two cases that expose the difference

Use one test with a gap, like the example above, and one with overlapping windows. For 09:00–11:00 and 10:00–12:00, the expected coverage is three hours, not four: simply summing the input rows counts the shared hour twice. The gap case catches a query that measures only the outer span; the overlap case catches a query that adds raw durations without taking the union. Check both before using generated SQL to report uptime.

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.