我正在尝试从kafka读取数据并保存到hdfs上的镶木地板文件中。 我的代码类似于以下,不同之处在于我用Java编写。
val df = spark
.readStream
.format("kafka")
.option("kafka.bootstrap.servers", "host1:port1,host2:port2")
.option("subscribe", "topic1")
.load()
df.selectExpr("CAST(key AS STRING)","CAST(value AS STRING)").writeStream.format("parquet").option("path",outputPath).option("checkpointLocation", "/tmp/sparkcheckpoint1/").outputMode("append").start().awaiteTermination()
然而,它引发了Uri without authority: hdfs:/data/_spark_metadata
异常,其中hdfs:///data
是输出路径。
当我将代码更改为spark.read
和df.write
以写出一次镶木地板文件时,没有任何异常,所以我猜它与我的hdfs配置无关。
任何人都可以帮助我吗?
答案 0 :(得分:0)
Here有建议从路径中删除hdfs://,但将其保留在检查点中。但是,对我来说,在HDP沙箱中,无论在检查点有无hdfs://,它都能同时起作用:
.option("path", "/user/username/outpath")
.option("checkpointLocation", "/tmp/checkpoint")