Github user dongjoon-hyun commented on a diff in the pull request:
https://github.com/apache/spark/pull/22198#discussion_r212852643
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveHints.scala
---
@@ -47,20 +49,39 @@ object ResolveHints {
*
* This rule must happen before common table expressions.
*/
- class ResolveBroadcastHints(conf: SQLConf) extends Rule[LogicalPlan] {
+ class ResolveBroadcastHints(conf: SQLConf, catalog: SessionCatalog)
extends Rule[LogicalPlan] {
private val BROADCAST_HINT_NAMES = Set("BROADCAST", "BROADCASTJOIN",
"MAPJOIN")
def resolver: Resolver = conf.resolver
- private def applyBroadcastHint(plan: LogicalPlan, toBroadcast:
Set[String]): LogicalPlan = {
+ private def namePartsWithDatabase(nameParts: Seq[String]): Seq[String]
= {
+ if (nameParts.size == 1) {
+ catalog.getCurrentDatabase +: nameParts
+ } else {
+ nameParts
+ }
+ }
+
+ private def matchedTableIdentifier(
+ nameParts: Seq[String],
+ tableIdent: IdentifierWithDatabase): Boolean = {
+ val identifierList =
+ tableIdent.database.getOrElse(catalog.getCurrentDatabase) ::
tableIdent.identifier :: Nil
+
namePartsWithDatabase(nameParts).corresponds(identifierList)(resolver)
--- End diff --
1) First of all, the above two test cases should work as before.
`global_temp.v1` should be used with the prefix `global_temp.`. Before this PR,
we cannot put `database` name on Hint. So, we allowed exceptional cases; hints
on global temporary view (without `global_temp.` prefix).
2) For the case you mentioned, I'd like to interpret `MAPJOIN(v1)` to
`default.v1 only` because it's the Spark's behavior outside this Hint syntax.
And, please add a test case for this, too.
@cloud-fan and @gatorsmile . Could you give us some advice, too? Is it okay
to you?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]