Snowflake Data Clean Rooms 개발자 가이드¶
This topic provides guidelines for users who want to create or manage Snowflake Data Clean Rooms programmatically.
Snowflake exposes an API of stored procedures for creating and controlling clean rooms. These stored procedures can be run in any interface that can access the Snowflake account associated with your clean room environment, including Snowsight notebooks and worksheets, as well as the Snowflake CLI. These procedures can be called in SQL or in any language supported by your Snowflake environment.
환경 설정하기¶
개발 도구¶
Clean Rooms를 위한 주요 개발자 도구는 다음과 같습니다.
코딩 환경: Snowflake 계정에서 저장 프로시저를 실행할 수 있는 모든 코딩 환경이 작동합니다. 대부분의 개발자는 Snowsight(브라우저 기반 도구) 또는 Snowflake CLI 에서 워크시트를 사용합니다.
The clean rooms UI: Use the clean rooms UI to configure, manage, or create clean rooms. Most clean room analysts use the UI rather than code, so it’s important to see and test the experience of your clean rooms in the UI. Additionally, there are a handful of features that are available only in the clean rooms UI.
Snowsight 는 데이터베이스 및 기타 오브젝트를 탐색하고 오브젝트를 검색하는 데 유용합니다.
Clean rooms API: API documentation is divided into provider and consumer topic pages.
코딩 설정¶
요구되는 역할 및 웨어하우스¶
The clean rooms API requires the SAMOOHA_APP_ROLE role for full API access. Ask your clean rooms administrator to grant you full API access. Clean rooms also supports creating roles with access to a subset of API procedures.
SAMOOHA_APP_ROLE이 사용할 수 있는 웨어하우스에서 클린룸 API를 사용해야 합니다. ``app_wh``는 API에 대한 액세스 권한이 있는 여러 웨어하우스 중 하나입니다. 요구 사항에 적합한 웨어하우스를 선택합니다.
-- Set up environment.
USE ROLE SAMOOHA_APP_ROLE;
USE WAREHOUSE app_wh;
-- Call your clean rooms API functions.
...
다른 웨어하우스를 사용하는 경우 해당 웨어하우스에 SAMOOHA_APP_ROLE 사용 권한을 부여해야 합니다.
GRANT USAGE ON WAREHOUSE <your_warehouse> TO SAMOOHA_APP_ROLE;`
Clean Rooms 정보 API 정보¶
Snowflake Data Clean Rooms exposes a set of stored procedures that let a provider create, configure, and share a clean room. These procedures can be called in any command-line environment that supports Snowflake procedures, including notebooks, worksheets, and the Snowflake CLI. The documentation here shows SQL usage, but you can also use Python or any other supported Snowflake language.
프로시저는 다음 스키마 안에 존재합니다.
samooha_by_snowflake_local_db.provider- 공급자별 프로시저. 이러한 프로시저는 현재 계정에서 생성된 Clean Rooms에서만 호출할 수 있습니다.samooha_by_snowflake_local_db.consumer- 컨슈머 전용 프로시저. 이러한 프로시저는 현재 계정이 컨슈머로 초대된 클린룸에서만 호출할 수 있습니다.samooha_by_snowflake_local_db.library- General procedures called by either the clean room creator (provider) or a clean room collaborator (consumer). These procedures are documented in both the provider and consumer reference pages.
Some procedures have both provider and consumer versions. The results are appropriate to the schema: for example,
provider.view_cleanrooms lists all clean rooms in the current account for which you are a provider, and consumer.view_cleanrooms lists
all clean rooms in the current account for which you are a consumer. Be sure to call the procedure in the namespace that you need.
API 프로시저의 Clean Room 이름 정보¶
많은 Clean Room API 프로시저는 cleanroom_name 인자를 받습니다.
클린룸이 API를 사용하여 생성된 경우 클린룸 :emph:`이름`을 사용하세요. 패키지 이름의 일부로 사용되는 경우 공백을 밑줄로 바꿉니다.
-- Spaces work here: CALL samooha_by_snowflake_local_db.provider.describe_cleanroom('my code created clean room'); -- Underscores required here: SHOW VERSIONS IN APPLICATION PACKAGE SAMOOHA_CLEANROOM_my_code_created_clean_room;
클린룸이 클린룸 UI를 사용하여 생성된 경우 클린룸 :emph:`ID`를 사용합니다.
describe_cleanroom 또는 ``view_cleanrooms``를 호출하여 클린룸 이름과 ID를 볼 수 있습니다.
Clean rooms created using the API are labeled in the clean rooms UI as Supported with Developer APIs.
계정, 사용자 및 역할 설정하기¶
You aren’t required to use the clean rooms UI to develop clean rooms: most clean room functionality is available by calling the API. However, a few features are available only in the UI, and some are faster to perform in the UI. And because many users use the UI exclusively, it’s important to see how your clean room behaves in the UI. Therefore, you should ask a clean room administrator to add you as a clean room manager or higher in the appropriate clean room accounts.
사용 사례에 따라 다른 웹 호스팅 리전에 추가 Snowflake 계정을 설정하여 :doc:`클라우드 간 동작</user-guide/cleanrooms/enabling-laf>`을 테스트할 수도 있습니다.
Name your test Snowflake accounts meaningfully to indicate their typical usage: for example, “Consumer account,” “Provider account,” and “Cross-cloud account.” This can help when you have multiple test accounts and must choose an account on the clean rooms login page.
내부 테스트 클린룸¶
You can test a clean room during development by sharing the clean room with yourself. Such a clean room is called an internal testing clean room. Using a single account for both provider and consumer is convenient for quick feature testing.
To create an internal testing clean room, simply pass the provider account information to provider.add_consumers as the sole consumer.
Internal testing clean rooms have the following restrictions:
An internal testing clean room cannot later be shared with other accounts. An internal testing clean room always is an internal testing clean room.
다음 기능은 내부 테스트 클린룸에서 지원되지 않습니다.
공급자 활성화
공급자 실행 분석
요청 로그(
provider.mount_request_logs_for_all_consumers``또는 ``provider.view_request_logs) 마운트 또는 보기컨슈머 정의 템플릿
다중 공급자 분석
차등 개인정보 보호
내부 테스트룸에서 지원되지 않는 기능을 테스트하려면 별도의 공급자 및 컨슈머 Snowflake 계정을 설정하여 클린룸의 양쪽을 테스트해야 합니다.
Download a sample worksheet that demonstrates using a clean room in a
single account for both provider and consumer.
클린룸 환경에 설치된 항목 확인¶
Snowflake Data Clean Rooms는 설치 시 많은 로컬 데이터베이스를 생성합니다. :doc:`/user-guide/cleanrooms/installation-details`에서 클린룸 패키지로 실행되거나 설치된 작업 및 오브젝트에 대한 세부 정보를 찾을 수 있습니다.
샘플 데이터¶
클린룸 환경은 사용할 수 있는 :ref:`몇 가지 샘플 데이터 세트<label-dcr_samooha_sample_database>`를 설치합니다.
Snowflake를 사용하여 :doc:`합성 테스트 데이터를 생성</user-guide/synthetic-data>`할 수도 있습니다.
가이드라인 및 권장 사항¶
Clean Rooms UI 와 코드에서 동일한 계정을 사용하고 있는지 확인하기¶
예를 들어 코드에서 Clean Room을 만든 다음 Clean Rooms UI 에서 그 모양을 확인할 때와 같이 코딩 환경과 Clean Rooms UI 를 동일한 Snowflake 계정으로 열어야 하는 경우가 많습니다. 각각에서 동일한 Snowflake 계정을 사용하고 있는지 확인하는 것이 중요합니다.
Snowsight does not have a shortcut to open the clean rooms UI for the same account, or the reverse, so you must be sure to log in to the same account in each environment.
Clean Room 이름과 Clean Room ID¶
When using the API, for procedures that take a clean room name argument, determine whether to use the clean room name or the clean room ID as follows:
Update your clean room whenever you make UI changes¶
When you change any clean room properties that affect the UI, call
provider.create_or_update_cleanroom_listing to propagate the changes.
코드 또는 UI 에서 생성된 Clean Rooms 간의 상호 운용성¶
When you create a clean room using the API, some features are not modifiable in the clean rooms UI. For example, you cannot add additional templates, even stock Snowflake templates, in code for a UI-created clean room. You also cannot change the differential privacy settings.
문제 해결하기¶
컨슈머가 조인 정책을 설정하거나 조인된 클린룸에서 다른 기본 작업을 수행할 수 없음¶
적절한 역할(SAMOOHA_APP_ROLE)로 Clean Room을 설치했는지 확인합니다. Clean Room을 설치할 때 SAMOOHA_APP_ROLE 을 사용하지 않았다면 일반적으로 권한 오류와 같은 많은 문제가 발생할 수 있습니다. 이 경우 consumer.uninstall_cleanroom 조차도 실패하므로 올바른 역할을 하는 Clean Room을 제거한 다음 다시 설치하는 추가 단계를 수행해야 합니다.
-- Who owns the clean room?
SHOW SHARES LIKE 'SAMOOHA_CLEANROOM_REQUESTS_<cleanroom_name>';
-- If the owner role is not SAMOOHA_APP_ROLE, you must drop the share, then
-- uninstall the clean room.
DROP SHARE SAMOOHA_CLEANROOM_REQUESTS_<cleanroom_name>;
CALL samooha_by_snowflake_local_db.consumer.uninstall_cleanroom($cleanroom_name);
USE ROLE SAMOOHA_APP_ROLE;
CALL samooha_by_snowflake_local_db.consumer.install_cleanroom($cleanroom_name, '<provider_locator>');
생성한 Clean Room을 찾을 수 없음¶
한 계정에서 Clean Room을 만들었는데 공동 작업자의 계정에서 볼 수 없는 경우 몇 가지 이유가 있을 수 있습니다.
Clean Room이 다른 클라우드 호스팅 리전에서 생성되었으며 클라우드 간 자동 복제 를 활성화하지 않았습니다.
provider.create_or_update_cleanroom_listing을 호출하여 Clean Room을 게시하지 않았습니다.provider.view_cleanrooms()대신consumer.view_cleanrooms()를 호출하고 있습니다(또는 그 반대).Clean Room을 공유하지 않았거나, 잘못된 계정으로 Clean Room을 공유했거나, Snowsight/Clean rooms UI/CLI 에서 잘못된 공동 작업자 계정에 로그인했습니다. Clean Room을 볼 수 있는 계정이 Clean Room을 공유한 계정인지, 그리고 해당 공유 계정에 로그인되어 있는지 확인합니다.
Clean Room을 게시한 후 공동 작업자가 볼 수 있는 시점까지는 약간의 지연이 있습니다.
알 수 없는 함수¶
프로시저를 호출하고 다음 코드 조각과 같은 오류가 발생하는 경우:
Unknown user-defined function SAMOOHA_BY_SNOWFLAKE_LOCAL_DB.CONSUMER.<procedure name>
다음은 몇 가지 가능한 원인입니다.
- 네임스페이스를 잘못 입력했습니다.
해당 프로시저의 적절한
consumer또는provider버전을 호출해야 합니다. 많은 프로시저에는 공급자 버전과 컨슈머 버전이 모두 있습니다.- 함수 이름을 잘못 입력했습니다.
올바른 명명은 참조 가이드를 확인하세요.
- 제한된 액세스 실행 역할이 부여되었으며 호출한 함수가 자신의 역할에서 허용되지 않습니다.
다음 SQL 코드를 실행하여 이를 테스트합니다.
USE DATABASE samooha_by_snowflake_local_db; CALL IS_DATABASE_ROLE_IN_SESSION('samooha_run_role');
코드 조각이 TRUE를 반환하는 경우 클린룸 API에 대한 제한된 액세스 실행 역할 권한이 있습니다. 더 많은 액세스 권한이 필요한 경우 클린룸 관리자에게 전체 액세스 권한을 요청하세요. :ref:`consumer.grant_run_on_cleanrooms_to_role documentation<label-dcr_sproc_consumer_manage_role_access>`에서 허용되는 실행 역할 프로시저 목록을 참조하세요.
- SAMOOHA_APP_ROLE이 없음
SAMOOHA_APP_ROLE을 사용할 수 있는지 확인하려면 다음 명령을 실행합니다.
-- Get current user name. SELECT current_user(); -- Add current user name in place as indicated. SHOW GRANTS TO USER <current_user_name> ->> select * from $1 where "role" = 'SAMOOHA_APP_ROLE';
결과를 얻지 못한 경우 관리자에게 클린룸에 대한 API 액세스를 요청하세요.
사용자가 클린룸을 설치했는지 확인¶
다음 SQL 코드를 실행하여 지정된 사용자가 지정된 클린룸을 설치했는지 확인할 수 있습니다. $consumer_locator 및 ``$cleanroom_name``을 컨슈머 로케이터 및 클린룸 이름으로 바꿉니다.
SELECT * FROM snowflake.data_sharing_usage.application_state
WHERE consumer_account_locator = $consumer_locator
AND CONTAINS(package_name, UPPER(REPLACE($cleanroom_name, ' ', '_')));
쿼리 또는 분석 기록 확인¶
UI 또는 코드에서 실행된 분석에 대한 쿼리 기록을 볼 수 있습니다. 이러한 기록은 별도로 저장되고 확인됩니다.
UI 분석 기록¶
클린룸 UI는 :ui:`Analyses & Queries`페이지에서 이 계정에 대한 모든 이전 분석 목록을 표시합니다. 이러한 결과는 UI에서 실행되는 쿼리에만 해당됩니다.
클린룸을 수정하거나 삭제하면 보고서가 다음 템플릿 중 하나를 사용하지 않는 한 해당 클린룸에 대한 UI의 분석 보고서가 삭제됩니다.
Audience Overlap & Segmentation
SQL Query
사용자 지정 템플릿.
위에 나열된 템플릿에 대한 쿼리 기록은 클린룸이 수정되거나 삭제되더라도 유지됩니다.
API 쿼리 기록¶
API를 사용하여 실행된 모든 호출의 계정 기록과 템플릿 분석을 보려면 다음을 수행하세요.
Snowsight 에 로그인합니다.
탐색 메뉴에서 Monitoring » Query History 를 선택합니다.
필터를 사용하여 분석과 관련된 쿼리를 찾고, 쿼리 또는 분석을 선택합니다.
확장된 예¶
To help you understand how to use various features of the Developer APIs, you can refer to the examples in the Use cases and Features sections of the clean rooms documentation.