LTRIM

Remove leading whitespace from the input string.

Category: stringReturns: VARCHARDialect: Standard

Syntax

LTRIM(str)

Description

## Overview Removes whitespace characters from the beginning of the input string. Characters to the right of the first non-whitespace character are preserved unchanged, including any trailing whitespace. LTRIM is typically used when only the leading whitespace is meaningful noise, such as after extracting a field from a fixed-width file, an indented YAML/JSON fragment, or a CSV column where the exporter pads values for alignment. ## Behavior - Returns NULL when the input is NULL. - Returns an empty string when the input is empty or consists only of whitespace characters. - Whitespace is defined as the standard Unicode whitespace set: space (U+0020), tab (U+0009), line feed (U+000A), carriage return (U+000D), form feed (U+000C), vertical tab (U+000B), and the non-breaking space (U+00A0). - Trailing whitespace and interior whitespace are preserved exactly. - Operates on UTF-8 code points, so multi-byte characters immediately after a run of leading whitespace are kept intact. - Equivalent to TRIM(LEADING FROM str) in SQL-standard syntax. ## Compatibility - LTRIM(str) is widely supported with identical semantics. - Some dialects also support LTRIM(str, chars) for a custom character set. DeltaForge accepts that extended form and treats it as BTRIM-style trimming restricted to the left side.

Parameters

NameTypeDescription
strSpecifies the input string from which leading whitespace is removed.

Examples

-- Remove leading spaces
SELECT LTRIM('   hello');  -- 'hello'
-- Trailing whitespace is preserved
SELECT LTRIM('   hello   ');  -- 'hello   '
-- No leading whitespace, result unchanged
SELECT LTRIM('hello');  -- 'hello'
-- Clean a column's leading indentation
SELECT LTRIM(description) AS description_clean
FROM retail.products.catalog;
-- NULL propagates
SELECT LTRIM(CAST(NULL AS VARCHAR));  -- NULL
-- Whitespace-only input becomes empty
SELECT LTRIM('   ');  -- ''

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →