【问题标题】:Redirecting output of Google Dataproc query into a text file将 Google Dataproc 查询的输出重定向到文本文件
【发布时间】:2020-06-11 13:47:19
【问题描述】:

我有一个要求,我需要在文本文件中输出 Google Dataproc。

例如,我有以下查询:

gcloud dataproc jobs submit hive --cluster=$CLUSTER --region=$REGION \
    --execute="select count(*) from db.table;"

我只需要平面文件中的记录数信息。

我正在使用类似下面的东西(重定向运算符)。但是,它为我提供了在控制台中打印的全部数据。

gcloud dataproc jobs submit hive --cluster=$CLUSTER --region=$REGION \
    --execute="select count(*) from db.table;" > text.csv

我想要的输出是:

724

其中724 是我的表中的记录总数。

变通解决方案:

gcloud dataproc 作业提交 hive --cluster=$CLUSTER --region=$REGION \ --execute="从 db.table 中选择计数(*);" &> 文本.csv

在重定向前使用 "&"。它会将整个输出重定向到 test.csv 文件。

【问题讨论】:

    标签: google-cloud-platform google-cloud-dataproc


    【解决方案1】:

    Dataproc 作业 API 不支持此功能。您可能必须在重定向之前进行一些输出解析。我提交了一个功能请求,以在 Jobs API 输出中分离 stdout 和 stderr。感谢您的反馈。

    【讨论】:

      猜你喜欢
      • 2013-01-06
      • 1970-01-01
      • 2013-04-21
      • 2023-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多