How to select and rename columns dynamically based on a Regex?

I’ve got a bunch of columns as a result of a columnization processor, and I’d like to rename them to a more intelligible name.

Ex:

year_month_date_start_interval_2021minus01_value_SUM   -> a2021_01
kw_concat_year_2023_KW9_value_SUM                       -> a2023_KW9
date_2022-05-15_00:00:00dot0_value_SUM                   -> a2022_05_15

Solution by @christoph.pernul in Slack

  • Use the describe inputTable in a query to get the names
  • Upply your regex and use the query helper to rename the columns
1 Like