Select from a dynamic table name returned by databricks function

sgupta
New Contributor II
  • I have a databricks function that returns a table_name
CREATE OR REPLACE FUNCTION test_func()
  RETURNS string
  READS SQL DATA
  RETURN    'table_name'
  • I want to select from the table that is returned by this function. How can I make it work in SQL, something like this -

SELECT * FROM (SELECT test_func())

Currently this SELECT is returning a single row with the table name and not the contents of the table name.