

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 自動產生 ETL 指令碼 API
<a name="aws-glue-api-etl-script-generation"></a>

ETL 產生指令碼 API 說明在 AWS Glue產生 ETL 指令碼的資料類型與 API。

## 資料類型
<a name="aws-glue-api-etl-script-generation-objects"></a>
+ [CodeGenNode 結構](#aws-glue-api-etl-script-generation-CodeGenNode)
+ [CodeGenNodeArg 結構](#aws-glue-api-etl-script-generation-CodeGenNodeArg)
+ [CodeGenEdge 結構](#aws-glue-api-etl-script-generation-CodeGenEdge)
+ [Location 結構](#aws-glue-api-etl-script-generation-Location)
+ [CatalogEntry 結構](#aws-glue-api-etl-script-generation-CatalogEntry)
+ [MappingEntry 結構](#aws-glue-api-etl-script-generation-MappingEntry)

## CodeGenNode 結構
<a name="aws-glue-api-etl-script-generation-CodeGenNode"></a>

代表有向無環圖 (DAG) 中的節點

**欄位**
+ `Id` – *必要：*UTF-8 字串，長度不可小於 1 個位元組，也不可以超過 255 個位元組，且需符合[Identifier string pattern](aws-glue-api-common.md#aws-glue-api-regex-id)。

  節點圖中獨特唯一的節點識別符。
+ `NodeType` – *必要：*UTF-8 字串。

  節點的所屬類型。
+ `Args` – *必要：*一個 [CodeGenNodeArg](#aws-glue-api-etl-script-generation-CodeGenNodeArg) 物件陣列，不可超過 50 個結構。

  節點的屬性，形式為名稱值對組。
+ `LineNumber` – 數字 (整數)。

  節點的行號。

## CodeGenNodeArg 結構
<a name="aws-glue-api-etl-script-generation-CodeGenNodeArg"></a>

節點的引數或屬性。

**欄位**
+ `Name` – *必要：*UTF-8 字串。

  引數或屬性的名稱。
+ `Value` – *必要：*UTF-8 字串。

  引數或屬性的值。
+ `Param` – 布林值。

  如果值做為參數使用，則為 true。

## CodeGenEdge 結構
<a name="aws-glue-api-etl-script-generation-CodeGenEdge"></a>

代表有向無環圖 (DAG) 中的方向性邊緣。

**欄位**
+ `Source` – *必要：*UTF-8 字串，長度不可小於 1 個位元組，也不可以超過 255 個位元組，且需符合[Identifier string pattern](aws-glue-api-common.md#aws-glue-api-regex-id)。

  邊緣開始節點的 ID。
+ `Target` – *必要：*UTF-8 字串，長度不可小於 1 個位元組，也不可以超過 255 個位元組，且需符合[Identifier string pattern](aws-glue-api-common.md#aws-glue-api-regex-id)。

  邊緣結束節點的 ID。
+ `TargetParameter` – UTF-8 字串。

  邊緣的目標。

## Location 結構
<a name="aws-glue-api-etl-script-generation-Location"></a>

資源的位置。

**欄位**
+ `Jdbc` – [CodeGenNodeArg](#aws-glue-api-etl-script-generation-CodeGenNodeArg) 物件陣列，不可超過 50 個結構。

  JDBC 位置。
+ `S3` – [CodeGenNodeArg](#aws-glue-api-etl-script-generation-CodeGenNodeArg) 物件陣列，不可超過 50 個結構。

  Amazon Simple Storage Service (Amazon S3) 的位置。
+ `DynamoDB` – [CodeGenNodeArg](#aws-glue-api-etl-script-generation-CodeGenNodeArg) 物件陣列，不可超過 50 個結構。

  Amazon DynamoDB 資料表位置。

## CatalogEntry 結構
<a name="aws-glue-api-etl-script-generation-CatalogEntry"></a>

在 AWS Glue Data Catalog中指定資料表的定義。

**欄位**
+ `DatabaseName` – *必要：*UTF-8 字串，長度不可小於 1 個位元組，也不可以超過 255 個位元組，且需符合[Single-line string pattern](aws-glue-api-common.md#aws-glue-api-regex-oneLine)。

  資料表中繼資料所在的資料庫。
+ `TableName` – *必要：*UTF-8 字串，長度不可小於 1 個位元組，也不可以超過 255 個位元組，且需符合[Single-line string pattern](aws-glue-api-common.md#aws-glue-api-regex-oneLine)。

  有問題的資料表的名稱。

## MappingEntry 結構
<a name="aws-glue-api-etl-script-generation-MappingEntry"></a>

定義映射。

**欄位**
+ `SourceTable` – UTF-8 字串。

  來源資料表的名稱。
+ `SourcePath` – UTF-8 字串。

   來源路徑。
+ `SourceType` – UTF-8 字串。

  來源類型。
+ `TargetTable` – UTF-8 字串。

  目標資料表。
+ `TargetPath` – UTF-8 字串。

  目標路徑。
+ `TargetType` – UTF-8 字串。

  目標類型。

## 作業
<a name="aws-glue-api-etl-script-generation-actions"></a>
+ [CreateScript 動作 (Python: create\$1script)](#aws-glue-api-etl-script-generation-CreateScript)
+ [GetDataflowGraph 動作 (Python: get\$1dataflow\$1graph)](#aws-glue-api-etl-script-generation-GetDataflowGraph)
+ [GetMapping 動作 (Python: get\$1mapping)](#aws-glue-api-etl-script-generation-GetMapping)
+ [GetPlan 動作 (Python: get\$1plan)](#aws-glue-api-etl-script-generation-GetPlan)

## CreateScript 動作 (Python: create\$1script)
<a name="aws-glue-api-etl-script-generation-CreateScript"></a>

將有向無環圖 (DAG) 轉換為程式碼。

**請求**
+ `DagNodes` – 一個 [CodeGenNode](#aws-glue-api-etl-script-generation-CodeGenNode) 物件陣列。

  DAG 中節點的清單。
+ `DagEdges` – 一個 [CodeGenEdge](#aws-glue-api-etl-script-generation-CodeGenEdge) 物件陣列。

  DAG 中邊緣的清單。
+ `Language` – UTF-8 字串 (有效值：`PYTHON` \$1 `SCALA`)。

  從 DAG 所產生程式碼的程式設計語言。

**回應**
+ `PythonScript` – UTF-8 字串。

  從 DAG 產生的 Python 指令碼。
+ `ScalaCode` – UTF-8 字串。

  從 DAG 產生的 Scala 程式碼。

**錯誤**
+ `InvalidInputException`
+ `InternalServiceException`
+ `OperationTimeoutException`

## GetDataflowGraph 動作 (Python: get\$1dataflow\$1graph)
<a name="aws-glue-api-etl-script-generation-GetDataflowGraph"></a>

將 Python 指令碼轉換為有向無環圖 (DAG)。

**請求**
+ `PythonScript` – UTF-8 字串。

  要轉換的 Python 指令碼。

**回應**
+ `DagNodes` – 一個 [CodeGenNode](#aws-glue-api-etl-script-generation-CodeGenNode) 物件陣列。

  在所產生 DAG 中的節點的清單。
+ `DagEdges` – 一個 [CodeGenEdge](#aws-glue-api-etl-script-generation-CodeGenEdge) 物件陣列。

  在所產生 DAG 中的邊緣的清單。

**錯誤**
+ `InvalidInputException`
+ `InternalServiceException`
+ `OperationTimeoutException`

## GetMapping 動作 (Python: get\$1mapping)
<a name="aws-glue-api-etl-script-generation-GetMapping"></a>

建立映射。

**請求**
+ `Source` – *必要：*[CatalogEntry](#aws-glue-api-etl-script-generation-CatalogEntry) 物件。

  指定來源資料表。
+ `Sinks` – 一個 [CatalogEntry](#aws-glue-api-etl-script-generation-CatalogEntry) 物件陣列。

  目標資料表的清單。
+ `Location` – [Location](#aws-glue-api-etl-script-generation-Location) 物件。

  映射用的參數。

**回應**
+ `Mapping` – *必要：*一個 [MappingEntry](#aws-glue-api-etl-script-generation-MappingEntry) 物件。

  指定目標的映射的清單。

**錯誤**
+ `InvalidInputException`
+ `InternalServiceException`
+ `OperationTimeoutException`
+ `EntityNotFoundException`

## GetPlan 動作 (Python: get\$1plan)
<a name="aws-glue-api-etl-script-generation-GetPlan"></a>

取得程式碼以進行指定的映射。

**請求**
+ `Mapping` – *必要：*一個 [MappingEntry](#aws-glue-api-etl-script-generation-MappingEntry) 物件。

  來源資料表與目標資料表的映射的清單。
+ `Source` – *必要：*[CatalogEntry](#aws-glue-api-etl-script-generation-CatalogEntry) 物件。

  來源資料表。
+ `Sinks` – 一個 [CatalogEntry](#aws-glue-api-etl-script-generation-CatalogEntry) 物件陣列。

  目標資料表。
+ `Location` – [Location](#aws-glue-api-etl-script-generation-Location) 物件。

  映射用的參數。
+ `Language` – UTF-8 字串 (有效值：`PYTHON` \$1 `SCALA`)。

  用來進行映射的程式碼的程式設計語言。
+ `AdditionalPlanOptionsMap` – 金鑰值對的映射陣列。

  每個金鑰都是 UTF-8 字串。

  每個值都是 UTF-8 字串。

  用於保存額外選用鍵-值參數的映射。

  目前支援下列鍵值對：
  + `inferSchema`  —  指定任務所產生的預設指令碼是`inferSchema`設定為 true 還是 false AWS Glue 。例如，若要將 `inferSchema` 設定為 true，請傳遞鍵值對：

    `--additional-plan-options-map '{"inferSchema":"true"}'`

**回應**
+ `PythonScript` – UTF-8 字串。

  用來進行映射的 Python 指令碼。
+ `ScalaCode` – UTF-8 字串。

  用來進行映射的 Scala 程式碼。

**錯誤**
+ `InvalidInputException`
+ `InternalServiceException`
+ `OperationTimeoutException`