Github user maropu commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22198#discussion_r212850203
  
    --- 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 --
    
    @dongjoon-hyun a little confused about the name resolution here;
    ```
    "SELECT /*+ MAPJOIN(v1) */ * FROM global_temp.v1, v2 WHERE v1.id = v2.id",
    ```
    `MAPJOIN(v1)` implicitly means `global_temp.v1`?
    For example;
    ```
    "SELECT /*+ MAPJOIN(v1) */ * FROM default.v1, global_temp.v1 WHERE 
default.v1.id = global_temp.v1.id",
    ```
    In this case, what's the `MAPJOIN(v1)` behaviour?
     - 1. Apply no hint
     - 2. Apply a hint into `default.v1` only
     - 3. Apply a hint into both
    
    WDYT?


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to