我正在尝试使用Pyspark将DataFrames写入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
ERROR:
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)
有谁知道问题可能是什么?如果有任何建议,我将不胜感激!谢谢!