SQL Column Rendering
Currently supported column types for custom rendering:
- integer
- bytes
For SQL Editor
Custom rendering for integer and bytes columns can be set using comment directives with the format:@colrender colname[,colname ...] / kind [/ key=val[; key=val ...] ]
-- @colrender created_at, last_login_at / datetime / unit=mills
select * from users;For integer columns, three rendering variants are supported:
datetime: Optional parameters:
unit(sec/mills/nano),layout(string)andtz(string).unitdefault tomills.layoutfollows the day.js format.tzdefaults to the computer's local time zone, and can be any IANA time zone name.
Example:
@colrender intcol / datetime / unit=sec; layout=YYYY-MM-DD HH:mm:ss.bool:0 is treated as false, and all other values as true.
Example:
@colrender intcol / bool.enum: Any value in the options that can be safely converted to an integer is considered an enum item.
Example:
@colrender intcol / enum / a=1; b=2; c=3.
For Bytes columns, three rendering variants are supported:
uuid:The value length must be 16.
Example:
@colrender bytescol / uuid.boolean:The value length must be 1. 0 is treated as false, and all other values as true.
Example:
@colrender bytescol / boolean.string:
encodingdefault toutf-8.
Example:
@colrender bytescol / string / encoding=utf8.
For TypeScript Editor
sql`select * from users`
.export(ctx)
.colrender(["created_at", "last_login_at"], "datetime", { unit: "mills" });