gengliangwang commented on code in PR #59943:
URL: https://github.com/apache/spark/pull/59943#discussion_r4470327960
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala:
##########
@@ -1101,6 +1103,41 @@ private[sql] object DataSourceV2Strategy extends Logging
{
withFilter
}
}
+
+ /**
+ * Returns the output of the scan node of a streaming relation: the columns
that its scan reads.
+ * The projections and the filters over the relation, which the scan node is
planned with, must
+ * still apply the filters that the scan got, and read no column of the
relation that the scan
+ * does not read, if it was built to read fewer columns than the relation
outputs (see
+ * `StreamingV2ScanPushDown`).
+ */
+ private def streamingScanOutput(
+ relation: StreamingDataSourceV2ScanRelation,
+ project: Seq[NamedExpression],
+ filters: Seq[Expression]): Seq[AttributeReference] = {
+ val missingFilters =
relation.pushedFilters.filterNot(ExpressionSet(filters).contains)
Review Comment:
**[P0] Allow stronger batch predicates to satisfy pushed filters**
Startup optimization excludes InferFiltersFromConstraints, so it records and
pushes `id > 10`. Normal IncrementalExecution optimization still runs
inference: joining against `oid = 20` on `id = oid` introduces `id = 20`, then
CombineFilters, ConstantPropagation, and ConstantFolding eliminate the
redundant `id > 10`. ConstantPropagation changes only Filter conditions,
leaving relation.pushedFilters unchanged. This exact ExpressionSet membership
check therefore throws INTERNAL_ERROR even though the surviving predicate
guarantees the pushed filter. Validation must account for these legitimate
optimizer rewrites.
**Failure scenario:** Join two V2 streams supporting filter pushdown:
left.where("id > 10") and right.where("oid = 20"), on id = oid. When both
supply a new row with key 20, the micro-batch aborts during planning instead of
returning the matching row.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]