-
-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable PKChunking for sf_query_bulk #46
Comments
First, the issue may not be related to PKChunking. If you are seeing Next, there are two ways to pass control arguments:
This appears to match the first style you gave. However, I have not tested each header parameter individually so it is possible that it is being passed, just not be in the way Salesforce wants it (e.g.
That example above should show something like Lastly, the second style you tried out to pass the argument is not the correct syntax because it doesn't tell the control argument that the list you are passing is for setting the PKChunkingHeader header, so I would expect that to be either ignored or fail. |
Fix so that a character version of the logical TRUE/FALSE will be properly formatted. This arose from having to handle TRUE/FALSE as valid values but also the elements in the list themselves that need to be formatted and imply TRUE. Fixes #46
Update the process by which the Bulk 1.0 query functions pull down results because it is different when the data is PKChunked #46
@JordanLewis312 Apologize for the extremely long delay, but finally got to the heart of the issue. It had two distinct parts:
This fix is already on GitHub and will be included in the new release of the package (v0.2.0) coming in the next few days. Upgrade your version of {salesforcer} package to (>= 0.1.4.9999), then you can invoke like this: library(salesforcer)
sf_auth()
contacts <- sf_query("SELECT Id, Name FROM Contact",
object_name = "Contact",
api_type = "Bulk 1.0",
PKChunkingHeader = list(`Sforce-Enable-PKChunking` = TRUE),
# alternatively you can turn on using specific chunking options like this ...
# PKChunkingHeader = list(`chunkSize` = 500),
interval_seconds = 10,
max_attempts = 200)
contacts
#> # A tibble: 383 x 2
#> Id Name
#> <chr> <chr>
#> 1 0033s000012NdFhAAK John Doe
#> 2 0033s000012NkzwAAC Jane Doe
#> 3 0033s000012NkzxAAC Jane Doe
#> 4 0033s000012NkzyAAC Jane Doe
#> 5 0033s000012NkzzAAC Jane Doe
#> # … with 378 more rows As a heads up, I'll also answer your post over on StackOverflow in case others stumble across it there (https://stackoverflow.com/questions/59863547/salesforcer-enable-pkchunking-for-salesforce-bulk-query-in-r) |
Fix so that a character version of the logical TRUE/FALSE will be properly formatted. This arose from having to handle TRUE/FALSE as valid values but also the elements in the list themselves that need to be formatted and imply TRUE. Fixes #46
Update the process by which the Bulk 1.0 query functions pull down results because it is different when the data is PKChunked #46
I am attempting to query a large table (~30M records) from Salesforce to R using the SalesforceR package, and hope to do so without splitting up into many queries.
The following query succeeds, if I limit the records:
OrderItemsSF <- sf_query_bulk("SELECT Id,Order,Product,Quantity FROM OrderItems LIMIT 1000000",object_name = "OrderItems", api_type = "Bulk 1.0", verbose = TRUE, max_attempts = 1000)
This query fails ("Error: column name 'result' must not be duplicated") whenever it takes longer than 10 minutes, which fits with SF's documentation saying bulk queries retry after 10 minutes. I believe the answer is to enable PKChunking to automatically separate my query into smaller batches, but I am having trouble finding a working syntax for this.
I have tried the following:
OrderItemsSF <- sf_query_bulk("SELECT Id,Order,Product,Quantity FROM OrderItems LIMIT 1000000",object_name = "OrderItems", api_type = "Bulk 1.0", verbose = TRUE, max_attempts = 1000, control = sf_control(PKChunkingHeader = list(
Sforce-Enable-PKChunking= TRUE)))
This results in the error "Error in catch_errors(httr_response) : ClientInputError: Sforce-Enable-PkChunking doesn't have a valid value. The same error results from using FALSE, and according to the documentation (see link 2 at bottom), FALSE is the default for this parameter, so that doesn't make sense!
Other syntax attempts, like the one below, succeed on queries under 10 minutes and fail over 10 minutes, suggesting that R is ignoring this text and not actually PKChunking:
OrderItemsSF <- sf_query_bulk("SELECT Id,Order,Product,Quantity FROM OrderItems LIMIT 1000000",object_name = "OrderItems", api_type = "Bulk 1.0", verbose = TRUE, max_attempts = 1000, control = list(
Sforce-Enable-PKChunking= TRUE))
I'm at a loss for what seems like a simple syntax issue, and can't find any specific examples online of PKChunking in a SalesforceR query, despite the documentation saying this can be done. I'd greatly appreciate some guidance here.
The text was updated successfully, but these errors were encountered: