andygrove commented on code in PR #1424: URL: https://github.com/apache/datafusion-comet/pull/1424#discussion_r1963989909
########## spark/src/main/scala/org/apache/comet/rules/RewriteJoin.scala: ########## @@ -67,4 +78,21 @@ object RewriteJoin extends JoinSelectionHelper { } case _ => plan } + + def getOptimalBuildSide(join: Join): BuildSide = { + val leftSize = join.left.stats.sizeInBytes + val rightSize = join.right.stats.sizeInBytes + val leftRowCount = join.left.stats.rowCount + val rightRowCount = join.right.stats.rowCount + if (leftSize == rightSize && rightRowCount.isDefined && leftRowCount.isDefined) { + if (rightRowCount.get <= leftRowCount.get) { Review Comment: With AQE enabled, we have rowCount and sizeInBytes available for completed query stages. We could extend the logic here to also look at `LogicalRelation.sizeInBytes` if the AQE stats are not available (this could be the case for the first join in a query). @mbutrovich also suggested that we take into account the size of the data that will go into the build-side hash table i.e. consider which columns are uses in the join. I think we can experiment more with this. I will file an issue to track this. -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org