cloud-fan commented on code in PR #57159:
URL: https://github.com/apache/spark/pull/57159#discussion_r3554100171
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/FilterPushdownSuite.scala:
##########
@@ -1644,4 +1644,41 @@ class FilterPushdownSuite extends PlanTest {
.analyze
comparePlans(optimizedQueryWithoutStep, correctAnswer)
}
+
+ test("push down deterministic predicate through BinBy") {
+ // Relation: ts_start, ts_end, value (DISTRIBUTE), label (pass-through).
+ val tsStart = AttributeReference("ts_start", TimestampType, nullable =
false)()
+ val tsEnd = AttributeReference("ts_end", TimestampType, nullable = false)()
+ val value = AttributeReference("value", DoubleType, nullable = false)()
+ val label = AttributeReference("label", StringType, nullable = true)()
+ val relation = LocalRelation(tsStart, tsEnd, value, label)
+
+ // Produced attributes: scaled DISTRIBUTE output and appended BIN BY
columns.
+ val scaledValue = AttributeReference("value", DoubleType, nullable =
true)()
+ val binStart = AttributeReference("bin_start", TimestampType, nullable =
true)()
+ val binEnd = AttributeReference("bin_end", TimestampType, nullable =
true)()
+ val binRatio = AttributeReference("bin_distribute_ratio", DoubleType,
nullable = true)()
+
+ def binByOver(child: LogicalPlan): BinBy = BinBy(
+ binWidthMicros = 300000000L,
+ rangeStart = tsStart,
+ rangeEnd = tsEnd,
+ originMicros = 0L,
+ distributeColumns = Seq(value),
+ scaledDistributeColumns = Seq(scaledValue),
+ appendedAttributes = Seq(binStart, binEnd, binRatio),
+ child = child,
+ timeZoneId = Some("UTC"))
+
+ // (a) A predicate on a forwarded pass-through column (label) must push
BELOW BinBy.
Review Comment:
This assertion pushes a predicate on a pass-through column (`label`) below
`BinBy`, but not on a range column (`ts_start`/`ts_end`). The range-column case
is the subtler safety claim the PR description leans on: range columns are
semantically consumed by the binning logic yet forwarded unchanged in `output`,
which is exactly why a predicate on them is safe to push. Both take the same
code path (both are child attributes), so this is coverage-completeness rather
than a correctness gap — but adding a range-column predicate to this "pushes
below" case would exercise that claim directly. Non-blocking.
--
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]