Can't import sqlContext.implicits._ without an error through Jupyter

主宰稳场 提交于 2020-02-27 07:44:13

问题


When I try to use the import sqlContext.implicits._ on my Jupyter notebook, I get the following error:

Name: Compile Error
Message: <console>:25: error: stable identifier required, but $iwC.this.$VAL10.sqlContext.implicits found.
       import sqlContext.implicits._
                         ^

I've tried this locally and it works, but this does not properly function when using it on my Jupyter Notebook server (which is hosted on ec2). I have tried importing different libraries involving that, but unfortunately can not get it to function.


回答1:


You need to instantiate a sqlContext like so:

val sqlC = new org.apache.spark.sql.SQLContext(sc)
import sqlC.implicits._

You should have seen this error:

stable identifier required




回答2:


you have to use val keyword instead of var keyword. Since val is equals to const or final keywords.



来源:https://stackoverflow.com/questions/37798657/cant-import-sqlcontext-implicits-without-an-error-through-jupyter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!