Cast Data Types
Convert column data types without code. Change string to integer, datetime to date, or boolean. Available target types adapt to your destination database.
Cast Data Types changes the data type of one or more columns in your dataset. Every column is shown at once with its current source type and a dropdown to select the target type. Change only the columns you need. Unchanged columns are left as-is. No new column is created.
The target types available in the dropdown are determined by your connected destination database (BigQuery, Snowflake, PostgreSQL, etc.). The dropdown shows only types that are valid for that destination.
When to Use Cast Data Types
- Fixing schema mismatches after ingestion. A numeric column ingested as string cannot be summed or averaged. Cast it to integer or float before aggregating.
- Preparing for joins. Join keys must match in type. If one table has
order_idas string and another has it as integer, cast before joining. - Converting date strings to datetime. Dates stored as
"2024-01-15"strings need to be cast to Date or Datetime before using in date range filters or datetime aggregations. - Standardizing boolean columns. Values like
"true","yes","1"stored as strings can be cast to Boolean for downstream logic. - Matching destination schema. Your target table expects specific types. Cast here to avoid load errors.
Sample Dataset
The examples in this doc use the Edilitics sample orders dataset. Download it to follow along in your own workspace.
edilitics_sample_orders.csv
Sample orders dataset for hands-on practice · 500 rows
Relevant columns for Cast Data Types examples:
Prop
Type
How Casting Works by Target Type
Converts string values to integer or float. Uses non-strict casting: values that cannot be converted become null instead of throwing an error.
| Input (string) | Target type | Output |
|---|---|---|
"1200" | float | 1200.0 |
"45.75" | float | 45.75 |
"N/A" | float | null |
"1200" | integer | 1200 |
Check for unexpected nulls in the preview after casting. A high null count usually means some values were in an unexpected format.
Converts string values to Date, Datetime, or Time. Edilitics auto-detects the format. If auto-detection fails, it falls back to YYYY-MM-DD HH:MM:SS.
| Input (string) | Target type | Output |
|---|---|---|
"2024-01-15" | Date | 2024-01-15 |
"2024-01-15 09:30:00" | Datetime | 2024-01-15 09:30:00 |
Values that do not parse become null. If most values are becoming null, the format likely does not match either auto-detect or the fallback format. Use Find & Replace to reformat the strings before casting.
The following string values map to true: "true", "1", "y", "t", "yes" (case-insensitive). Everything else maps to false.
| Input | Output |
|---|---|
"true" | true |
"yes" | true |
"1" | true |
"false" | false |
"no" | false |
"0" | false |
null | false |
Numeric 1 and 0 also cast correctly. Any value not in the true-list becomes false.
Extracts the date part or the time part from a datetime column.
| Input (datetime) | Target type | Output |
|---|---|---|
2024-01-15 09:30:00 | Date | 2024-01-15 |
2024-01-15 09:30:00 | Time | 09:30:00 |
Use this when you need to join or group by date only, stripping the time component.
Converts numeric values to their string representation. Uses non-strict casting.
| Input (integer) | Target type | Output |
|---|---|---|
1200 | string | "1200" |
45.75 | string | "45.75" |
Use when a downstream system expects a text identifier or when concatenating with other string columns using Merge Columns.
How to Apply Cast Data Types
Open the Cast Data Types operation
In your Transform pipeline, click Add Operation and select Cast Datatypes from the operation list. All columns load automatically with their current types.
Find the column to change
Each row shows: Source Column (read-only), Source Type (the type from your source system, read-only), and Convert To Type (the dropdown you change).
Use the search bar to filter by column name or type if your dataset has many columns.
Select the target type
Click the Convert To Type dropdown for the column and select the target type. The dropdown shows types valid for your connected destination database.
Repeat for any other columns you want to cast.
Save the operation
Click Save & Preview. Only the columns you changed are included in the operation. A success toast confirms: "Cast configuration saved. Preview has been updated with the latest schema."
The Save & Preview button is disabled until at least one column type has been changed.
Verify in the preview
Check the preview to confirm types changed correctly. Watch for unexpected nulls in numeric or datetime columns, which indicate values that could not be converted.
Before and After
Four columns cast in one operation:
| Column | Source Type | Cast To |
|---|---|---|
order_id | string | integer |
order_date | string | date |
revenue | string | float |
is_returned | string | boolean |
Before:
| order_id | order_date | revenue | is_returned |
|---|---|---|---|
"1001" | "2024-01-15" | "780.62" | "true" |
"1002" | "2024-01-16" | "N/A" | "no" |
After:
| order_id | order_date | revenue | is_returned |
|---|---|---|---|
1001 | 2024-01-15 | 780.62 | true |
1002 | 2024-01-16 | null | false |
"N/A" cannot be cast to float so it becomes null. "no" is not in the true-list so it becomes false.
Code Equivalent
SELECT
CAST(order_id AS INTEGER) AS order_id,
CAST(order_date AS DATE) AS order_date,
TRY_CAST(revenue AS FLOAT) AS revenue,
CASE
WHEN LOWER(is_returned) IN ('true','1','y','t','yes') THEN TRUE
ELSE FALSE
END AS is_returned
FROM orders;
-- TRY_CAST returns null on failure (PostgreSQL: CAST with error catch)import polars as pl
df = df.with_columns([
pl.col("order_id").cast(pl.Int64, strict=False),
pl.col("order_date").cast(pl.Utf8).str.to_datetime(strict=False).dt.date(),
pl.col("revenue").cast(pl.Float64, strict=False),
pl.col("is_returned").map_elements(
lambda x: str(x).lower() in ["true", "1", "y", "t", "yes"],
return_dtype=pl.Boolean
),
])After Save & Preview, the pipeline shows a DQ delta badge on this step - green if the table score improved, red if it dropped. See Data Quality Scoring for how scores are calculated.
After Save & Preview, the pipeline shows a DQ delta badge on this step - green if the table score improved, red if it dropped. See Data Quality Scoring for how scores are calculated.
Operation Reference
Prop
Type
Frequently Asked Questions
Next Steps
Manage Nulls
Fill nulls that appeared after a failed cast before running aggregations.
Filter
Filter rows by value now that column types match your conditions.
Group By
Aggregate numeric columns now that types are correct for sum and average.
Join
Join datasets after aligning key column types across both tables.
Need help? Email support@edilitics.com with your workspace, job ID, and context. We reply within one business day.
Last updated on
Drop / Rename Columns
Remove columns you no longer need or rename them to match your output schema. Drop and rename in the same step with validation to prevent invalid names.
Merge Columns
Combine two or more columns into a single string column using a delimiter. Configure multiple merge rules in one operation while preserving source columns.