Try PostgreSQL 19 IGNORE NULLS / RESPECT NULLS Window Functions from a Desktop GUI
PostgreSQL 19 adds IGNORE NULLS and RESPECT NULLS to lead(), lag(), first_value(), last_value(), and nth_value(). Run the new window-function syntax in HiDataLinker's SQL editor and inspect the result grid — without a visual window-function builder.
正文目前为英文。
PostgreSQL 19 gives several window functions a null-treatment clause. The PostgreSQL 19 release notes record that lead(), lag(), first_value(), last_value(), and nth_value() now accept IGNORE NULLS and RESPECT NULLS. Official window function documentation places the option after the function call and before OVER, and treats RESPECT NULLS as the default. This guide shows how to try lead / lag IGNORE NULLS on PostgreSQL 19 from HiDataLinker, a free MIT PostgreSQL desktop GUI (MySQL in the same client): local-first credentials, URL paste, Dump / same-engine migrate, and no seat, connection, or tab freemium wall.
The new syntax requires a PostgreSQL 19+ server. Confirm with SELECT version();. On older majors the statement will not parse.
What HiDataLinker actually ships
HiDataLinker v1.3.0 includes a SQL editor and a result grid. Paste a postgresql:// URL or DATABASE_URL, keep the profile on your machine, and run the documented window-function SQL yourself. After ⌘/Ctrl+Enter, compare RESPECT NULLS with IGNORE NULLS on the same rows in the grid.
It does not ship a visual window-function builder — no drag-and-drop OVER clause, no frame designer, and no helper that injects IGNORE NULLS for you. Visual EXPLAIN in v1.3.0 (ANALYZE / BUFFERS) can show a plan if you prefix the query with EXPLAIN, but it does not construct the window. The PostgreSQL 19 server evaluates the syntax; the desktop client only sends the statement and displays the result.
1. Connect to a PostgreSQL 19 server
- Install from hidatalinker.onesolo.app.
- Open New Connection — paste the URI or fill host, port, user, password, and database. See paste a DATABASE_URL.
- Test, then connect. Profiles stay on your machine — local-first, no hosted workspace.
- In the SQL editor, run
SELECT version();and confirm you are on PostgreSQL 19 or newer.
2. Compare lag() with IGNORE NULLS and RESPECT NULLS
A short sensor series is enough to see the difference: a missing reading is a NULL, and lag() without IGNORE NULLS returns that NULL as the previous value. With PostgreSQL 19 IGNORE NULLS, lag() walks back to the nearest non-null temperature instead.
CREATE TABLE sensor_readings (
sensor_id text,
ts timestamptz,
temp numeric
);
INSERT INTO sensor_readings VALUES
('a', '2026-11-29 09:00+08', 21.4),
('a', '2026-11-29 09:05+08', NULL),
('a', '2026-11-29 09:10+08', 21.8),
('a', '2026-11-29 09:15+08', NULL),
('a', '2026-11-29 09:20+08', 22.1);
SELECT
ts,
temp,
lag(temp) OVER (PARTITION BY sensor_id ORDER BY ts)
AS prev_respect_nulls,
lag(temp) IGNORE NULLS OVER (PARTITION BY sensor_id ORDER BY ts)
AS prev_ignore_nulls,
lead(temp) IGNORE NULLS OVER (PARTITION BY sensor_id ORDER BY ts)
AS next_ignore_nulls
FROM sensor_readings
ORDER BY ts;
lag(temp) with the default RESPECT NULLS at 09:10 is NULL (the 09:05 gap). lag(temp) IGNORE NULLS at the same row is 21.4. The same pattern works with lead().
Dimitri Fontaine walked through this clause while getting ready for PostgreSQL 19; the examples here are independent. The official feature description is the short canonical summary: those five window functions can skip NULL values with IGNORE NULLS.
Run the statements in the SQL editor (⌘/Ctrl+Enter). The result grid shows both columns side by side.
3. first_value, last_value, and the window frame
first_value(), last_value(), and nth_value() also accept the option, but they only consider rows in the window frame. Official docs: the default frame is the start of the partition through the last peer of the current row, which is often unhelpful for last_value (and sometimes nth_value). Add an explicit ROWS / RANGE / GROUPS frame when you need later rows — for example, ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING when first_value(...) IGNORE NULLS should look forward.
HiDataLinker will not suggest a frame for you; write it in the editor and inspect the grid.
Official limits
- The option is valid only for
lag,lead,first_value,last_value, andnth_value. Other window or aggregate functions do not takeIGNORE NULLSthis way. - If you omit the clause, the default is
RESPECT NULLS. - The SQL standard's
FROM FIRST/FROM LASToption fornth_valueis not implemented in PostgreSQL; only the defaultFROM FIRSTbehavior is supported (you can reverseORDER BYto get the other direction). - The clause requires PostgreSQL 19+. It is not a client-side feature of the desktop GUI.
HiDataLinker is a thin Tauri desktop app for PostgreSQL and MySQL — paste DATABASE_URL, keep creds local, and avoid seat / connection / tab freemium walls. Honest v1: MySQL + PostgreSQL as marketed; no visual window-function builder. Overview: /db-client.
Soft next step
Need a desktop GUI that can run PostgreSQL 19 window functions with IGNORE NULLS / RESPECT NULLS in a SQL editor and show the result grid, without a freemium wall?
- Download: https://hidatalinker.onesolo.app/
- Source: https://github.com/henrybit/HiDataLinker