Normalize column names

Supported in: Batch, Faster, Streaming

Normalizes column names to use lower_snake_case.

An underscore is inserted at each camel case boundary, all letters are lowercased, hyphens and runs of whitespace become underscores, and periods are removed. Characters that Foundry does not permit in column names (,;{}()=, the tab, and newline characters) are always replaced with an underscore, regardless of whether the remove special characters argument is enabled. Consecutive underscores are then collapsed into a single underscore, and any leading or trailing underscore is removed.

Transform categories: Data preparation

Declared arguments

  • Dataset: Dataset to normalize column names.
    Table
  • optional Remove special characters: Replaces each run of the characters |@~`!#$%^&=*+':"/?>< in a column name with a single underscore. When this argument is disabled (the default), these characters are left unchanged, except for those that Foundry does not permit in column names, which are always replaced with an underscore.
    Literal<Boolean>

Examples

Example 1: Base case

Argument values:

  • Dataset: ri.foundry.main.dataset.a
  • Remove special characters: null

Input:

recentlyServicedtailNumber_airlineCode
trueKK-150KK
falseXB-120XB
trueMT-190MT

Output:

recently_servicedtail_numberairline_code
trueKK-150KK
falseXB-120XB
trueMT-190MT

Example 2: Base case

Argument values:

  • Dataset: ri.foundry.main.dataset.a
  • Remove special characters: true

Input:

recently^Servicedtail@Number$!airline*Code
trueKK-150KK
falseXB-120XB
trueMT-190MT

Output:

recently_servicedtail_numberairline_code
trueKK-150KK
falseXB-120XB
trueMT-190MT

Example 3: Edge case

Argument values:

  • Dataset: ri.foundry.main.dataset.a
  • Remove special characters: null

Input:

columnA.columnB()column!Ccolumn,;{} Dcolumn()e
foobarfooBarfoobar

Output:

column_acolumn_bcolumn!_ccolumn_dcolumn_e
foobarfooBarfoobar