CAST converts a value from one data type to another in ParadeDB, a PostgreSQL-compatible database.
CAST changes the data type of a value at query time—turning text into integers, timestamps into dates, or JSON into text—so functions and comparisons work correctly.
Use CAST when the column type differs from the function’s expected type, when comparing mixed-type columns, or when preparing data for inserts into stricter typed tables.
Use the standard CAST(expr AS target_type) or the shorthand expr::target_type.ParadeDB supports both.
Convert a text column storing numeric strings to integer before arithmetic:SELECT CAST(total_amount AS numeric) * 1.05 AS total_with_tax FROM Orders;
Yes. Extract a JSON value, then CAST:SELECT (order_data->>'promo_code')::text FROM Orders;
CAST to the smallest type that fully fits the source data.For money values, CAST to numeric with scale, not integer.
Keep CASTs close to the data source, prefer explicit CAST over implicit, and create views with pre-cast columns to simplify client queries.
.
No. Both compile to the same internal function call; choose either for readability.
Yes. CAST values in the VALUES list or SELECT statement feeding the INSERT to match the destination column types.
ParadeDB inherits PostgreSQL’s CREATE CAST, allowing you to define casts between user-defined types when superuser privileges are available.