sgupta
New Contributor II

I looked at this post

https://stackoverflow.com/questions/77475436/in-databricks-workbook-using-spark-sql-how-to-pass-para...

 What I want is to replace the static table name with the table name passed as parameter (param_table_name). Is it possible?

 

CREATE OR REPLACE FUNCTION mydb.tbl_filter(a_val INT, param_table_name string)
RETURNS TABLE(a INT, b INT)
RETURN SELECT * FROM tbl_filter.param_table_name tf 
WHERE tf.a = tbl_filter.a_val;