我设置了一个 AppFlow,其中 Salesforce 作为源,S3 作为目标。我可以通过在流程定义中使用 Map_all
任务类型来移动
all列,并将源字段留空。
但是现在我只想将几列移至 S3,并重命名它们。我正在尝试做这样的事情:
"Tasks": [
{
"SourceFields": ["Website"],
"DestinationField": "Website",
"TaskType": "Map",
"TaskProperties": {},
},
{
"SourceFields": ["Account Name"],
"DestinationField": "AccountName",
"TaskType": "Map",
"TaskProperties": {},
},
{
"SourceFields": ["Account ID"],
"DestinationField": "AccountId",
"TaskType": "Map",
"TaskProperties": {},
}
],
但我收到错误
Create Flow request failed: [Task Validation Error: You must specify a projection task or a MAP_ALL task]
。
在将它们移动到 S3 之前,如何选择几列并重命名它们,而无需借助 Glue 等工具?
弄清楚了 - 首先添加一个投影任务来获取所需的字段,然后添加映射任务,每个字段一个被重命名
tasks=[
{
"connectorOperator": {"Salesforce": "PROJECTION"},
"sourceFields": ["Id", "Name"],
"taskProperties": {},
"taskType": "Filter",
},
{
"connectorOperator": {"Salesforce": "NO_OP"},
"destinationField": "Id",
"sourceFields": ["Id"],
"taskProperties": {
"DESTINATION_DATA_TYPE": "string",
"SOURCE_DATA_TYPE": "id",
},
"taskType": "Map",
},
{
"connectorOperator": {"Salesforce": "NO_OP"},
"destinationField": "Name",
"sourceFields": ["Name"],
"taskProperties": {
"DESTINATION_DATA_TYPE": "string",
"SOURCE_DATA_TYPE": "string",
},
"taskType": "Map",
},
],
以上是需要的代码。
我在 AWS 文档中没有找到此信息。
一个技巧是我在 AppFlow GUI 中使用步骤 3
Map fields directly
中的 Edit data fields
选项手动创建了一个流,并选择了所需的源字段。
成功创建流程后,我使用了 Appflow.Client.describe_flow(**kwargs), https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/appflow/client/describe_flow.html#describe-flow 返回了所有需要的东西。