Skip to content
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

pk_chunking is not working #74

Open
hrishy opened this issue Aug 23, 2019 · 6 comments
Open

pk_chunking is not working #74

hrishy opened this issue Aug 23, 2019 · 6 comments

Comments

@hrishy
Copy link

hrishy commented Aug 23, 2019

Hi

I tried the example in the documentation

job = bulk.create_query_job("Contact", contentType='CSV', pk_chunking=True)
batch = bulk.query(job, "select Id,LastName from Contact")
bulk.close_job(job)
while not bulk.is_batch_done(batch):
    sleep(10)

for result in bulk.get_all_results_for_query_batch(batch):
    reader = unicodecsv.DictReader(result, encoding='utf-8')
    for row in reader:
        print(row) # dictionary rows

BulkBatchFailed Traceback (most recent call last)
in
8 batch = bulk.query(job, "select Id,LastName from Contact")
9 bulk.close_job(job)
---> 10 while not bulk.is_batch_done(batch):
11 sleep(10)
12

c:\python37\lib\site-packages\salesforce_bulk\salesforce_bulk.py in is_batch_done(self, batch_id, job_id)
426 if batch_state in bulk_states.ERROR_STATES:
427 status = self.batch_status(batch_id, job_id)
--> 428 raise BulkBatchFailed(job_id, batch_id, status.get('stateMessage'), batch_state)
429 return batch_state == bulk_states.COMPLETED
430

BulkBatchFailed: Batch 123456789 of job None failed: None

Without pk_chunking it works though.
Any ideas what am i doing wrong here any help would be appreciated

@kunal4422
Copy link

Hi @hrishy did u find solution to this?

@hrishy
Copy link
Author

hrishy commented Dec 23, 2019 via email

@kunal4422
Copy link

@hrishy didnt got you. I am having same code as you and also same error. Instead of pk_chunking=True i tried to give pk_chunking=100000; as given in example. What exactly should i do to rectify this error?
Somewhere we have to use get_batch_items() for iterating between batches. How did u solve it?

@hrishy
Copy link
Author

hrishy commented Dec 23, 2019 via email

@roshin8
Copy link

roshin8 commented Feb 27, 2020

I added an example to the README which shows how to use PK Chunking. Let me know if that helps you.
https://github.com/heroku/salesforce-bulk/pull/77/files

@fungss
Copy link

fungss commented Jun 4, 2023

I added an example to the README which shows how to use PK Chunking. Let me know if that helps you. https://github.com/heroku/salesforce-bulk/pull/77/files

This should be merged into README. It works really well. Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants