ERROR: missing FROM-clause entry for table "pse_raw_table_data_vw" Position: 317

Metabase Version: V0.38.0.1
Database: Postgres 12.4
Operating System: RedHat Enterprise Linux 8.3 (64-bit)
Browser: FireFox 99.0 (64-bit)

I have a PostgreSQL function that I created. It is a “table function” that returns a result set…

I can successfully run the function using the following queries:
SELECT * FROM public.pse_latest_table_results_func();
SELECT * FROM public.pse_latest_table_results_func(‘v940m8’);

The first query returns the data from all of the releases and the second one just the data for v940m8. I am trying to figure out how to get this to work in Metabase using filter variables. I tried to create a question in Metabase with the following query:
SELECT release,
sum(test_cnt) AS total_tests,
sum(success_cnt) AS total_pass,
sum(success_cnt + skipped_cnt) / sum(test_cnt) AS passrate
FROM public.pse_latest_table_results_func( [[ {{release}} ]] ) f
GROUP BY release

This works as long as the “release” variable is a “Text” variable. However I would like to make it a “Field Filter” variable using the underlying table/view for the values (public.pse_raw_table_data_vw->release). However when I change the type to this, I get the error:
ERROR: missing FROM-clause entry for table "pse_raw_table_data_vw" Position: 317

Hi @sascjm
You should upgrade immediately to a newer release: https://github.com/metabase/metabase/releases/latest

You cannot use Field Filter without a FROM/JOIN-clause table reference (without alias):
https://www.metabase.com/learn/sql-questions/field-filters#field-filter-gotchas

You would have to either use Text, or create a sub-select like:
FROM public.pse_latest_table_results_func( [[ (SELECT release FROM pse_raw_table_data_vw WHERE {{release}} LIMIT 1) ]] ) f