Skip to content

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 ...] ]

sql
-- @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) and tz(string).

    • unit default to mills.
    • layout follows the day.js format.
    • tz defaults 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:

    • encoding default to utf-8.

    Example: @colrender bytescol / string / encoding=utf8.

For TypeScript Editor

typescript
sql`select * from users`
  .export(ctx)
  .colrender(["created_at", "last_login_at"], "datetime", { unit: "mills" });