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

    https://github.com/apache/spark/pull/17185#discussion_r206978220
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala
 ---
    @@ -654,16 +654,19 @@ class SessionCatalog(
        *
        * If the relation is a view, we generate a [[View]] operator from the 
view description, and
        * wrap the logical plan in a [[SubqueryAlias]] which will track the 
name of the view.
    +   * [[SubqueryAlias]] will also keep track of the name and 
database(optional) of the table/view
        *
        * @param name The name of the table/view that we look up.
        */
       def lookupRelation(name: TableIdentifier): LogicalPlan = {
         synchronized {
           val db = formatDatabaseName(name.database.getOrElse(currentDb))
           val table = formatTableName(name.table)
    +      // To keep track of the name and database of the table/view
    +      val alias = AliasIdentifier(table, Some(db))
           if (db == globalTempViewManager.database) {
             globalTempViewManager.get(table).map { viewDef =>
    -          SubqueryAlias(table, viewDef)
    +          SubqueryAlias(alias, viewDef)
    --- End diff --
    
    Here, SubqueryAlias takes in a AliasIdentifier and not a string. 
    
    Also want to mention that: we considered somewhat similar to your 
suggestion - to  simply add a qualifier as a Seq[String] as a member of 
SubqueryAlias but that change would require touching more files.  
    
    I had implemented that first (long time back now) and then after some 
offline discussions we favored this as this change is more localized and 
encapsulated.  @gatorsmile @cloud-fan 



---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to