Apache Hive : HPL/SQL - SIGNAL Statement

Last updated: August 12, 2026

Apache Hive : HPL/SQL - SIGNAL Statement

SIGNAL statement raises a user-defined condition (exception).

Syntax:

SIGNAL condition_name;

Example:

Raise a condition if the number of rows is not equal to the specified number:

DECLARE cnt INT DEFAULT 0; 
DECLARE wrong_cnt_condition CONDITION;

DECLARE EXIT HANDLER FOR wrong_cnt_condition
  PRINT 'Wrong number of rows';  

SELECT COUNT(*) INTO cnt FROM TABLE (VALUES (1,2));

IF cnt <> 1 THEN
  SIGNAL wrong_cnt_condition;
END IF;

Compatibility: IBM DB2, Teradata and MySQL

See also: