Cast to Boolean
Description
Converts a value to the boolean type.
Category
Transformation
Supported Field Types
- text
- float
- int
Output Field Type
- boolean
Arguments
None
Pseudo-code (Python)
def func(val):
"""
val: original value
"""
if val:
if type(val) is text:
return val.lower() == "true"
else:
return bool(val)
else:
return None
Cast values to boolean in Kondado
Use the Cast to Boolean transformation to convert text, float, or integer fields into boolean values in your Kondado pipelines.
Identify fields to convert
Review your source schema and identify text, float, or integer fields that should be represented as boolean (for example, 'true'/'false' strings or 1/0 integers) before loading into your destination.
Open the pipeline transformations
Open the pipeline that loads the source field and navigate to the transformations step where you can add functions to individual fields.
Apply the Cast to Boolean function
Add the Cast to Boolean function to the chosen field. No arguments are required: text values matching 'true' (case-insensitive) become true, numeric values are converted with standard boolean rules, and null/empty inputs return None.
Validate the output type
Run a test execution and confirm the field now returns boolean values. Pay attention to edge cases such as empty strings or zero values to make sure the conversion matches your business logic.
Replicate to your destination
Save the pipeline and let Kondado replicate the cleaned boolean field into your data warehouse, BI tool, or spreadsheet at the frequency you choose.