dongjoon-hyun commented on code in PR #60633:
URL: https://github.com/apache/spark/pull/60633#discussion_r4607747620
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala:
##########
@@ -769,7 +769,7 @@ case class Join(
None
}
- case LeftSemi | LeftAnti =>
+ case LeftSemi | LeftAnti | LeftSingle =>
Review Comment:
Thanks. Agreed, and it is the same behavior as for a left semi or anti join,
so I accept the cost rather than change `EliminateLimits` for every bounded
input. I added a paragraph about it to the PR description.
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/plans/LogicalPlanSuite.scala:
##########
@@ -169,6 +170,11 @@ class LogicalPlanSuite extends SparkFunSuite {
assert(query.where(Literal.FalseLiteral).maxRowsPerPartition.contains(0))
}
+ test("SPARK-61891: a left single join outputs at most as many rows as its
left side") {
+ val join = Join(Range(0, 10, 1, 1), Range(0, 100, 1, 1), LeftSingle, None,
JoinHint.NONE)
Review Comment:
Good catch. Added a case where the right side has no row bound
(`UnresolvedRelation`), and checked that it fails if the new case is narrowed
to a bounded right side. Done in 33be1519fc0.
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/statsEstimation/BasicStatsEstimationSuite.scala:
##########
@@ -402,6 +402,18 @@ test("range with invalid long value") {
attributeStats = AttributeMap(Seq(attribute -> colStat))))
}
+ test("SPARK-61891: a left single join is estimated from its left side") {
+ // It outputs each of the 10 rows of `plan` once, with the column of
`other` added.
+ val otherKey = attr("other")
+ val other = StatsTestPlan(outputList = Seq(otherKey), rowCount = 1000,
+ attributeStats = AttributeMap(Seq(otherKey -> colStat)), size =
Some(1000 * (8 + 4)))
+ val join = Join(plan, other, LeftSingle, Some(attribute === otherKey),
JoinHint.NONE)
Review Comment:
Good catch. The left side now has twice its row count times its row width,
as in the SPARK-61534 test, so the expected size is 320 and a left semi style
estimate (160) no longer passes. Done in 33be1519fc0.
--
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]