CREATE DBT PROJECT¶
Creates a new dbt project object or replaces an existing dbt project object. Running CREATE DBT PROJECT with the OR REPLACE option resets the version identifier to version$1 and removes all version name aliases. For more information, see Versions for dbt project objects and files.
- 참고 항목:
ALTER DBT PROJECT, DESCRIBE DBT PROJECT, EXECUTE DBT PROJECT, SHOW DBT PROJECTS, DROP DBT PROJECT
구문¶
매개 변수¶
nameString that specifies the name of the dbt project object. Must be unique within the schema in which the dbt project object is created.
또한, 식별자는 알파벳 문자로 시작해야 하며 전체 식별자 문자열을 큰따옴표(예:
"My object")로 묶지 않는 한 공백이나 특수 문자를 포함할 수 없습니다. 큰따옴표로 묶인 식별자도 대/소문자를 구분합니다.자세한 내용은 식별자 요구 사항 섹션을 참조하십시오.
FROM 'source_location'Required. A string that specifies the location of the dbt project source files.
The source location must point to a directory that contains a single
dbt_project.ymlfile at its root. Although workspaces support working with repositories that contain multiple dbt projects, you must select a specific project directory when deploying a dbt project object.The dbt project object source files can be in any one of the following locations:
Git 리포지토리 스테이지, 예를 들면 다음과 같습니다.
'@my_db.my_schema.my_git_repository_stage/branches/my_branch/path/to/dbt_project_or_projects_parent'Snowflake에서 |sf-dbt|용 워크스페이스에 Git 리포지토리를 연결하는 Git 리포지토리 오브젝트를 생성하는 방법에 대한 자세한 내용은 Git 리포지토리에 연결된 작업 공간 만들기 섹션을 참조하세요. 워크스페이스를 사용하지 않고 Git 리포지토리 오브젝트 및 스테이지를 생성하고 관리하는 방법에 대한 자세한 내용은 Snowflake에서 Git 리포지토리 사용하기 및 CREATE GIT REPOSITORY 섹션을 참조하세요.
기존 dbt 프로젝트 스테이지, 예를 들면 다음과 같습니다.
'snow://dbt/my_db.my_schema.my_existing_dbt_project_object/versions/last'The version specifier is required and can be
last(as shown in the previous example),first, or the specifier for any existing version in the formversion$<num>. For more information, see Versions for dbt project objects and files.명명된 내부 스테이지, 예를 들면 다음과 같습니다.
'@my_db.my_schema.my_internal_named_stage/path/to/dbt_projects_or_projects_parent'내부 사용자 스테이지 및 테이블 스테이지는 지원되지 않습니다.
Snowflake의 dbt를 위한 워크스페이스, 예를 들면 다음과 같습니다.
'snow://workspace/user$.public."my_workspace_name"/versions/live/path/to/dbt_projects_or_projects_parent'워크스페이스 이름은 대소문자를 구분하고 특수 문자를 포함할 수 있으므로 워크스페이스 이름을 큰따옴표로 묶는 것이 좋습니다.
The version specifier is required and can be
last,first,live, or the specifier for any existing version in the formversion$<num>. For more information, see Versions for dbt project objects and files.
COMMENT = 'string_literal'dbt 프로젝트 오브젝트에 대한 설명을 지정합니다.
기본값: 값 없음
DBT_VERSION = version_numberSpecifies a version for the dbt project object.
If no value is specified, the system defaults to the version set by the DEFAULT_DBT_VERSION account parameter. For more information, see Set the account-level default version.
DEFAULT_TARGET = default_targetSpecifies the profile used for compilation and subsequent executions (for example,
prod) of the dbt project object. You can override this parameter by using the EXECUTE DBT PROJECT command withARGS = '--target <other_target>'.기본값: 값 없음
EXTERNAL_ACCESS_INTEGRATIONS = ( integration_name [ , ... ] )dbt 패키지 허브 또는 GitHub에서 원격 종속성을 가져올 수 있는 권한을 부여하는 데 사용되는 외부 액세스 통합을 지정합니다. 오브젝트에 선언된 경우,
dbt deps`는 배포 중에 자동으로 실행됩니다. 자세한 내용은 :doc:/user-guide/data-engineering/dbt-projects-on-snowflake-dependencies` 섹션을 참조하십시오.
액세스 제어 요구 사항¶
이 작업을 실행하는 데 사용되는 역할 에는 최소한 다음 권한 이 있어야 합니다.
권한 |
오브젝트 |
|---|---|
CREATE DBT PROJECT |
스키마 |
스키마의 오브젝트에 대한 작업을 수행하려면 상위 데이터베이스에 대한 하나 이상의 권한과 상위 스키마에 대한 하나 이상의 권한이 필요합니다.
지정된 권한 세트로 사용자 지정 역할을 만드는 방법에 대한 지침은 사용자 지정 역할 만들기 섹션을 참조하십시오.
보안 오브젝트 에 대해 SQL 작업을 수행하기 위한 역할과 권한 부여에 대한 일반적인 정보는 액세스 제어의 개요 섹션을 참조하십시오.
사용법 노트¶
OR REPLACE 및 IF NOT EXISTS 절은 상호 배타적입니다. 두 절을 같은 문에 함께 사용할 수 없습니다.
CREATE OR REPLACE <오브젝트> 문은 원자성입니다. 즉, 오브젝트가 바뀔 때 단일 트랜잭션으로 이전 오브젝트가 삭제되고 새 오브젝트가 생성됩니다.
메타데이터 관련:
주의
고객은 Snowflake 서비스를 사용할 때 개인 데이터(사용자 오브젝트 제외), 민감한 데이터, 수출 통제 대상 데이터 또는 기타 규제 데이터가 메타데이터로 입력되지 않도록 해야 합니다. 자세한 내용은 Snowflake의 메타데이터 필드 섹션을 참조하십시오.
예¶
Snowflake의 Git 리포지토리 스테이지에서 dbt 프로젝트 오브젝트 만들기¶
Git 리포지토리 스테이지의 dbt 프로젝트 파일에서 이름이 sales_dbt_model`인 dbt 프로젝트 오브젝트를 생성합니다. 이 예제에서는 Snowflake에서 이름이 :code:`sales_dbt_git_stage`인 Git 리포지토리 스테이지의 :code:`main 분기를 참조하며, 프로젝트의 dbt_project.yml 파일은 리포지토리 루트에 저장됩니다. 또한 이 명령은 dbt 명령을 실행할 때 사용되는 기본 대상을 설정하고 프로젝트에 필요한 외부 액세스 통합을 지정합니다.
Snowflake의 Git 리포지토리 스테이지 내의 하위 디렉터리에서 dbt 프로젝트 오브젝트 만들기¶
여러 dbt 프로젝트가 포함된 Git 리포지토리 스테이지 내 하위 디렉터리에서 이름이 sw_region_sales_model`인 dbt 프로젝트 오브젝트를 생성합니다. 이 예제에서는 Snowflake에서 이름이 :code:`sales_dbt_git_stage`인 Git 리포지토리 스테이지의 :code:`main 분기를 참조합니다. 여기서 프로젝트의 dbt_project.yml 파일은 sales_dbt_projects_parent 디렉터리의 sw_region_dbt_project 하위 디렉터리에 저장됩니다.
이 예제에서는 다음 속성도 설정합니다.
dbt 버전
Snowflake를 통해 실행되는 dbt 명령에 사용되는 기본 실행 대상(예:
prod또는dev).External access integrations the dbt project object is permitted to use to pull remote dependencies from dbt package hub or Github.
기존 dbt 프로젝트 오브젝트의 특정 버전에서 dbt 프로젝트 오브젝트 만들기¶
Create a new dbt project object named sales_model_nw_region from version$2 of the existing sales_model dbt project object.
또한 이 예제에서는 DEFAULT_TARGET을 사용하여 기본 실행 대상을 설정하고 EXTERNAL_ACCESS_INTEGRATIONS를 사용하여 허용되는 외부 액세스 통합을 지정합니다.
여러 dbt 프로젝트가 포함된 워크스페이스에서 dbt 프로젝트 오브젝트 만들기¶
여러 dbt 프로젝트 디렉터리가 포함된 작업 공간의 라이브 버전에서 이름이 ``sales_model_from_workspace``인 새 dbt 프로젝트 오브젝트를 생성합니다. 사용자의 개인 데이터베이스 내 “My dbt Project Workspace”입니다. 이는 작업 공간에 여러 하위 프로젝트가 있고 특정 하위 디렉터리에서 dbt 프로젝트 오브젝트를 생성하려는 경우에 유용합니다. 작업 공간은 대/소문자를 구분하며 특수 문자를 포함할 수 있으므로 작업 공간 이름을 큰따옴표로 묶는 것이 좋습니다.