_in_query is not working for Dimension when using it in COUNT custom field

I face an issue with _in_query to properly define sql_table_name. It is not working when dimension is used in Custom field.

Scenario:

  1. I defined sql_table_name for a view with liquid and _in_query
    {% if bonuses_daily.account_id._in_query %}
    tangome-production.finance.bonuses_daily_account
    {% else %}
    tangome-production.finance.bonuses_daily
    {% endif %} ;;

  2. When Account_id field is used in filter or returned in table that is working fine. I see SQL than references proper table bonuses_daily_account

  3. When I use dimension menu for Account_ID field (three dots) → AddCustom Field → Count the resulting SQL references wrong table bonuses_daily.

  4. When I create measure in the Model that counts Account ID’s that is also working fine.

    Question: is it a bug or a feature? Can it be fixed?

    I expect that there is no such issue. This is bad for users as they can make custom field and find themselves looking at errors.
    I want to focus on modelling and not on explaining users how to use COUNT properly.
    _in_query is wonderful feature, but such a issue ruins the whole idea

4 Likes