SET RECIPIENT

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 15.1 and later

Sets the CURRENT_RECIPIENT to the specified recipient in the current session to allow the provider to mock CURRENT_RECIPIENT properties. This enables providers to query views that contain the CURRENT_RECIPIENT function.

Syntax

SET RECIPIENT recipient_name

Parameters

  • recipient_name

    The name of the recipient to set as the current recipient.

Examples

— Creates new recipient
> CREATE RECIPIENT nasdaq PROPERTIES (‘country’ = ‘US’);

> CREATE TABLE my_table (country STRING, name STRING);
> INSERT INTO my_table VALUES (‘US’, ‘John’), (‘UK’, ‘Mary’);

> CREATE VIEW my_view AS
    SELECT * FROM my_table
    WHERE country = CURRENT_RECIPIENT('country');

— Sets current recipient
> SET RECIPIENT nasdaq;

> SELECT * FROM my_view;
  US         John