Datatype Conversion

Switchboard has the ability to convert data from one type to another.

Natively, Switchboard supports the following datatypes:

  • string: A string of characters, equivalent to a the TEXT format in SQL.
  • integer: A non-decimal. 
  • float: A decimal value.
  • boolean: “true” or “false”
  • datetime.
  • date.
  • json: A JSON object, can be a nested record
  • url: A special type for URL formats

A typecast may be used to parse a string. If the string cannot be parsed, the typecast will produce null. A typecast may also be used to assert that a JSON value has a particular type, for example:

import t1 from {...} using {c: json;}
    table t2 is select c.field[0]: integer as f0 from t1;


Convert a column to boolean datatype

table my_new_table is select
   string_column:boolean as boolean_column
from original_table;

Convert an column to an integer datatype

table my_new_table is select
   string_column:integer as integer_column
from original_table;