When objects have lots of (e.g. 800) attributes, the SOQL for these objects can hit URL length limits. This page documents an approach to handle this limit, by splitting attributes into multiple batches, without the knowledge of users
Use case(s)
I have a Salesforce object with over 800 attributes. When I send a SOQL query for this object with all attributes in it to the Salesforce APIs, I hit URL length limits. To get around this situation, I have wrapped my code for querying Salesforce into a script that retrieves data for an object in batches, and then joins the batches together. This process is extremely manual, custom, one-off and error prone, and therefore extremely hard to manage and maintain. I would like the ability to for the Salesforce plugins in CDAP to batch the attributes before submitting the SOQL to Salesforce, and handle this grunt work automatically.
User Storie(s)
Plugin Type
This is not a new plugin, but enhancements to existing plugins.
Configurables
This section defines properties that are configurable for this plugin.
User Facing Name
Type
Description
Constraints
Design / Implementation Tips
Tip #1
Tip #2
Design
Approach(s)
In CDAP Salesforce Source Batch plugin user specifies sObject (ex: Opportunity). Using Salesforce describe functionality, we receive all fields and generate SOQL
length of the generated SOQL does not exceed 20,000 [1] characters then we will use standard approach based on Bulk API. Details: Salesforce Batch Source.
length of the generated SOQL exceeds 20,000 characters [1] then we will use 2 APIs (SOAP and Bulk) to solve length problem:
Fetch all IDs [2] for provided sObject using Bulk API (generate: select id from sObject).
Create chunks by 2,000 ids and query all fields using SOAP API (2,000 is a limit of records exposed by SOAP API [3]). Details: Detailed wide object flow
Make retrieve() request for each chunk.
Save to sink or expose to further transformations in CDAP.
In CDAP Salesforce Source Batch plugin user specifies SOQL (ex: select id, type … from Opportunity where type = ‘ABC’)
length of the SOQL does not exceed 20,000 characters then we will use standard approach based on Bulk API. Details: Salesforce Batch Source.
length of the SOQL exceeds 20,000 characters then we will use 2 APIs (SOAP and Bulk) to solve length problem:
Parse given SOQL query and extract all fields in SELECT clause and replace them with id field (ex: select id, type … from Opportunity where type = ‘ABC' -> select id from Opportunity where type = ‘ABC').
Fetch all IDs [2] produced by generated SOQL query (ex: select id from Opportunity where type = ‘ABC’).
Create chunks by 2,000 ids and query fields extracted from initial SOQL query using SOAP APl. Details: Detailed wide object flow
Make retrieve() request for each chunk.
Save to sink or expose to further transformations in CDAP.