我正在尝试使用pyspark将Dataframe写入hbase。
from pyspark import SparkContext
from pyspark.sql import SQLContext
sc = SparkContext()
sqlc = SQLContext(sc)
data_source_format = 'org.apache.spark.sql.execution.datasources.hbase'
df = sc.parallelize([('a', '1.0'), ('b', '2.0')]).toDF(schema=['col0', 'col1'])
catalog = ''.join("""{
"table":{"namespace":"default", "name":"testtable"},
"rowkey":"key",
"columns":{
"col0":{"cf":"rowkey", "col":"key", "type":"string"},
"col1":{"cf":"cf", "col":"col1", "type":"string"}
}
}""".split())
df.write.options(catalog=catalog).format(data_source_format).save()
正在执行以下格式的命令:
sudo spark-submit --packages com.hortonworks:shc-core:1.1.1-2.1-s_2.11 --repositories http://repo.hortonworks.com/content/groups/public/ --files /home/chenxx/hbase/conf/hbase-site.xml sogou4.py
spark版本:2.3.0 hadoop版本:2.7.6 hbase版本:1.1.5 scala版本:2.11.6
错误:
Traceback (most recent call last):
File "/home/chenxx/PycharmProjects/SoGou/sogou4.py", line 52, in <module>
df.write.options(catalog = catalog1).format(data_source_format).save()
File "/usr/local/lib/python2.7/dist-packages/pyspark/python/lib/pyspark.zip/pyspark/sql/readwriter.py", line 701, in save
File "/usr/local/lib/python2.7/dist-packages/pyspark/python/lib/py4j-0.10.6-src.zip/py4j/java_gateway.py", line 1160, in __call__
File "/usr/local/lib/python2.7/dist-packages/pyspark/python/lib/pyspark.zip/pyspark/sql/utils.py", line 63, in deco
File "/usr/local/lib/python2.7/dist-packages/pyspark/python/lib/py4j-0.10.6-src.zip/py4j/protocol.py", line 320, in get_return_value
**py4j.protocol.Py4JJavaError: An error occurred while calling o61.save.
: com.fasterxml.jackson.core.JsonParseException: Unexpected end-of-input: expected close marker for OBJECT (from [Source: {"table":{"namespace":"default","name":"testtable"},"rowkey":"key","columns":{"col0":{"cf":"rowkey","col":"key","type":"string"},"col1":{"cf":"cf","col":"col1","type":"string"}}; line: 1, column: 0])
at [Source: {"table":{"namespace":"default","name":"testtable"},"rowkey":"key","columns":{"col0":{"cf":"rowkey","col":"key","type":"string"},"col1":{"cf":"cf","col":"col1","type":"string"}}; line: 1, column: 355]**
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1581)
有人知道问题出在哪里吗?如果有什么建议,我将不胜感激!谢谢!
暂无答案!
目前还没有任何答案,快来回答吧!