Edilitics | Data to Decisions

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_id as 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

Download

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 typeOutput
"1200"float1200.0
"45.75"float45.75
"N/A"floatnull
"1200"integer1200

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 typeOutput
"2024-01-15"Date2024-01-15
"2024-01-15 09:30:00"Datetime2024-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.

InputOutput
"true"true
"yes"true
"1"true
"false"false
"no"false
"0"false
nullfalse

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 typeOutput
2024-01-15 09:30:00Date2024-01-15
2024-01-15 09:30:00Time09: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 typeOutput
1200string"1200"
45.75string"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:

ColumnSource TypeCast To
order_idstringinteger
order_datestringdate
revenuestringfloat
is_returnedstringboolean

Before:

order_idorder_daterevenueis_returned
"1001""2024-01-15""780.62""true"
"1002""2024-01-16""N/A""no"

After:

order_idorder_daterevenueis_returned
10012024-01-15780.62true
10022024-01-16nullfalse

"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

Need help? Email support@edilitics.com with your workspace, job ID, and context. We reply within one business day.

Last updated on

On this page