Getting error :USER_DEFINED_FUNCTIONS.CORRELATED_REFERENCES_IN_SQL_UDF_CALLS_IN_DML_COMMANDS_NOT_IMP

Vivek_Singh
New Contributor III

Hello Focus,

need help, implemented Row level security at Unity Catalog, it is working as expected however while deleting the record getting error as enclosed detail 

[USER_DEFINED_FUNCTIONS.CORRELATED_REFERENCES_IN_SQL_UDF_CALLS_IN_DML_COMMANDS_NOT_IMPLEMENTED_YET] User defined function is invalid: This command includes calls to SQL user-defined function row_filter_countryid_source_table which contains subquery expressions with correlated outer references; this feature is is not implemented yet SQLSTATE: 42601

 

VZLA
Databricks Employee
Databricks Employee

The correlated subqueries within SQL User-Defined Functions (UDFs) used for row-level security are currently not supported for DELETE operations in Unity Catalog. You will need to adjust your row_filter_countryid_source_table UDF to avoid correlated subqueries. This may involve refactoring the logic within the UDF or moving the filtering logic into the main query to bypass the limitation.