Apache Hive : HPL/SQL - SUBSTRING Function

Last updated: August 12, 2026

Apache Hive : HPL/SQL - SUBSTRING Function

SUBSTRING function returns a substring from string.

Syntax:

SUBSTRING(string, start_pos [, substring_len])
|
SUBSTRING(string FROM start_pos [FOR substring_len])

Parameters:

ParameterTypeValueDescription
stringStringVariable or expressionOriginal string
start_posIntegerVariable or expressionStart position of substring (starts from 1)
substring_lenIntegerVariable or expressionLength of substring

Notes:

  • If start_pos is 0 then it is treated as 1
  • SUBSTRING and SUBSTR functions are synonyms

Return Type:

String.

Example:

SUBSTRING('Remark', 3); 

Result: ‘mark’

Example:

SUBSTRING('Remark', 3, 3); 

Result: ‘mar’

Compatibility: IBM DB2, Teradata and Microsoft SQL Server.

See also: