[ 
https://issues.apache.org/jira/browse/GOBBLIN-865?focusedWorklogId=353637&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-353637
 ]

ASF GitHub Bot logged work on GOBBLIN-865:
------------------------------------------

                Author: ASF GitHub Bot
            Created on: 04/Dec/19 18:35
            Start Date: 04/Dec/19 18:35
    Worklog Time Spent: 10m 
      Work Description: htran1 commented on pull request #2722: GOBBLIN-865: 
Add feature that enables PK-chunking in partition
URL: https://github.com/apache/incubator-gobblin/pull/2722#discussion_r353912680
 
 

 ##########
 File path: 
gobblin-salesforce/src/main/java/org/apache/gobblin/salesforce/SalesforceExtractor.java
 ##########
 @@ -588,16 +566,41 @@ public String getTimestampPredicateCondition(String 
column, long value, String v
     return dataTypeMap;
   }
 
+
+  private Boolean isPkChunkingFetchDone = false;
+
+  private Iterator<JsonElement> getRecordSetPkchunking(WorkUnit workUnit) 
throws RuntimeException {
+    if (isPkChunkingFetchDone) {
+      return null; // must return null to represent no more data.
+    }
+    isPkChunkingFetchDone = true; // set to true, never come here twice.
+    try {
+      if (!bulkApiLogin()) {
+        throw new IllegalArgumentException("Invalid Login");
+      }
+    } catch (Exception e) {
+      throw new RuntimeException(e);
+    }
+    String jobId = workUnit.getProp(PK_CHUNKING_JOB_ID);
+    String batchIdResultIdString = 
workUnit.getProp(PK_CHUNKING_BATCH_RESULT_IDS);
+    return new ResultIterator(bulkConnection, jobId, batchIdResultIdString, 
fetchRetryLimit);
+  }
+
   @Override
   public Iterator<JsonElement> getRecordSetFromSourceApi(String schema, String 
entity, WorkUnit workUnit,
       List<Predicate> predicateList) throws IOException {
     log.debug("Getting salesforce data using bulk api");
-    RecordSet<JsonElement> rs = null;
 
+    // new version of extractor: bulk api with pk-chunking in pre-partitioning 
of SalesforceSource
+    if (workUnit.contains(PK_CHUNKING_JOB_ID)) {
+      log.info("----pk-chunking get record set----" + 
workUnit.getProp(PK_CHUNKING_JOB_ID));
+      return getRecordSetPkchunking(workUnit);
 
 Review comment:
   What would it take to unify the code? I see that the new `ResultIterator` 
class is not used for the non-pk chunking bulk fetch.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 353637)
    Time Spent: 10h 10m  (was: 10h)

> Add feature that enables PK-chunking in partition 
> --------------------------------------------------
>
>                 Key: GOBBLIN-865
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-865
>             Project: Apache Gobblin
>          Issue Type: Task
>            Reporter: Alex Li
>            Priority: Major
>              Labels: salesforce
>          Time Spent: 10h 10m
>  Remaining Estimate: 0h
>
> In SFDC(salesforce) connector, we have partitioning mechanisms to split a 
> giant query to multiple sub queries. There are 3 mechanisms:
>  * simple partition (equally split by time)
>  * dynamic pre-partition (generate histogram and split by row numbers)
>  * user specified partition (set up time range in job file)
> However there are tables like Task and Contract are failing time to time to 
> fetch full data.
> We may want to utilize PK-chunking to partition the query.
>  
> The pk-chunking doc from SFDC - 
> [https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/async_api_headers_enable_pk_chunking.htm]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to