scala – Spark-submit Sql Context Create Statement不起作用

我的下面的代码不适用于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://....'
      """)

它给出了错误
线程“main”中的异常java.lang.RuntimeException:[1.2]失败:“with”预期但找到标识符

代码适用于Spark-shell,但不适用于Spark-submit.可能是什么原因?

解决方法

spark-shell中的“sqlContext”认为’HiveContext’.也许您需要在脚本中新建一个HiveContext而不是sqlContext.

你可以这样新:

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

相关文章

共收录Twitter的14款开源软件,第1页Twitter的Emoji表情 Tw...
Java和Scala中关于==的区别Java:==比较两个变量本身的值,即...
本篇内容主要讲解“Scala怎么使用”,感兴趣的朋友不妨来看看...
这篇文章主要介绍“Scala是一种什么语言”,在日常操作中,相...
这篇文章主要介绍“Scala Trait怎么使用”,在日常操作中,相...
这篇文章主要介绍“Scala类型检查与模式匹配怎么使用”,在日...