Macros on columns from aliased tables

I am trying to pass a column from an aliased table to a macro, i.e.

select {{my_macro(aliased_table.my_column)}} 
from my_table aliased_table

It’s the same problem as Pass column to macro as variable but the solution does not work for me. I’m using the Trino adapter.

  • With single quotes, trino tells me
    TrinoUserError(type=USER_ERROR, name=COLUMN_NOT_FOUND, message="Column 'aliased_table.my_column' cannot be resolved"
  • With double quotes, trino tells me TrinoUserError(type=USER_ERROR, name=COLUMN_NOT_FOUND, message="Column 'aliased_table.my_column' cannot be resolved"
  • Without quotes, dbt tells me 'aliased_table' is undefined. This can happen when calling a macro that does not exist. Check for typos and/or install package dependencies with "dbt deps".

My macro looks like this:

{% macro my_macro(my_column) %}
regexp_replace("{{ my_column }}", '[-./_;,]', ' ')
{% endmacro %}

I’ve also tried adapter.quote(my_column), to no avail.
I’ve also tried

{% macro my_macro(my_column) %}
{# allow for select aliased tables like a.col1 #}
{% set lst = my_column.split(".") %}
{% set regex_str = "'[-./_;,]'" %}
{% set target_str = "' '" %}
{% if (lst | length) == 2 %} regexp_replace(lst[0].lst[1], {{ regex_str }}, {{ target_str }})
{% else %} regexp_replace("{{ my_column }}", {{ regex_str }}, {{ target_str }})
{% endif %}
{% endmacro %}

But that starts to fail when you put in more complex derived columns like when calling

{{my_macro(coalesce(a.col, b.col))}}

Any clue how to resolve this? Is this a limitation of trino interpreting single quotes as literals?

Ah stupid me, don’t put quotes in here…
Solution:
regexp_replace({{ my_column }}, '[-./_;,]', ' ')