mysql - Using Spark to Read from Hive -
problem
i attempting read hive table, receiving following error:
[error] (run-main-0) org.apache.spark.sql.analysisexception: table or view not found: tags; line 1 pos 14 i have placed hive-site.xml in both $spark_home/conf , $hive_home/conf. well, had no trouble using sqoop grab data mysql , importing hive. wrong scala code? or config error?
scala code:
package test1 import java.io.file import org.apache.spark.sql.row import org.apache.spark.sql.sparksession case class movie(movieid: string, title: string, genres: string) case class tag(userid: string, title: string, tag: string) object sparkhivetest { def main(args: array[string]) { val warehouselocation = new file("spark-warehouse").getabsolutepath val spark = sparksession .builder() .master("local") .appname("sparkhiveexample") .config("spark.sql.warehouse.dir", warehouselocation) .enablehivesupport() .getorcreate() spark.sql("select * tags").show() spark.stop() } } hive-site.xml:
<configuration> <property> <name>javax.jdo.option.connectionurl</name> <value>jdbc:mysql://localhost/metastore?createdatabaseifnotexist=true</value> <description>metadata stored in mysql server</description> </property> <property> <name>javax.jdo.option.connectiondrivername</name> <value>com.mysql.jdbc.driver</value> <description>mysql jdbc driver class</description> </property> <property> <name>javax.jdo.option.connectionusername</name> <value>hiveuser</value> <description>user name connecting mysql server</description> </property> <property> <name>javax.jdo.option.connectionpassword</name> <value>hivepass</value> <description>password connecting mysql server</description> </property> </configuration>
make sure hive metastore configured properly:
<configuration> <property> <name>hive.metastore.uris</name> <value>hive metastore uri(s) here</value> <description>uri client contact metastore server</description> </property> </configuration>
Comments
Post a Comment