Snow 应用程序运行¶
在 Snowflake 账户中创建应用程序包,将代码文件上传到相应暂存区,然后通过应用程序包创建或升级应用程序对象。
语法
实参
无
选项
--version TEXT您要用来创建应用程序对象的现有应用程序包定义版本。根据项目定义文件确定应用程序对象和应用程序包名称。
--patch INTEGERThe patch number under the given –version defined in an existing application package that should be used to create an application object. The application object and application package names are determined from the project definition file.
--from-release-directive创建或升级应用程序对象,使其适用于 Snowflake 账户的版本指令指定的版本和补丁。如果给定应用程序包的 Snowflake 账户不存在版本指令,则该命令将失败,指令会由项目定义文件确定。默认:未设置。默认值:False。
--channel TEXTThe name of the release channel to use when creating or upgrading an application instance from a release directive. Requires the –from-release-directive flag to be set. If unset, the default channel will be used.
--interactive / --no-interactive启用此选项后,即使标准输入和输出不是终端设备,也会显示提示。在交互式 shell 环境中默认值为 True,否则为 False。
--force启用此选项后,命令会隐式批准出现的任何提示。如果未指定交互模式,并且想要执行可能具有破坏性的操作,则应启用此选项。默认为未设置。默认值:False。
--validate / --no-validate启用后,此选项将触发已部署的 Snowflake Native App 安装脚本 SQL 的验证。默认值:True。
--package-entity-id TEXT当 definition_version 为 2 或更高时,要操作的包实体的 ID。
--app-entity-id TEXT当 definition_version 为 2 或更高时,要操作的应用程序实体的 ID。
-p, --project TEXTSnowflake 项目的存储路径。默认为当前工作目录。
--env TEXT格式为 key=value 的字符串。替换用于模板的 env 部分的变量。默认值:[]。
--connection, -c, --environment TEXTName of the connection, as defined in your config.toml file. Default: default.
--host TEXT连接的主机地址。替换为连接指定的值。
--port INTEGER连接的端口。替换为连接指定的值。
--account, --accountname TEXT分配给 Snowflake 账户的名称。替换为连接指定的值。
--user, --username TEXT连接到 Snowflake 的用户名。替换为连接指定的值。
--password TEXTSnowflake 密码。替换为连接指定的值。
--authenticator TEXTSnowflake 身份验证器。替换为连接指定的值。
--workload-identity-provider TEXT工作负载身份提供商(AWS、AZURE、GCP、OIDC)。替换为连接指定的值。
--private-key-file, --private-key-path TEXTSnowflake 私钥文件路径。替换为连接指定的值。
--token TEXT连接到 Snowflake 时使用的 OAuth 令牌。
--token-file-path TEXT连接到 Snowflake 时使用的带有 OAuth 令牌的文件路径。
--database, --dbname TEXT要使用的数据库。替换为连接指定的值。
--schema, --schemaname TEXT要使用的数据库架构。替换为连接指定的值。
--role, --rolename TEXT要使用的角色。替换为连接指定的值。
--warehouse TEXT要使用的仓库。替换为连接指定的值。
--temporary-connection, -xUses a connection defined with command-line parameters, instead of one defined in config. Default: False.
--mfa-passcode TEXT用于多重身份验证的令牌 (MFA)。
--enable-diag是否生成连接诊断报告。默认值:False。
--diag-log-path TEXTPath for the generated report. Defaults to system temporary directory. Default: <system_temporary_directory>.
--diag-allowlist-path TEXT包含允许列表参数的 JSON 文件的路径。
--oauth-client-id TEXT身份提供商为 Snowflake 集成提供的客户端 ID 的值。
--oauth-client-secret TEXT身份提供商为 Snowflake 集成提供的客户端密钥的值。
--oauth-authorization-url TEXT向驱动程序提供授权码的身份提供商端点。
--oauth-token-request-url TEXT向驱动程序提供访问令牌的身份提供商端点。
--oauth-redirect-uri TEXTURI 用于授权码重定向。
--oauth-scope TEXT身份提供商授权请求中请求的范围。
--oauth-disable-pkceDisables Proof Key for Code Exchange (PKCE). Default: False.
--oauth-enable-refresh-tokensEnables a silent re-authentication when the actual access token becomes outdated. Default: False.
--oauth-enable-single-use-refresh-tokensWhether to opt-in to single-use refresh token semantics. Default: False.
--client-store-temporary-credential存储临时凭据。
--format [TABLE%JSON%JSON_EXT|CSV]指定输出格式。默认:TABLE。
--verbose, -vDisplays log entries for log levels info and higher. Default: False.
--debugDisplays log entries for log levels debug and higher; debug logs contain additional information. Default: False.
--silent关闭到控制台的中间输出。默认值:False。
--enhanced-exit-codes根据错误类型区分退出错误代码。默认值:False。
--decimal-precision INTEGERNumber of decimal places to display for decimal values. Uses Python’s default precision if not specified. [env var: SNOWFLAKE_DECIMAL_PRECISION].
--helpDisplays the help text for this command.
使用说明
Note
This command does not accept a role or warehouse overrides to your config.toml file. Please add them to the native app definition in the snowflake.yml or snowflake.local.yml instead.
This command relies on the resolved project definition to determine the stage to which to upload files, which files to upload, and the name of the objects to create. For guidance on defaults, please refer to About Snowflake Native App projects and snow init usage notes. You can also change them to be according to your own preference, though it is your responsibility to check if there is any clash with existing objects in your account.
- Objects created by Snowflake CLI are tagged with a special comment
GENERATED_BY_SNOWCLI. - The role(s) used to create the application package and instance must have the proper account-level privileges to work with Snowflake Native Applications. See Create and manage an application package and Install and test an app locally for more information.
By default, the snow app run command creates an application package in your Snowflake account, uploads code files to its stage, validates the setup script SQL, and then creates (or upgrades) a development-mode instance of that application. You should keep the following in mind when running the default command:
- All files specified under
nativeapp.project.artifactsin the project definition file(s) are uploaded to the Snowflake stage. This artifact must include amanifest.ymlfile and its related setup script(s). - All files specified under
nativeapp.project.artifactsmust have already been compiled and packaged separately, if needed, before callingsnow app run. Snowflake CLI does not offer any feature to perform these intermediate tasks for you, so you have full control over your build process by executing it in your own scripts. - Snowflake CLI uses default application package name, stage name, and application name when creating those objects.
- Subsequent runs of
snow app runafter the initial one compare the state of your uploaded files to the files in your local directory, and selectively upload only the modified files to save you time. If any files have changed, the application is upgraded based on the new contents of the stage. - If the application package already exists and its distribution property is
INTERNAL, the command checks if the package was created by the Snowflake CLI. If it was not, the command throws an error. If the distribution of the application package isEXTERNAL, no such check is performed. - 如果您正在使用的应用程序包的分发值与解析的项目定义中设置的值不同,则该命令会警告您,但会继续执行。
- The application instance is created or upgraded in development mode. Specifically, it uses the staged files.
If you specify a --version, --patch or --from-release-directive option, this command upgrades your existing application instance, or creates one if the application does not exist. It does not create an application package in this scenario.
- If Snowflake CLI is not able to update your application for any reason, such as trying to upgrade an application initially installed in loose files mode to use release directives instead, it attempts to drop the existing application and create a new one using the desired installation strategy. The command prompts you to confirm the drop before performing the action.
- If you do not want to interact with the command and instead force all actions, use the
--forceoption to bypass all prompts, which proxies as a yes to all the inputs asking whether to proceed with destructive actions. - Snowflake CLI tries to determine if you are running the commands in an interactive shell. If
--forceis not provided and you are executing commands in the interactive shell, it automatically chooses the interactive option for you. - If you want to force Snowflake CLI to interact with you even if not in an interactive shell, use the
--interactiveoption.
示例
These examples assume you have made the necessary changes to your code files and added them to your snowflake.yml or snowflake.local.yml files.
-
如果要使用暂存文件创建应用程序包和应用程序,可以执行以下操作:
-
如果您已经拥有带有版本和修补程序的应用程序包,希望使用此版本和补丁创建应用程序,并调用交互模式,则可以执行以下操作:
Here, version
V1and patch12are used as an example only. -
如果您在应用程序包设置了现有的版本指令,希望使用其创建应用程序并绕过交互模式,则可以执行以下操作:
-
要从非默认发布通道的发布指令创建应用程序,请执行:
-
This example shows how to pass in multiple environment variables using the
--envoption: