5
votes

My below code does not work with Spark-submit.

sqlContext.sql(s"""
create external table if not exists landing (
date string,
referrer string)
partitioned by (partnerid string,dt string)
row format delimited fields terminated by '\t' lines terminated by '\n'
STORED AS TEXTFILE LOCATION 's3n://....'
      """)

It gives error: Exception in thread "main" java.lang.RuntimeException: [1.2] failure: ``with'' expected but identifier create found

This code works in Spark-shell but not in Spark-submit. What can be the reason?

1
Maybe missing imports? - Reactormonk
Also import sqlContext.implicits._? - Reactormonk
class Analysis extends Serializable{ val sc = new SparkContext() val sqlContext = SQLContextSingleton.getInstance(sc) import sqlContext.implicits._ => I run it like this but no way :( - Yusuf Can Gürkan
Did you eventually find a solution for this? - octavian

1 Answers

3
votes

"sqlContext" in spark-shell is 'HiveContext' by default. Maybe you need to new a HiveContext instead of sqlContext in your script.

You may new it like that:

import SparkContext._
import org.apache.spark.sql.hive._ 
val sc = new SparkContext()
val sqlContext = new HiveContext(sc)