I'm attempting to allow the user of our app to UNLOAD selected columns from our backend Redshift (postgres based) database into S3. Ideally, we would not allow a query like
UNLOAD ('select * from main')
Instead, we want to be able to allow the user to select the columns to unload themselves, resulting in a query more like:
UNLOAD ('select first_name, last_name, age from main')
Currently, I'm trying to accomplish this with a checkboxTree or Multiselect, but I'm running into a problem turning the selected column names into a valid SQL statement. I'm using the following JS:
select {{checkboxTree1.checked.map(d => `"${d}"`).join(',')}} from main limit 100
but it turns into
select "\first_name\", \"last_name\"" from main limit 100
Is it possible to accomplish this in Retool?
Hey @redfiel3!
Do you run into any issues when not using double quotes around the column names? For instance with something like checkboxTree1.checked.join(',')
or checkboxTree1.leafPathArray.map(arr => _.last(arr)).join(',')
?
Hey @Kabirdas thanks for getting back to me here. So it looks like it both runs and fails. I've attached the screenshot:
It's evaluating to a valid SQL query string as expected:
"select res_address,res_city,res_zip from main limit 100"
I've also went ahead and run that same query in my normal workbench and it evaluates appropriately. Do you have any idea what that "assert" error is?
Hmm... the Assert
error seems to be fairly opaque, this could be a prepared statements issue. If you haven't already, can you try disabling them and see if that helps?

This was exactly it. It executed and returned as expected in the app. Thank you!