Last active
January 11, 2016 01:53
-
-
Save karanveerm/27d852bf311e39f05491 to your computer and use it in GitHub Desktop.
java.lang.IllegalArgumentException: spark.sql.execution.id is already set
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Imports | |
import org.apache.spark.sql.hive.HiveContext | |
import org.apache.spark.{SparkConf, SparkContext} | |
import org.apache.spark.sql.SaveMode | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import java.util.Properties | |
import scala.concurrent.Future | |
// Set up spark on local with 2 threads | |
val conf = new SparkConf().setMaster("local[2]").setAppName("app") | |
val sc = new SparkContext(conf) | |
val sqlCtx = new HiveContext(sc) | |
// Create fake dataframe | |
import sqlCtx.implicits._ | |
var df = sc.parallelize(1 to 50000).map { i => (i, i, i, i, i, i, i) }.toDF("a", "b", "c", "d", "e", "f", "g").repartition(2) | |
// Write it as a parquet file | |
df.write.parquet("/tmp/parquet1") | |
df = sqlCtx.read.parquet("/tmp/parquet1") | |
// JDBC connection | |
val url = s"jdbc:postgresql://localhost:5432/tempdb" | |
val prop = new Properties() | |
prop.setProperty("user", "admin") | |
prop.setProperty("password", "") | |
// 4 futures - at least one of them has been consistently failing for | |
val x1 = Future { df.write.jdbc(url, "temp1", prop) } | |
val x2 = Future { df.write.jdbc(url, "temp2", prop) } | |
val x3 = Future { df.write.jdbc(url, "temp3", prop) } | |
val x4 = Future { df.write.jdbc(url, "temp4", prop) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment