How to use Elixir function in ecto query

What if I want to call a custom function?, for example; I want to check for 3 conditions when I’m joining two tables. Since this is lots of typing, I want to put that in a function.

However, the compiler complains that the binding variable is undefined.

  def filter(...) do
      # ...
      |> join(:inner, [tr, tt: tt], t in Tag,
        as: :tag,
        on: ^is_matching_tag(tt, t)
      )

    # ...
  end

  defp is_matching_tag(trt, tag) do
    Enum.map(2..0, fn level -> is_matching_tag(trt, tag, level) end)
    |> Enum.any?()
  end

  defp is_matching_tag(a,b,c) do
    # ...
  end

But I get the following error where the call occrus (the ecto join)

** (CompileError) ../trs.ex:62: undefined function t/0
    (elixir) src/elixir_locals.erl:108: :elixir_locals."-ensure_no_undefined_local/3-lc$^0/1-0-"/2
    (elixir) src/elixir_locals.erl:109: anonymous fn/3 in :elixir_locals.ensure_no_undefined_local/3
    (stdlib) erl_eval.erl:680: :erl_eval.do_apply/6

Can this be accomplished using Ecto?

thanks! (newbie here)