In ADF, when you work with SOQL queries, it's important to know that SOQL does not natively support dynamic variables the way some other query languages do. ADF expressions (like @{}
) are not part of the SOQL syntax and therefore cannot be directly evaluated inside the SOQL query string. This is why your query isn't working as expected.
A workaround is to construct the entire SOQL query string dynamically in ADF, and then pass it as a single query string rather than embedding expressions directly in SOQL.
- Create the query string dynamically in ADF using pipeline expressions before executing the SOQL. This can be done by building the query in an ADF pipeline variable using
concat()
to dynamically insert values (e.g., dates, numbers). - Assign the dynamically constructed SOQL query to a parameter or variable and use it in your Salesforce connector's dataset or activity.
{
"name": "QueryString",
"value": "@{concat('select * from ', json(item().SourceObjectSettings).objectApiName, ' where ', json(item().DataLoadingBehaviorSettings).watermarkColumnName, ' > ', if(contains(json(item().DataLoadingBehaviorSettings).watermarkColumnType, 'Int'), json(item().DataLoadingBehaviorSettings).watermarkColumnStartValue, concat('{ts''', formatDateTime(json(item().DataLoadingBehaviorSettings).watermarkColumnStartValue, 'yyyy-MM-dd HH:mm:ss'), '''}')), ' and ', json(item().DataLoadingBehaviorSettings).watermarkColumnName, ' <= ', if(contains(json(item().DataLoadingBehaviorSettings).watermarkColumnType, 'Int'), activity('GetMaxWatermarkValue').output.firstRow.CurrentMaxWaterMarkColumnValue, concat('{ts''', formatDateTime(activity('GetMaxWatermarkValue').output.firstRow.CurrentMaxWaterMarkColumnValue, 'yyyy-MM-dd HH:mm:ss'), '''}')))}"
}
In this example:
- The entire SOQL query is built as a string using ADF expression language.
- The result is stored in a variable (or passed as a parameter) and then used in your activity to execute the SOQL query.
This way, you're dynamically constructing the SOQL query in ADF and sending it as a whole, avoiding the issue of embedding ADF expressions directly inside SOQL.
Let me know if you need further adjustments!