Use case: SOQL queries for the Salesforce source

This page shows how to use SOQL relationship queries when you use the Salesforce source in Cloud Data Fusion.

The Salesforce source lets you seamlessly connect to Salesforce and load large amounts of data into Google Cloud. To simplify loading the data, you can use SOQL relationship queries to retrieve records and reduce the number of API calls in Salesforce.

Before you begin

  1. Deploy and configure the properties for the Salesforce source in Cloud Data Fusion. For more information, see Salesforce batch source.

  2. On the Salesforce node in your pipeline, click Properties. This opens the Salesforce plugin properties page.

The following sections describe how to configure the SOQL query field on the Properties page.

Scenario 1: Relationship query with polymorphic key and limits

The following relationship query example has a polymorphic key and a limit:

SELECTId,Owner.NameFROMTaskWHEREOwner.FirstNamelike'B%'Limit100

This query fetches data from a Task SObject related to Owner. It reads data from the selected fields in the Task SObject. It has a WHERE clause and a placeholder, which you can assign a suitable value.

This query lets you access the required fields using a placeholder variable. It limits the quantity of records fetched to 100.

Scenario 2: Relationship query with child-to-parent with custom objects

The following query fetches data from a custom object with child-to-parent relationship:

SELECTEmail,newsales__c,Account__r.OwnerIdFROMleadWHEREAccount__r.LeadSourceLIKE'C%

This query uses a SELECT clause to fetch data from the Lead SObject in Salesforce with the reference field, Account__r.OwnerId.

The query returns data from the selected fields in the Lead SObject and the relational fields from the lookup linked to the Account parent object. You can query multiple data fields from a cluster of relational SObjects.

Scenario 3: Relationship query with WHERE and OFFSET clauses

The following query fetches data from multiple SObjects: Account and Contacts, related to a specific Industry type and OFFSET clause:

SELECTName,(SELECTLastNameFROMContactsWHERECreatedBy.Alias='x')FROMAccountWHEREIndustry='media'
offset4

The OFFSET clause lets you to return results on multiple pages, which is an efficient way to handle large results sets.

What's next

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年10月16日 UTC.