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

    https://github.com/apache/spark/pull/12634#discussion_r60848581
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
 ---
    @@ -412,20 +412,26 @@ class Analyzer(
             catalog.lookupRelation(u.tableIdentifier, u.alias)
           } catch {
             case _: NoSuchTableException =>
    -          u.failAnalysis(s"Table or View not found: ${u.tableName}")
    +          u.failAnalysis(s"Table or view not found: ${u.tableName}")
           }
         }
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, _, _, _, _) =>
             i.copy(table = EliminateSubqueryAliases(lookupTableFromCatalog(u)))
           case u: UnresolvedRelation =>
    -        try {
    +        val table = u.tableIdentifier
    +        if (table.database.isDefined && conf.runSQLonFile &&
    +            (!catalog.databaseExists(table.database.get) || 
!catalog.tableExists(table))) {
    +          // If the table does not exist, and the database part is 
specified, and we support
    +          // running SQL directly on files, then let's just return the 
original UnresolvedRelation.
    +          // It is possible we are matching a query like "select * from 
parquet.`/path/to/query`".
    +          // The plan will get resolved later.
    +          // Note that we are testing (!db_exists || !table_exists) 
because the catalog throws
    --- End diff --
    
    We can add it when it shows up more. So far this is the only place.
    
    On Sunday, April 24, 2016, tedyu <[email protected]> wrote:
    
    > In
    > 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
    > <https://github.com/apache/spark/pull/12634#discussion_r60845292>:
    >
    > >        }
    > >      }
    > >
    > >      def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
    > >        case i @ InsertIntoTable(u: UnresolvedRelation, _, _, _, _) =>
    > >          i.copy(table = 
EliminateSubqueryAliases(lookupTableFromCatalog(u)))
    > >        case u: UnresolvedRelation =>
    > > -        try {
    > > +        val table = u.tableIdentifier
    > > +        if (table.database.isDefined && conf.runSQLonFile &&
    > > +            (!catalog.databaseExists(table.database.get) || 
!catalog.tableExists(table))) {
    > > +          // If the table does not exist, and the database part is 
specified, and we support
    > > +          // running SQL directly on files, then let's just return the 
original UnresolvedRelation.
    > > +          // It is possible we are matching a query like "select * 
from parquet.`/path/to/query`".
    > > +          // The plan will get resolved later.
    > > +          // Note that we are testing (!db_exists || !table_exists) 
because the catalog throws
    >
    > Maybe add a helper method in catalog with database and table name which
    > checks existence of database first, followed by existence of table.
    >
    > —
    > You are receiving this because you authored the thread.
    > Reply to this email directly or view it on GitHub
    > 
<https://github.com/apache/spark/pull/12634/files/cddc66b62d89bb35c3a53d307d9d3410fe133e16#r60845292>
    >



---
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]

Reply via email to