尝试使用 Rest API 使用 Serverless Dataproc 提交 Spark 作业时 https://cloud.google.com/dataproc-serverless/docs/quickstarts/spark-batch#dataproc_serverless_create_batch_workload-drest
curl -X POST \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://dataproc.googleapis.com/v1/projects/project-id/locations/region/batches"
我收到此错误响应
{
"error": {
"code": 400,
"message": "Batch ID is required",
"status": "INVALID_ARGUMENT"
}
}
我在这里缺少什么?
最佳答案
我使用 gcloud --log-http
进行了测试:
$ gcloud dataproc batches submit spark --log-http \
--jars=file:///usr/lib/spark/examples/jars/spark-examples.jar \
--class=org.apache.spark.examples.SparkPi \
-- 1000
...
==== request start ====
uri: https://dataproc.googleapis.com/v1/projects/my-project/locations/us-west1/batches?alt=json&batchId=21dd24ca279a4603926d4e59d65bfaf9&requestId=21dd24ca279a4603926d4e59d65bfaf9
method: POST
...
请注意网址中的 batchId=21dd24ca279a4603926d4e59d65bfaf9
。
我还测试了使用 --batch
手动设置 ID:
$ gcloud dataproc batches submit spark --log-http \
--batch=foobar \
--jars=file:///usr/lib/spark/examples/jars/spark-examples.jar \
--class=org.apache.spark.examples.SparkPi \
-- 1000
...
==== request start ====
uri: https://dataproc.googleapis.com/v1/projects/my-project/locations/us-west1/batches?alt=json&batchId=foobar&requestId=c7b5a753cac4483da21b1ba1c6c2a2d1
method: POST
...
似乎 REST API 需要在 URL 中添加 batchId
参数,但使用 gcloud 时它会自动生成一个参数。
关于google-cloud-platform - 无服务器 Dataproc 错误 - 需要批处理 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71311179/