【问题标题】:Is there a better way to load a spark df into BigQuery through PySpark cluster (dataporc)?有没有更好的方法通过 PySpark 集群(dataporc)将 spark df 加载到 BigQuery 中?
【发布时间】:2020-06-10 11:12:47
【问题描述】:

我目前正在使用以下代码通过 PySpark 集群 (dataproc) 将数据加载到 BigQuery 中,但是处理时间过长或因超出执行时间错误而终止。有没有更好更快的方法将 spark df 加载到 BigQuery 中?

output.write \
      .format("bigquery") \
      .option("table","{}.{}".format(bq_dataset, bq_table)) \
      .option("temporaryGcsBucket", gcs_bucket) \
      .mode('append') \
      .save()

以下是我的 dataproc 集群配置:

Master node : Standard (1 master, N workers)
Machine type : n1-standard-4
Number of GPUs : 0
Primary disk type : pd-standard
Primary disk size : 500GB
Worker nodes : 3
Machine type : n1-standard-4
Number of GPUs : 0
Primary disk type : pd-standard
Primary disk size : 500GB
Image version : 1.4.30-ubuntu18

【问题讨论】:

  • 数据的大小是多少?集群的大小是多少——有多少执行器、cpu、内存?
  • df.count()df.show() 运行无限时间并且不执行,不知道为什么,但我猜它不应该是 200-300 行,我已将集群配置添加为问题的一部分。

标签: python google-cloud-platform pyspark google-bigquery google-cloud-dataproc


【解决方案1】:

请确保您使用的是最新版本的 SparkBigQueryConnector。

尝试使用其他中间格式(例如 avro、orc 和 parquet)测试您的代码。 Avro 往往在处理更大的数据时表现更好。

如果您正在写入的数据非常庞大,请尝试添加更多工作人员或选择不同的机器类型。

【讨论】:

    猜你喜欢
    • 2016-01-26
    • 2022-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-17
    • 2015-07-31
    • 2018-08-20
    • 1970-01-01
    相关资源
    最近更新 更多