Snowpark Migration Accelerator: 使用 SMA CLI

描述

Snowpark Migration Accelerator (SMA) 提供命令行界面 (CLI),允许您执行各种操作。使用此 CLI,您可以执行代码处理器、管理访问代码(安装或显示它们),以及执行 SMA 应用程序中提供的任何其他任务。

The SMA uses a single code processor that works with all supported source platforms. You don't need to provide any additional arguments for this processor.

安装

Before installing the Command Line Interface (CLI), you need to download it to a location you can access. Choose the installation guide that matches your operating system:

命令

要运行该工具,您需要根据您的要求设置一系列命令。您可以使用 长命令短命令 选项,语法如下:

sma [command] [argument] [command] [argument] ...

以下命令可用。点击任意命令可查看其详细说明。

Long-command

Short-Command

描述

--help

-h

Displays help documentation.

--version

-v

Displays current tool version.

install-access-code

install-ac

Installs a new access code.

show-access-code

show-ac

Displays all installed access codes.

--input

-i

Specifies the input folder location.

--output

-o

Specifies the output folder location.

--assessment

-a

Runs the tool in assessment mode.

--mapDirectory

-m

Specifies the folder containing custom mapping files.

--enableJupyter

-j

Enables or disables conversion of Databricks notebooks to Jupyter format.

--sql

-f

Specifies which database engine syntax to use for SQL commands.

--customerEmail

-e

Sets the customer email address.

--customerCompany

-c

Sets the customer company name.

--projectName

-p

Sets the project name.

--yes

-y

Skips confirmation prompts during execution.

安装访问码

要开始代码转换过程,您必须先安装访问码。您可以通过两种方式来做到这一点:

  1. 直接输入访问码

  2. 提供包含访问码的文件的路径(当您离线工作或在防火墙限制严格的环境中工作时,此方法很有用)

您可以通过运行以下命令来安装访问码:

sma install-access-code <access-code>

此命令产生的结果与前面的命令相同。

sma install-ac <access-code>

To install an access code from a file, use either the --file or -f option with your command, like this:

sma install-access-code --file <path-to-file>
or
sma install-access-code -f <path-to-file>

如果安装许可证时出现错误,系统将显示错误消息。

要申请访问码,请联系 sma-support@snowflake.com

检查安装了哪些访问码

要检查您的计算机上当前安装了哪些访问码,请使用以下命令:

sma show-access-code

此命令显示有关计算机上当前安装的所有访问码的详细信息。

转换

安装有效许可证后,您可以运行代码处理器来转换代码。要开始转换过程,您需要提供以下必需的实参:

  • 输入路径: 包含原始源代码的文件夹

  • 输出路径: 用于保存转换后的代码的文件夹

项目信息

When you run the code processor for the first time, you need to provide certain arguments. These arguments will be saved and used for future executions. The required arguments are the same as those needed when creating a new project in the application.

  • 客户电子邮件地址: 输入有效的电子邮件地址

  • 客户公司: 输入您的公司名称

  • 项目名称: 输入您的项目名称

此示例演示如何仅使用基本要求来执行代码处理器:

sma -i <input-path> -o <output-path> -e <client email> -c <client company> -p <project name> <additional-parameters>

输入命令序列并按“Enter”后,该工具将显示您的当前设置,并要求您进行确认,然后再开始该过程。

启动过程之前的当前配置。

您想添加或修改任何实参吗?输入“n”可取消,输入“y”可继续。

跳过项目确认

要绕过上面显示的确认提示,请添加 --yes-y 作为实参。在以编程方式使用该工具时,这一点尤其重要,因为每次没有这些参数时都会出现确认提示。

For more information about all available parameters, please refer to this link.

执行评估

When performing an assessment, add the --assessment or -a option to the standard conversion commands. Here are examples of how the commands should look:

sma --input <input-path> --output <output-path> --assessment <additional-parameters>

这些命令中的每一个都可以接受其他参数。有关更多详情,请参阅“转换”部分。

检查工具版本

要检查工具版本和代码处理引擎,您可以使用以下任何命令:

sma --version
sma -v

允许将 Databricks 笔记本转换为 Jupyter 笔记本

此选项可将 Python (.python) 和/或 Scala (.scala) 源文件转换为 Jupyter Notebook (.ipynb) 文件。无论原始文件是从笔记本中导出的,还是常规代码文件,都可以进行转换。

To convert Jupyter notebooks, add either the '--enableJupyter' flag or its shorthand version '-j' to your command.

sma -i <input-path> -o <output-path> --enableJupyter

设置源代码的 SQL 风格

You can specify which SQL syntax to use when a SQL command is detected. Use either the command '--sql' or its shortcut '-f'. The supported syntax options are 'SparkSql' (which is the default), 'HiveSql', and 'Databricks'.

sma --input <input-path> --output <output-path> --sql SparkSql
sma --input <input-path> --output <output-path> --sql HiveSql
sma --input <input-path> --output <output-path> --sql Databricks

需要更多帮助?

要查看命令行界面 (CLI) 的常规帮助信息,您可以使用以下任何命令:

sma --help
sma -h
帮助信息

要了解有关特定命令的更多信息,您可以执行以下命令:

sma <command> --help

To learn more about installing an access code, run the command sma install-access-code --help.