title: Issue with WITH clause with Cloudera JDBC Driver for Impala - Returning column name instead of actual Data
body: <p>I am using Cloudera JDBC Driver for Impala v 2.5.38 with Spark 1.6.0 to create DataFrame. It is working fine for all queries except WITH clause, but WITH is extensively used in my organization.
  Below is my code snippet.</p>
  
  <pre><code>def jdbcHDFS(url:String,sql: String):DataFrame = {
    var rddDF: DataFrame = null
    val jdbcURL = s"jdbc:impala://$url"
    val connectionProperties = new java.util.Properties
    connectionProperties.setProperty("driver","com.cloudera.impala.jdbc41.Driver")
    rddDF = sqlContext.read.jdbc(jdbcURL, s"($sql) AS ST", connectionProperties)
    rddDF
  }
  </code></pre>
  
  <p>Given below example for working and non-working SQL</p>
  
  <pre><code>val workingSQL = "select empname from (select * from employee) as tmp"
  val nonWorkingSQL = "WITH tmp as (select * from employee) select empname from tmp"
  </code></pre>
  
  <p>Below is the output of rddDF.first for above SQLs.</p>
  
  <p>For workingSQL </p>
  
  <pre><code>scala&gt; rddDF.first
  res8: org.apache.spark.sql.Row = [Kushal]
  </code></pre>
  
  <p>For nonWorkingSQL</p>
  
  <pre><code>scala&gt; rddDF.first
  res8: org.apache.spark.sql.Row = [empname] //Here we are expecting actual data ie. 'Kushal' instead of column name like the output of previous query.
  </code></pre>
  
  <p>It would be really helpful if anyone can suggest any solution for it.</p>
  
  <p>Please note: Both the queries are working fine in IMPALA-SHELL as well as in HIVE through HUE.</p>
  
  <p>Update:
  I have tried to setup plain JDBC connection and execute the nonWorkingSQL and it worked!
  Then i thought the issue is due to Spark wraps a "SELECT * FROM ( )" around the query, hence i tried the below SQL to find the root cause but still it worked and displayed expected result.</p>
  
  <pre><code>String sql  = "SELECT * FROM (WITH tmp as (select * from employee) select empname from tmp) AS ST"
  </code></pre>
  
  <p>Hence, the root cause is not clear and need to be analysed so that it work with SPARK as well. Please suggest further.</p>