As the parent mentioned, you can encode your sum type by providing all the columns and constraining exactly one to be non-null.
It's like saying you don't need foreign key constraints as built-in concept as long as you have triggers, because you can encode such integrity checks as triggers. Technically true, but no one is going to buy that is a legitimate argument against foreign key constraints.
Databases provide product types, and the dual of product types are sum types. As you point out, you can encode this in various ways, but it's not natural and very error-prone.
In a recent feature I had an object field modelled as:
type Destination = Customer of Customer | Supplier of Supplier | Warehouse of Warehouse
and the table representation was customer_id uuid null
, supplier_id uuid null
, warehouse_id uuid null
, constraint unique_destination check (num_nonnulls(customer_id, supplier_id, warehouse_id) = 1)
It's not first class support, but manageable enough.