scala – Spark-submit Sql Context Create Statement不起作用
发布时间:2020-12-16 18:36:32 所属栏目:安全 来源:网络整理
导读:我的下面的代码不适用于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 '
我的下面的代码不适用于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://....' """) 它给出了错误: 此代码适用于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) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |