Github user hvanhovell commented on a diff in the pull request:
https://github.com/apache/spark/pull/14132#discussion_r70226914
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
---
@@ -339,8 +339,24 @@ class AstBuilder extends SqlBaseBaseVisitor[AnyRef]
with Logging {
case SqlBaseParser.SELECT =>
// Regular select
+ // Broadcast hints
+ var withBroadcastedTable = relation
+ if (ctx.hint != null) {
+ val broadcastedTables =
+
hint.mapJoinHint.broadcastedTables.asScala.map(visitTableIdentifier)
+ for (table <- broadcastedTables) {
+ var stop = false
+ withBroadcastedTable = withBroadcastedTable.transformDown {
+ case r @ BroadcastHint(UnresolvedRelation(_, _)) => r
+ case r @ UnresolvedRelation(t, _) if !stop && t == table =>
--- End diff --
What happens if we use the same table multiple times? Only the first one
gets a broadcasted hint? What does hive do?
What will happen if we do something like this:
```SQL
SELECT /*+ MAPJOIN(tbl_b) */
*
FROM tbl_a A
LEFT JOIN tbl_b B
ON B.id = A.id
LEFT JOIN (SELECT XA.id
FROM tbl_c XA
LEFT ANTI JOIN tbl_b XB
ON XB.id = XA.id) C
ON C.id = A.id
```
Will both the `tbl_b` instances be broadcasted?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]