Spark job creating only 1 stage task when executed

321 Views Asked by At

I am trying to load data from DB2 to Hive using Spark 2.1.1. & Scala 2.11. Code used is given below

import org.apache.spark.SparkConf
import org.apache.spark.SparkContext
import org.apache.spark.sql
import org.apache.spark.sql.SparkSession
import org.apache.spark.sql.SQLContext
import org.apache.spark.sql.hive.HiveContext;

object DB2SparkDataImport {
  def main(args: Array[String]): Unit = {
    //Start the Spark context
    val conf = new SparkConf().setAppName("DB2SparkDataImport").set("mapreduce.fileoutputcommitter.algorithm.version","2").set("spark.serializer","org.apache.spark.serializer.KryoSerializer").set("spark.kryoserializer.buffer.mb","24") 
    val sc = new SparkContext(conf)
    val sqlContext = new SQLContext(sc)
    val hiveContext = new HiveContext(sc)
    val sparkSession = SparkSession.builder().enableHiveSupport().getOrCreate()
    val df = sqlContext.read.format("jdbc").option("url", "jdbc:db2://<<host>>:<<port>>/<<db>>")
      .option("driver", "com.ibm.db2.jcc.DB2Driver").option("dbtable", "<<table name>>").option("user", "<<user name>>").option("password", "pswd").option("column", "LAST_UPD").option("numPartitions", "100").option("lowerBound", "1").option("upperBound", "100000").load()
    df.createOrReplaceTempView("mytempTable")
    val query = "INSERT OVERWRITE TABLE test.temp_stage select * from mytempTable"
    sparkSession.sql(query);
  }
}

Spark Submit command used is

export SPARK_MAJOR_VERSION=2
spark-submit --master yarn --deploy-mode cluster --class com.test.DB2SparkDataImport --driver-memory 5g  --executor-memory 3G --num-executors 10 --executor-cores 3  --conf spark.sql.shuffle.partitions=23 --conf spark.default.parallelism=23  --conf 'spark.executor.extraJavaOptions=-Ddb2.jcc.charsetDecoderEncoder=3' --conf 'spark.driver.extraJavaOptions=-Ddb2.jcc.charsetDecoderEncoder=3'  --jars db2jcc4-10.1.jar --files hive-site.xml DB2SparkDataImport-0.0.1-SNAPSHOT.jar 

This job is taking more than 30 minutes to get completed. No: of records in the table is 34901381 & its 678.7422 MB. I have added the column,numPartitions,lower bound and upper bound values. I need to execute the job on hourly basis to fetch entire data from the table.

Please help to resolve why only 1 stage task is generated for this program and how can i reduce the time of execution of this job.

Thanks,

Amrutha K

0

There are 0 best solutions below