vranes commented on code in PR #57159:
URL: https://github.com/apache/spark/pull/57159#discussion_r3560403644
##########
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:
Added a range-column case (ts_start pushes below BinBy) alongside the
existing ones, so all three cases are covered directly. Thanks!
--
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]