Github user rick-ibm commented on the pull request:

    https://github.com/apache/spark/pull/9202#issuecomment-152661995
  
    Thanks for the quick response, Michael. Simply parenthesizing the query 
will result in non-Standard syntax which an ANSI-compliant database will 
reject...
    
    // Raises the unhelpful error: Syntax error: Encountered "WHERE" at line 1, 
column 37.
    try {
      val jdbcDF = sqlContext.read.format("jdbc").options( 
        Map("url" -> "jdbc:derby:/Users/rhillegas/derby/databases/derby1",
        "dbtable" -> "(select * from app.t)")).load()
    } catch {
      case t: Throwable => println(t.getMessage)
    }
    
    However, you can go one step further and give the subquery a correlation 
name so that it will fit nicely in a FROM list...
    
    // succeeds
    try {
      val jdbcDF = sqlContext.read.format("jdbc").options( 
        Map("url" -> "jdbc:derby:/Users/rhillegas/derby/databases/derby1",
        "dbtable" -> "(select * from app.t) correlationName")).load()
    } catch {
      case t: Throwable => println(t.getMessage)
    }
    
    I am inclined to close SPARK-11426 as "not a problem". It seems that 
JDBCRDD.resolveTable() deliberately doesn't call 
JdbcDialect.getTableExistsQuery() because it is not really probing for the 
existence of the table. It is trying to compute the row-signature of a query 
expression.
    
    In any event, the changes made by this patch do not seem to affect the code 
path you are concerned about.
    
    Thanks,
    -Rick



---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to