Use the character storage type conversion as an example. For a target column declared as character(20) the following statement shows that the stored value is sized correctly:
CREATE TABLE tpcds.value_storage_t1 ( VS_COL1 CHARACTER(20) ) DISTRIBUTE BY HASH (VS_COL1); SELECT VS_COL1, octet_length(VS_COL1) FROM tpcds.value_storage_t1; vs_col1 | octet_length ----------------------+-------------- abcdef | 20 (1 row) ) DROP TABLE tpcds.value_storage_t1;
What has happened here is that the two unknown literals are resolved to text by default, allowing the || operator to be resolved as text concatenation. Then the text result of the operator is converted to bpchar ("blank-padded char", the internal name of the character data type) to match the target column type. Since the conversion from text to bpchar is binary-coercible, this conversion does not insert any real function call. Finally, the sizing function bpchar(bpchar, integer, boolean) is found in the system catalog and applied to the operator's result and the stored column length. This type-specific function performs the required length check and addition of padding spaces.