This function is a convenience wrapper for submitting and retrieving query API jobs from the Bulk 1.0 and Bulk 2.0 APIs.
Usage
sf_run_bulk_query(
soql,
object_name = NULL,
queryall = FALSE,
guess_types = TRUE,
bind_using_character_cols = deprecated(),
interval_seconds = 3,
max_attempts = 200,
control = list(...),
...,
api_type = c("Bulk 2.0", "Bulk 1.0"),
verbose = FALSE
)
sf_query_bulk(
soql,
object_name = NULL,
queryall = FALSE,
guess_types = TRUE,
bind_using_character_cols = deprecated(),
interval_seconds = 3,
max_attempts = 200,
control = list(...),
...,
api_type = c("Bulk 2.0", "Bulk 1.0"),
verbose = FALSE
)
Arguments
- soql
character
; a string defining a SOQL query (e.g. "SELECT Id, Name FROM Account").- object_name
character
; the name of the Salesforce object that the function is operating against (e.g. "Account", "Contact", "CustomObject__c").- queryall
logical
; indicating if the query recordset should include records that have been deleted because of a merge or delete. Setting this argument toTRUE
will also return information about archived Task and Event records. It is available in API versions 29.0 and later.- guess_types
logical
; indicating whether or not to usecol_guess()
to try and cast the data returned in the recordset. IfTRUE
thencol_guess()
is used along withanytime()
andanydate()
. IfFALSE
then all fields will be returned as character. SpecifyingFALSE
helpful when guessing the column data type will result in NA values and you would like to return the results as strings and then cast in your script according to your unique specifications.- bind_using_character_cols
logical
; an indicator of whether to cast the data to all character columns to ensure thatbind_rows
does not fail because two paginated recordsets have differing datatypes for the same column. Set this toTRUE
rarely, typically only when having this set toFALSE
returns an error or you want all columns in the data to be character.- interval_seconds
integer
; defines the seconds between attempts to check for job completion.- max_attempts
integer
; defines then max number attempts to check for job completion before stopping.- control
list
; a list of parameters for controlling the behavior of the API call being used. For more information of what parameters are available look at the documentation forsf_control
.- ...
other arguments passed on to
sf_control
orsf_create_job_bulk
to specify thecontent_type
,concurrency_mode
, and/orcolumn_delimiter
.- api_type
character
; one of"REST"
,"SOAP"
,"Bulk 1.0"
, or"Bulk 2.0"
indicating which API to use when making the request.- verbose
logical
; an indicator of whether to print additional detail for each API call, which is useful for debugging. More specifically, when set toTRUE
the URL, header, and body will be printed for each request, along with additional diagnostic information where available.
Examples
if (FALSE) { # \dontrun{
# select all Ids from Account object (up to 1000)
ids <- sf_query_bulk(soql = 'SELECT Id FROM Account LIMIT 1000')
# note that, by default, bulk queries are executed using the Bulk 2.0 API, which
# does not required the object name, but the Bulk 1.0 API can be still be invoked
# for queries by setting api_type="Bulk 1.0".
# alternatively you can specify as:
ids <- sf_query(soql = 'SELECT Id FROM Account LIMIT 1000',
api_type = "Bulk 2.0")
ids <- sf_query(soql = 'SELECT Id FROM Account LIMIT 1000',
object_name = 'Account',
api_type = "Bulk 1.0")
} # }