I have a table in default database of Hive, and can sucessfully get records from that table in command line:
>hive: select * from my_table;
But when I create a job in Spark to run, it just throwns me exception like this:
INFO metastore.HiveMetaStore: 0: get_table : db=default tbl=my_table
16/01/04 03:41:42 INFO HiveMetaStore.audit: ugi=etl ip=unknown-ip-addr cmd=get_table : db=default tbl=my_table
Exception in thread "main" org.apache.spark.sql.AnalysisException: no such table my_table;
Here is the code of that job:
SparkConf conf = new SparkConf().setMaster("local").setAppName("PhucdullApp");
JavaSparkContext sc = new JavaSparkContext(conf);
HiveContext sqlContext = new org.apache.spark.sql.hive.HiveContext(sc.sc());
DataFrame df = sqlContext.sql("select * from my_table");
df.show();
sc.close();
(Assuming that you are using default Derby database which is configured in hive-default.xml file). Ensure that you have followed the following steps: -
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With