08-18-2025 12:41 AM
hi ,
I am trying to create a databricks sql unity catalog function which will take table_name as input parameter and returns the full table as output. I am getting error, kindly help
08-18-2025 01:35 AM
Hi @saurabh_aher ,
It looks like this is a limitation of identifier clause. The identifier requires a constant STRING expression. When you're passing table_name as an input of that function it's no longer considered as a constant (known at complied time), but rather runtime value.
08-18-2025 01:27 AM - edited 08-18-2025 01:29 AM
@saurabh_aher if you're referring to an object i.e. a table I think you should be using backticks `` and not single quotes ''.
However, based on the error message: concat('kdp_bronze_prod.salesforce.', outer(get_table.user_id)).
I think in the concat function, it often helps to wrap a string in a LIT function.
All the best,
BS
08-18-2025 01:35 AM
Hi @saurabh_aher ,
It looks like this is a limitation of identifier clause. The identifier requires a constant STRING expression. When you're passing table_name as an input of that function it's no longer considered as a constant (known at complied time), but rather runtime value.
08-18-2025 02:02 AM
any workaround for this ??
08-18-2025 02:19 AM
Unfortunately, if we're talking about databricks sql functions I don't know workaround.
08-18-2025 02:24 AM
Hello @saurabh_aher ,
As a workaround maybe you can use SQL procedures, a quick example I created:
CREATE OR REPLACE PROCEDURE workspace.default.get_table_proc(IN p_fqn STRING)
LANGUAGE SQL
SQL SECURITY INVOKER
AS
BEGIN
DECLARE sql_str STRING;
SET sql_str = CONCAT('SELECT * FROM ', p_fqn);
EXECUTE IMMEDIATE sql_str;
END;
And then you can call it like this:
CALL workspace.default.get_table_proc('workspace.default.sample_trips_test');
Hope that helps a bit.
Best, Ilir
08-18-2025 03:00 AM - edited 08-18-2025 03:00 AM
Yep, that will work. Now, if that's okay with you @saurabh_aher that can be solution. If you want to stick to using databricks sql function then what I wrote before still applies.
"Unfortunately, if we're talking about databricks sql functions I don't know workaround. "
08-18-2025 04:31 AM
@szymon_dybczak I admire that you always find the appropriate information in the documentation. I will try my best to emulate this behaviour with other posts 👍.
@saurabh_aher great workaround suggestion with a stored procedure.
Lots of lessons learned here, for me, thanks guys 👏
All the best,
BS
08-18-2025 05:13 AM
Thanks for kind words @BS_THE_ANALYST . I think you're doing really well so far and I remember your first post on community (Zero to Hero). Actually, it's really impressive how quickly you became proficient with databricks and valuable member of community.
Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!
Sign Up Now