Skip to content

Commit

Permalink
RD-14975: LIMIT shouldn't be pushed when some predicates aren't pushed (
Browse files Browse the repository at this point in the history
  • Loading branch information
bgaidioz authored Oct 9, 2024
1 parent 4920edd commit 573aabc
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/main/scala/com/rawlabs/das/salesforce/DASSalesforceTable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ abstract class DASSalesforceTable(
"SELECT " + salesforceColumns.mkString(", ") + " FROM " + salesforceObjectName
}
}
val simpleQuals = quals.filter(_.hasSimpleQual) // Only simple quals are supported
if (simpleQuals.nonEmpty) {
soql += " WHERE " + quals
val (supportedQuals, unsupportedQuals) = quals.partition(_.hasSimpleQual) // Only simple quals are supported
if (supportedQuals.nonEmpty) {
soql += " WHERE " + supportedQuals
.map { q =>
assert(q.hasSimpleQual, "Only simple quals are supported")
val op = q.getSimpleQual.getOperator
Expand All @@ -201,8 +201,13 @@ abstract class DASSalesforceTable(
}
.mkString(", ")
}
if (maybeLimit.nonEmpty) {
soql += " LIMIT " + maybeLimit.get
if (unsupportedQuals.isEmpty) {
// LIMIT can be pushed _only_ when there are no unsupported quals.
if (maybeLimit.nonEmpty) {
soql += " LIMIT " + maybeLimit.get
}
} else {
maybeLimit.foreach(_ => logger.warn("Unsupported quals found, ignoring LIMIT"))
}
logger.debug(s"Executing SOQL query: $soql")
var query = connector.forceApi.query(soql)
Expand Down

0 comments on commit 573aabc

Please sign in to comment.