snow app validate¶
验证已部署的 Snowflake Native App 的安装脚本。
语法¶
snow app validate
  --package-entity-id <package_entity_id>
  --app-entity-id <app_entity_id>
  --project <project_definition>
  --env <env_overrides>
  --connection <connection>
  --host <host>
  --port <port>
  --account <account>
  --user <user>
  --password <password>
  --authenticator <authenticator>
  --workload-identity-provider <workload_identity_provider>
  --private-key-file <private_key_file>
  --token <token>
  --token-file-path <token_file_path>
  --database <database>
  --schema <schema>
  --role <role>
  --warehouse <warehouse>
  --temporary-connection
  --mfa-passcode <mfa_passcode>
  --enable-diag
  --diag-log-path <diag_log_path>
  --diag-allowlist-path <diag_allowlist_path>
  --oauth-client-id <oauth_client_id>
  --oauth-client-secret <oauth_client_secret>
  --oauth-authorization-url <oauth_authorization_url>
  --oauth-token-request-url <oauth_token_request_url>
  --oauth-redirect-uri <oauth_redirect_uri>
  --oauth-scope <oauth_scope>
  --oauth-disable-pkce
  --oauth-enable-refresh-tokens
  --oauth-enable-single-use-refresh-tokens
  --client-store-temporary-credential
  --format <format>
  --verbose
  --debug
  --silent
  --enhanced-exit-codes
实参¶
无
选项¶
--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 TEXT连接名称,如您在
config.toml文件中所定义。默认值:default。--host TEXT连接的主机地址。替换为连接指定的值。
--port INTEGER连接的端口。替换为连接指定的值。
--account, --accountname TEXT分配给 Snowflake 账户的名称。替换为连接指定的值。
--user, --username TEXT连接到 Snowflake 的用户名。替换为连接指定的值。
--password TEXTSnowflake 密码。替换为连接指定的值。
--authenticator TEXTSnowflake 身份验证器。替换为连接指定的值。
--workload-identity-provider TEXTWorkload identity provider (AWS, AZURE, GCP, OIDC). Overrides the value specified for the connection.
--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, -x使用命令行参数定义的连接,而不是在配置中定义的连接。默认值:False。
--mfa-passcode TEXT用于多重身份验证的令牌 (MFA)。
--enable-diag是否生成连接诊断报告。默认值:False。
--diag-log-path TEXT生成的报告的路径。默认为系统临时目录。默认:<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-pkce禁用代码交换证明密钥 (PKCE)。默认值:
False。--oauth-enable-refresh-tokens在实际访问令牌过期时启用静默重新身份验证。默认值:
False。--oauth-enable-single-use-refresh-tokens是否选择启用一次性刷新令牌语义。默认值:
False。--client-store-temporary-credential存储临时凭据。
--format [TABLE|JSON|JSON_EXT|CSV]指定输出格式。默认:TABLE。
--verbose, -v显示日志级别
info及更高级别的日志条目。默认值:False。--debug显示日志级别
debug及更高级别的日志条目;调试日志包含其他信息。默认值:False。--silent关闭到控制台的中间输出。默认值:False。
--enhanced-exit-codes根据错误类型区分退出错误代码。默认值:False。
--help显示此命令的帮助文本。
使用说明¶
为了避免影响应用程序源暂存区中的文件,此命令使用 应用程序包 实体的 scratch_stage 来创建空白暂存区、将项目文件上传到此暂存区、运行验证以及删除该暂存区。
验证会分别返回错误和警告。错误会导致命令退出,退出代码为 1,但警告不会。
示例¶
以下示例显示了成功验证的输出:
snow app validate
Validating Snowflake Native App setup script. Checking if stage st_version_pkg_<user>.app_src.stage_snowflake_cli_scratch exists, or creating a new one if none exists. Performing a diff between the Snowflake stage and your local deploy_root ('<APP_PATH>/apps/st-version/output/deploy') directory. There are no new files that exist only on the stage. There are no existing files that have been modified, or their status is unknown. There are no existing files that are identical to the ones on the stage. New files only on your local: README.md manifest.yml setup_script.sql streamlit/environment.yml streamlit/ui.py Uploading diff-ed files from your local <APP_PATH>/apps/st-version/output/deploy directory to the Snowflake stage. Dropping stage st_version_pkg_<user>.app_src.stage_snowflake_cli_scratch. Snowflake Native App validation succeeded.
以下示例显示了成功验证的输出,该输出使用 JSON 输出格式:
snow app validate --format json
{ "errors": [], "warnings": [], "status": "SUCCESS" }
以下示例显示了验证遇到错误和警告时的输出,该输出使用 JSON 输出格式:
snow app validate --format json
{ "errors": [ { "message": "Error in file '@STAGE_SNOWFLAKE_CLI_SCRATCH/empty.sql': Empty SQL statement.", "cause": "Empty SQL statement.", "errorCode": "000900", "fileName": "@STAGE_SNOWFLAKE_CLI_SCRATCH/empty.sql", "line": -1, "column": -1 }, { "message": "Error in file '@STAGE_SNOWFLAKE_CLI_SCRATCH/second.sql': Unsupported feature 'CREATE VERSIONED SCHEMA without OR ALTER'.", "cause": "Unsupported feature 'CREATE VERSIONED SCHEMA without OR ALTER'.", "errorCode": "000002", "fileName": "@STAGE_SNOWFLAKE_CLI_SCRATCH/second.sql", "line": -1, "column": -1 }, { "message": "Error in file '@STAGE_SNOWFLAKE_CLI_SCRATCH/setup_script.sql': File '/does-not-exist.sql' cannot be found in the same stage as the setup script is located.", "cause": "File '/does-not-exist.sql' cannot be found in the same stage as the setup script is located.", "errorCode": "093159", "fileName": "@STAGE_SNOWFLAKE_CLI_SCRATCH/setup_script.sql", "line": -1, "column": -1 } ], "warnings": [ { "message": "Warning in file '@STAGE_SNOWFLAKE_CLI_SCRATCH/setup_script.sql' on line 11 at position 35: APPLICATION ROLE should be created with IF NOT EXISTS.", "cause": "APPLICATION ROLE should be created with IF NOT EXISTS.", "errorCode": "093352", "fileName": "@STAGE_SNOWFLAKE_CLI_SCRATCH/setup_script.sql", "line": 11, "column": 35 }, { "message": "Warning in file '@STAGE_SNOWFLAKE_CLI_SCRATCH/setup_script.sql' on line 15 at position 13: CREATE Table statement in the setup script should have \"IF NOT EXISTS\", \"OR REPLACE\", or \"OR ALTER\".", "cause": "CREATE Table statement in the setup script should have \"IF NOT EXISTS\", \"OR REPLACE\", or \"OR ALTER\".", "errorCode": "093351", "fileName": "@STAGE_SNOWFLAKE_CLI_SCRATCH/setup_script.sql", "line": 15, "column": 13 }, { "message": "Warning in file '@STAGE_SNOWFLAKE_CLI_SCRATCH/setup_script.sql' on line 15 at position 13: Table identifier 'MY_TABLE' should include its parent schema name.", "cause": "Table identifier 'MY_TABLE' should include its parent schema name.", "errorCode": "093353", "fileName": "@STAGE_SNOWFLAKE_CLI_SCRATCH/setup_script.sql", "line": 15, "column": 13 } ], "status": "FAIL" }