

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

# AWS Glue for Spark 中的輸入與輸出的資料格式選項
<a name="aws-glue-programming-etl-format"></a>

這些頁面提供有關 AWS Glue for Spark 支援的資料格式之功能支援和組態參數的資訊。有關此信息的用法和適用性的說明，請參閱以下內容。

## Glue AWS 中跨資料格式的功能支援
<a name="aws-glue-programming-etl-format-features"></a>

 每個資料格式可能支援不同的 AWS Glue 功能。根據您的格式類型，可能會或可能不支持以下常見功能。請參閱資料格式的文件，瞭解如何運用我們的功能來滿足您的需求。


|  |  | 
| --- |--- |
| 讀取 | AWS Glue 無需連接器等其他資源即可識別和解譯此資料格式。 | 
| 寫入 | AWS Glue 可以以此格式寫入資料，無需其他資源。您可以在工作中包含協力廠商程式庫，並使用標準 Apache Spark 函數來寫入資料，就像在其他 Spark 環境中一樣。如需這些程式庫的詳細資訊，請參閱 [搭配 Glue 使用 Python AWS 程式庫](aws-glue-programming-python-libraries.md)。 | 
| 串流讀取 | AWS Glue 可以從 Apache Kafka、Amazon Managed Streaming for Apache Kafka 或 Amazon Kinesis 訊息串流辨識和解譯此資料格式。我們希望流以一致的格式呈現數據，因此它們被讀為DataFrames。 | 
| 對小型檔案進行分組 | AWS Glue 可以將檔案分組，以在執行 Glue AWS 轉換時傳送至每個節點的批次工作。如此可大幅改善涉及大量小型檔案的工作負載的效能。如需詳細資訊，請參閱[讀取在大型群組中的輸入檔案](grouping-input-files.md)。 | 
| 任務書籤 | AWS Glue 可以使用任務書籤追蹤在任務執行期間對相同資料集執行相同工作的轉換進度。這可以提高工作負載的效能，涉及自上次作業執行以來只需在新資料上完成工作的資料集。如需詳細資訊，請參閱[使用任務書籤追蹤處理的資料](monitor-continuations.md)。 | 

## 用來與 Glue AWS 中的資料格式互動的參數
<a name="aws-glue-programming-etl-format-parameters"></a>

某些 AWS Glue 連線類型支援多種`format`類型，要求您在使用 等方法時，使用 `format_options` 物件指定資料格式的相關資訊`GlueContext.write_dynamic_frame.from_options`。
+ `s3` – 如需詳細資訊，請參閱 Glue 中 ETL AWS 的連線類型和選項：[S3 連線參數](aws-glue-programming-etl-connect-s3-home.md#aws-glue-programming-etl-connect-s3)。您也可以檢視促進此連線類型之方法的文件：[create\_dynamic\_frame\_from\_options](aws-glue-api-crawler-pyspark-extensions-glue-context.md#aws-glue-api-crawler-pyspark-extensions-glue-context-create_dynamic_frame_from_options)和[write\_dynamic\_frame\_from\_options](aws-glue-api-crawler-pyspark-extensions-glue-context.md#aws-glue-api-crawler-pyspark-extensions-glue-context-write_dynamic_frame_from_options)在 Python 和相應的斯卡拉方法[def getSourceWithFormat](glue-etl-scala-apis-glue-gluecontext.md#glue-etl-scala-apis-glue-gluecontext-defs-getSourceWithFormat)和[def getSinkWithFormat](glue-etl-scala-apis-glue-gluecontext.md#glue-etl-scala-apis-glue-gluecontext-defs-getSinkWithFormat)。

  
+ `kinesis` – 如需詳細資訊，請參閱 Glue 中 ETL AWS 的連線類型和選項：[Kinesis 連線參數](aws-glue-programming-etl-connect-kinesis-home.md#aws-glue-programming-etl-connect-kinesis)。您也可以檢視促進此連線類型的方法文件：[create\_data\_frame\_from\_options](aws-glue-api-crawler-pyspark-extensions-glue-context.md#aws-glue-api-crawler-pyspark-extensions-glue-context-create-dataframe-from-options)和相應的斯卡拉方法[def createDataFrameFromOptions](glue-etl-scala-apis-glue-gluecontext.md#glue-etl-scala-apis-glue-gluecontext-defs-createDataFrameFromOptions)。
+ `kafka` – 如需詳細資訊，請參閱 Glue 中 ETL AWS 的連線類型和選項：[Kafka 連線參數](aws-glue-programming-etl-connect-kafka-home.md#aws-glue-programming-etl-connect-kafka)。您也可以檢視促進此連線類型的方法文件：[create\_data\_frame\_from\_options](aws-glue-api-crawler-pyspark-extensions-glue-context.md#aws-glue-api-crawler-pyspark-extensions-glue-context-create-dataframe-from-options)和相應的斯卡拉方法[def createDataFrameFromOptions](glue-etl-scala-apis-glue-gluecontext.md#glue-etl-scala-apis-glue-gluecontext-defs-createDataFrameFromOptions)。

某些連線類型不需要`format_options`。例如，在正常使用中，與關聯式資料庫的 JDBC 連線將以一致的表格式擷取資料。因此，從 JDBC 連接讀取不需要`format_options`。

在膠水中讀取和寫入數據的某些方法不需要`format_options`。例如，使用 `GlueContext.create_dynamic_frame.from_catalog`搭配 AWS Glue 爬蟲程式。爬蟲確定數據的形狀。使用爬蟲程式時，Glue AWS 分類器會檢查您的資料，以做出如何代表資料格式的明智決策。然後，它會將資料的表示法存放在 AWS Glue Data Catalog 中，可用於 Glue ETL AWS 指令碼，以 `GlueContext.create_dynamic_frame.from_catalog`方法擷取您的資料。檢索器無需手動指定有關數據格式的信息。

對於存取 AWS Lake Formation 受管資料表的任務， AWS Glue支援讀取和寫入 Lake Formation 受管資料表支援的所有格式。如需受 AWS Lake Formation 管資料表支援的最新格式清單，請參閱《 *AWS Lake Formation 開發人員指南*》中的[受管資料表的注意事項和限制](https://docs.aws.amazon.com/lake-formation/latest/dg/governed-table-restrictions.html)。

**注意**  
對於寫入 Apache Parquet，AWS Glue ETL 只支援透過指定為動態框架優化的自訂 Parquet 寫入器類型的選項寫入受管控資料表。使用 `parquet` 格式寫入受管控資料表時，您應該在表參數中新增值為 `true` 的金鑰 `useGlueParquetWriter`。

**Topics**
+ [Glue AWS 中跨資料格式的功能支援](#aws-glue-programming-etl-format-features)
+ [用來與 Glue AWS 中的資料格式互動的參數](#aws-glue-programming-etl-format-parameters)
+ [在 Glue AWS 中使用 CSV 格式](aws-glue-programming-etl-format-csv-home.md)
+ [在 Glue AWS 中使用 Parquet 格式](aws-glue-programming-etl-format-parquet-home.md)
+ [在 Glue AWS 中使用 XML 格式](aws-glue-programming-etl-format-xml-home.md)
+ [在 Glue AWS 中使用 Avro 格式](aws-glue-programming-etl-format-avro-home.md)
+ [在 Glue AWS 中使用 grokLog 格式](aws-glue-programming-etl-format-grokLog-home.md)
+ [在 Glue AWS 中使用 Ion 格式](aws-glue-programming-etl-format-ion-home.md)
+ [在 Glue AWS 中使用 JSON 格式](aws-glue-programming-etl-format-json-home.md)
+ [在 Glue AWS 中使用 ORC 格式](aws-glue-programming-etl-format-orc-home.md)
+ [搭配 AWS Glue ETL 任務使用資料湖架構](aws-glue-programming-etl-datalake-native-frameworks.md)
+ [共用的組態參考](#aws-glue-programming-etl-format-shared-reference)

## 共用的組態參考
<a name="aws-glue-programming-etl-format-shared-reference"></a>

 您可以將以下 `format_options` 值與任何格式類型搭配使用。
+ `attachFilename`：以適當格式作為資料欄名稱使用的字串。如果您提供此選項，記錄的來源檔案名稱會附加到記錄中。參數值將用作資料欄名稱。
+ `attachTimestamp`：以適當格式作為資料欄名稱使用的字串。如果您提供此選項，記錄的來源檔案修改時間會附加到記錄中。參數值將用作資料欄名稱。