批量 insert/upsert 的 simple-salesforce 结果

simple-salesforce result from bulk insert/upsert

我正在尝试将输出结果与输入行匹配,从我的测试来看,批量操作看起来 return 结果的顺序相同,但可以保证吗?

input = [{json1},{json2},{json3},...]

sf = Salesforce(instance='<some instance>', session_id='<some session id>')

output = sf.bulk.some_table.upsert(json_data, 'key column', batch_size=1000, use_serial=False)


df1 = pd.json_normalize(input)
df2 = pd.json_normalize(output)

summary_df = pd.merge(input, output, left_index=True, right_index=True)

print(summary_df)

批量 API 的文档似乎表明您可以依赖结果的顺序,而 Simple Salesforce 不应以不同的顺序返回(可能会改变,但我没有看到为什么图书馆会)。

Salesforce 文档:https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/asynch_api_batches_failed_records.htm

Track the record number for each result record. Each result record corresponds to a record in the batch. The results are returned in the same order as the records in the batch request. It's important to track the record number in the results so that you can identify the associated failed record in the batch request.