

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

# 從 Asana 實體中讀取
<a name="asana-reading-from-entities"></a>

 **先決條件** 

您想要從中讀取的 Asana 物件。請參閱以下支援的實體表格，以檢查可用實體。

 **來源的支援實體** 


| 實體 | 可以篩選 | 支援限制 | 支援排序依據 | 支援選取 \$1 | 支援分區 | 
| --- | --- | --- | --- | --- | --- | 
|  工作區  | 否 | 是 | 否 | 是 | 否 | 
| Tag | 否 | 是 | 否 | 是 | 否 | 
| 使用者 | 否 | 是 | 否 | 是 | 否 | 
|  產品組合  | 否 | 是 | 否 | 是 | 否 | 
| 團隊 | 否 | 是 | 否 | 是 | 否 | 
| 專案 | 是 | 是 | 否 | 是 | 否 | 
| 區段 | 否 | 是 | 否 | 是 | 否 | 
| 任務  | 是 | 否 | 否 | 是 | 是 | 
| 目標 | 是 | 是 | 否 | 是 | 否 | 
|  AuditLogEvent  | 是 | 是 | 否 | 是 | 否 | 
|  狀態更新  | 是 | 是 | 否 | 是 | 否 | 
|  自訂欄位  | 否 | 是 | 否 | 是 | 否 | 
|  專案簡介  | 是 | 否 | 否 | 是 | 是 | 

 **範例** 

```
read_read = glueContext.create_dynamic_frame.from_options(
    connection_type="Asana",
    connection_options={
        "connectionName": "connectionName",
        "ENTITY_NAME": "task/workspace:xxxx",
        "API_VERSION": "1.0",
        "PARTITION_FIELD": "created_at",
        "LOWER_BOUND": "2024-02-05T14:09:30.115Z",
        "UPPER_BOUND": "2024-06-07T13:30:00.134Z",
        "NUM_PARTITIONS": "3"
    }
```

 **Asana 實體和欄位詳細資訊** 
+ [工作區](https://developers.asana.com/docs/workspaces)
+ [標籤](https://developers.asana.com/docs/tags)
+ [使用者](https://developers.asana.com/docs/users)
+ [產品組合](https://developers.asana.com/docs/portfolios)
+ [團隊](https://developers.asana.com/docs/teams)
+ [專案](https://developers.asana.com/docs/get-all-projects-in-a-workspace)
+ [區段](https://developers.asana.com/docs/get-sections-in-a-project)
+ [任務](https://developers.asana.com/docs/search-tasks-in-a-workspace) 
+ [目標](https://developers.asana.com/docs/get-goals)
+ [AuditLogEvent](https://developers.asana.com/docs/audit-log-api)
+ [狀態更新](https://developers.asana.com/reference/status-updates)
+ [自訂欄位](https://developers.asana.com/reference/custom-fields)
+ [專案簡介](https://developers.asana.com/reference/project-briefs)

 **分區查詢** 

如果想要在 Spark 中使用並行，可以提供其他 Spark 選項 `PARTITION_FIELD`、`LOWER_BOUND`、`UPPER_BOUND`、`NUM_PARTITIONS`。使用這些參數，原始查詢會分區為可由 Spark 任務並行執行的子查詢的 `NUM_PARTITIONS` 數目。
+ `PARTITION_FIELD`：用來分區查詢的欄位名稱。
+ `LOWER_BOUND`：所選分區欄位的包含下限值。

  對於日期，我們接受 Spark SQL 查詢中使用的 Spark 日期格式。有效值的範例：`2024-06-07T13:30:00.134Z`。
+ `UPPER_BOUND`：所選分區欄位的唯一上限值。
+ `NUM_PARTITIONS`：分區數目。

 實體分區欄位支援詳細資訊如下表所示。


| 實體名稱 | 分區欄位 | 資料類型 | 
| --- | --- | --- | 
| 任務 |  created\$1at  | DateTime | 
| 任務 |  modified\$1at  | DateTime | 

 **範例** 

```
read_read = glueContext.create_dynamic_frame.from_options(
    connection_type="Asana",
    connection_options={
        "connectionName": "connectionName",
        "ENTITY_NAME": "task/workspace:xxxx",
        "API_VERSION": "1.0",
        "PARTITION_FIELD": "created_at",
        "LOWER_BOUND": "2024-02-05T14:09:30.115Z",
        "UPPER_BOUND": "2024-06-07T13:30:00.134Z",
        "NUM_PARTITIONS": "3"
    }
```