String Types

Singdata Lakehouse supports the following string types: CHAR, VARCHAR(n), and STRING.

Type Comparison

TypeLengthDescription
CHAR(n)Fixed length nLakehouse does not pad with spaces; strings exceeding the length are silently truncated; max 255 characters
VARCHAR(n)Variable, max nNo space padding; max 1,048,576 characters
STRINGVariable, no limitRecommended for large text; no length restriction

Selection Guide

  • Fixed-length codes (e.g., country codes, status codes): use CHAR
  • Fields with a length cap (e.g., usernames, email addresses): use VARCHAR(n)
  • Long text, JSON strings, fields with no length constraint: use STRING

Examples

-- CHAR: truncates on overflow, does not pad on underflow SELECT CAST('hello' AS CHAR(3)); -- 'hel' (truncated) SELECT length(CAST('hi' AS CHAR(5))); -- 2 (no space padding) -- VARCHAR: truncates on overflow SELECT CAST('hello world' AS VARCHAR(5)); -- 'hello' -- STRING: no length limit SELECT typeof('any length of text'); -- string