SET RECIPIENT
適用於: Databricks SQL Databricks Runtime 15.1 和更新版本
將 CURRENT_RECIPIENT 設定為目前會話中指定的收件者,以允許提供者模擬CURRENT_RECIPIENT屬性。 這可讓 providers 查詢 views,而這些 views 包含 CURRENT_RECIPIENT 函式。
語法
SET RECIPIENT recipient_name
Parameters
-
將 set 設定為當前收件者的名稱。
例子
— 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