Is there a way to specifically allow users to select the columns that they want to see?

Hello, I am using postgresql as a data source. I have a base table which contains multiple columns that the user wants to see. I want to create a UI where the user can select all columns that he wants to view and those are shown to him.
We can easily create a variable which displays all values of columns:

SELECT column_name
FROM information_schema.columns
WHERE table_schema='public' AND table_name='table'

The above variable is a multi select with All possible as one of its values.

How do I write a dynamic query that takes in the above as a dynamic input when the rows are shown to the user in a simple select clause?
So, I want to show a panel that contains a table as its panel output?

This was a fun one!

Create a variable that selects the columns for the table you want, pg_tables as an example

then build a query to fetch the data from the table, make sure you specify the csv option so it does not quote the variables when you select multiple