Scalars
There are other scalars that don't have their own dedicated
literals, but can instead be represented by casting some
literal into the appropriate type. These are: uuid
, datetime
, duration
, and json
. In order to cast one
value into a particular scalar type you need to put <new-type>
before the value. Try out a few casts:
Note that casting from one scalar type to another is a
generic operation and can be performed between many (but not
all) types. For example, every type can be cast to and from
a string (str
), except for bytes
, which cannot be cast
from or into anything else except json
(all types can be
cast into and from json
).
It is also possible to chain cast operations one after the other. They will be evaluated from right to left (from the cast adjacent to the value and moving out).
The full list of all the basic scalar types is: bool
, bytes
, uuid
, str
, json
, datetime
, duration
, int16
, int32
, int64
, float32
, float64
, decimal
, bigint
. Try out a few casts: