title: catch exceptionorg.apache.spark.sql.AnalysisException: Table or view not found
body: <p>I am trying to query hive table from spark scala code and getting below error:</p>
  
  <pre><code>catch exceptionorg.apache.spark.sql.AnalysisException: Table or view not found: `databaseName`.`register`; line 1 pos 35;
  'Distinct
  +- 'Project ['computer_name]
     +- 'UnresolvedRelation `databaseName`.`register`
  
  job failed
  </code></pre>
  
  <p>Here is the code, to read the data from Hive.</p>
  
  <pre><code>import org.apache.spark.sql.{SQLContext, SparkSession}
  val hc = spark.sqlContext
  val dbName = "databaseName"
  val tblName = "register"
      val HostDF = hc.sql(s"""select distinct computer_name from ${dbName}.${tblName} """)
  </code></pre>
  
  <p>If I ran through spark-shell, I don't see any issue and I am getting the data.</p>
  
  <p>If I am using same code through spark scala code(I mean running jar in cluster mode), I am getting above mentioned error.</p>
  
  <p>Could any one tell me what I am doing wrong in code Vs spark-shell?</p>
  
  <p>Thanks,
  Bab</p>