TERN

A Benchmark for Time-Series Text-to-SQL

About TERN

TERN is a text-to-SQL benchmark for time-series databases, automatically generated by TSSDA, an autonomous data generation agent framework. Built on Apache IoTDB, it spans basic temporal queries through complex time-series analysis.

The benchmark contains 13,182 samples across 32 database instances, with test sets organized into three levels: Foundation, Standard, and Analytical.

Leaderboard

Execution accuracy (EX %) · Higher is better
TERN leaderboard. Execution accuracy scores are percentages.
RankMethod / ModelDetails

Select a tier to rank by its EX score. Bold values mark the best score in each column. Click a method for details or an author citation to read its paper.

Dataset

Includes train/dev NL–SQL pairs, test questions and full database contents; test gold SQL is withheld.
Submit predictions via Submission for results by email; online EX evaluation is coming soon.

TERN Dataset

Complete package

The complete dataset, database contents, and Apache IoTDB distribution in one package for local deployment and execution accuracy (EX) evaluation on train/dev.

Download Dataset ZIP · 526 MB Download requests—Count not available yet

Submission

Email submissions coming soon

Submit your prediction file and method details by email for official review. The organizers will contact you about verification and leaderboard inclusion. Instant EX feedback for the test set is coming soon.

  1. 1 Prepare predictions
  2. 2 Check file format
  3. 3 Submit for review

Email submissions will open once the receiving address is confirmed. You can prepare and validate your file below.

Dataset Examples

Two representative questions from the TERN training set, with their gold SQL. Times use Asia/Shanghai (UTC+08:00); query ranges include the start and exclude the end.

EXAMPLE 01

Machine temperature stability

Training · train_001054

Question

For the machine, compute the population variance of process temperature and the average tool wear across overlapping 1-day windows that advance every 6 hours from 2020-01-01T00:00:00 to 2020-01-07T22:39:00 (end exclusive). Keep only records where tool wear is at least 180 minutes or torque exceeds 65 Nm, while air temperature stays at or below 305 K, process temperature is at least 305 K, and rotational speed is under 2800 RPM. Fill gaps with the previous value within a 1-hour limit, order the windows by time ascending, skip the first 6 rows, and return at most 20 rows. Name the results process_temperature_variance and avg_tool_wear_min.

Databaseroot.maintenance
Process and air temperature
K
Tool wear
min
Torque
Nm
Rotational speed
RPM
Gold SQL
SELECT
  VAR_POP(Process_Temperature_K) AS process_temperature_variance,
  AVG(Tool_Wear_Min) AS avg_tool_wear_min
FROM root.maintenance.machine
WHERE (Tool_Wear_Min >= 180 OR Torque_Nm > 65)
  AND Air_Temperature_K <= 305
  AND Process_Temperature_K >= 305
  AND Rotational_Speed_RPM < 2800
GROUP BY(
  [2020-01-01T00:00:00, 2020-01-07T22:39:00), 1d, 6h
)
ORDER BY TIME ASC
FILL(PREVIOUS, 1h)
LIMIT 20 OFFSET 6

EXAMPLE 02

Hourly bike-share demand

Training · train_000163

Question

For the NewportPkwy station from June 5 through June 11, 2023, show the hourly trend of total activity, departures, and arrivals as a percentage of total activity, considering only hours with positive total activity; fill missing hourly values with 0, order by time ascending, and return the first 24 rows.

Databaseroot.bikeshare

Total activity = departures + arrivals; all three series count trips.

Gold SQL
SELECT
  SUM(total_activity) AS total_activity,
  SUM(departures) AS departures_count,
  (SUM(total_activity) - SUM(departures))
    / SUM(total_activity) * 100.0 AS arrival_percentage
FROM root.bikeshare.NewportPkwy
WHERE total_activity > 0
GROUP BY(
  [2023-06-05T00:00:00, 2023-06-12T00:00:00), 1h
)
ORDER BY TIME ASC
FILL(0)
LIMIT 24

Citation & resources

Read TSSDA: An Autonomous Agent for Constructing a Time-Series Text-to-SQL Benchmark and explore the code repository.