Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write Dataframe to Phoenix

i am trying to write Dataframe to Phoenix table but i am getting exception.

Here is my code:

df.write.format("org.apache.phoenix.spark").mode(SaveMode.Overwrite).options(collection.immutable.Map(
                "zkUrl" -> "localhost:2181/hbase-unsecure",
                "table" -> "TEST")).save();

and the exception is:

org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 3.0 failed 4 times, most recent failure: 
Lost task 0.3 in stage 3.0 (TID 411, ip-xxxxx-xx-xxx.ap-southeast-1.compute.internal):
java.lang.RuntimeException: java.sql.SQLException: No suitable driver found for jdbc:phoenix:localhost:2181:/hbase-unsecure;
            at org.apache.phoenix.mapreduce.PhoenixOutputFormat.getRecordWriter(PhoenixOutputFormat.java:58)
            at org.apache.spark.rdd.PairRDDFunctions$anonfun$saveAsNewAPIHadoopDataset$1$anonfun$12.apply(PairRDDFunctions.scala:1030)
            at org.apache.spark.rdd.PairRDDFunctions$anonfun$saveAsNewAPIHadoopDataset$1$anonfun$12.apply(PairRDDFunctions.scala:1014)
            at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66)
            at org.apache.spark.scheduler.Task.run(Task.scala:88)
            at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:214)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

I have added phoenix-spark and phoenix-core jars to my pom.xml

like image 727
ROOT Avatar asked Mar 20 '17 06:03

ROOT


1 Answers

Per the Phoenix-Spark plugin doc, if you haven't, you might want to set both spark.executor.extraClassPath and spark.driver.extraClassPath in SPARK_HOME/conf/spark-defaults.conf to include phoenix-<version>-client.jar.

like image 82
Leo C Avatar answered Nov 19 '22 02:11

Leo C