Type Conversion Functions
Last updated
Was this helpful?
Was this helpful?
SELECT cast(revenue, 'DOUBLE') AS revenue_double
FROM orders
LIMIT 5bigDecimalToBytes(bigDecimalCol)SELECT bigDecimalToBytes(price) AS priceBytes
FROM products
LIMIT 5bytesToBigDecimal(bytesCol)SELECT bytesToBigDecimal(priceBytes) AS price
FROM products
LIMIT 5hexToBytes(hexString)SELECT hexToBytes('f0e1a3b2') AS rawBytes
FROM myTable
LIMIT 1
-- Converts hex string to 4-byte arraybytesToHex(bytesCol)SELECT bytesToHex(rawData) AS hexString
FROM myTable
LIMIT 5
-- Returns hex representation such as 'f012be3c'base64Encode(bytesCol)SELECT base64Encode(payload) AS encodedPayload
FROM events
LIMIT 5base64Decode(bytesCol)SELECT base64Decode(encodedPayload) AS originalPayload
FROM events
LIMIT 5hexDecimalToLong(hexString)SELECT hexDecimalToLong('0x1a2b') AS longVal
FROM myTable
LIMIT 1
-- Returns 6699longToHexDecimal(longCol)SELECT longToHexDecimal(6699) AS hexVal
FROM myTable
LIMIT 1
-- Returns '1a2b'