PRINT

Outputs values to the result stream (DeltaForge extension).

Category: output

Syntax

PRINT <expr1> [, <expr2>, ...] [SEPARATOR '<sep>'];

Description

## Overview PRINT is a DeltaForge extension to PL/pgSQL that outputs formatted values to the message stream. It provides a simpler syntax than RAISE NOTICE for debugging output and progress reporting. Messages appear in the GUI's Messages tab and in the tracing log. ## Behavior - Each expression in the comma-separated list is evaluated independently via the DataFusion expression evaluator. - Evaluated values are formatted to strings using a type-aware formatter: - NULL renders as the literal string "NULL". - Booleans render as "true" or "false". - Integers render as plain decimal numbers. - Floats render with 6 decimal places. - Strings render as their raw value (no quotes). - Dates render in YYYY-MM-DD format. - Timestamps render in YYYY-MM-DD HH:MM:SS format with appropriate precision. - Complex types use Rust Debug formatting. - The formatted values are joined using the separator (default: single space). - The resulting message is logged via `tracing::info!` with a "PRINT: " prefix and added to the executor's message buffer. - The message buffer is accessible to the GUI through the Messages tab in the bottom panel. ## Differences from PostgreSQL - PRINT is not a standard PostgreSQL PL/pgSQL construct. It is a DeltaForge extension inspired by T-SQL's PRINT statement. - The closest PostgreSQL equivalent is `RAISE NOTICE '%', value`. PRINT is more concise for multi-value output. - Values are always joined with a single space separator.

Parameters

NameTypeDescription
expressionsSupply one or more expressions whose evaluated values are formatted and joined for output.
separatorCustom separator between values.

Examples

DO $$
BEGIN
  PRINT 'Hello, World!';
END;
$$;
DO $$
DECLARE
  name TEXT := 'Alice';
  score INT := 95;
BEGIN
  PRINT 'Name:', name, 'Score:', score;
END;
$$;
DO $$
DECLARE
  x INT := 10;
  y INT := 20;
BEGIN
  PRINT x, y, x + y;
END;
$$;
DO $$
DECLARE
  rec RECORD;
BEGIN
  FOR rec IN SELECT id, name, salary FROM employees LIMIT 3 LOOP
    PRINT rec.id, rec.name, rec.salary;
  END LOOP;
END;
$$;
DO $$
DECLARE
  start_ts TIMESTAMP := now();
BEGIN
  PRINT 'Pipeline started at', start_ts;
  PERFORM pg_sleep(1);
  PRINT 'Pipeline completed at', now();
END;
$$;

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →