如何将pyspark(在本地模式下)连接到bigquery?

huangapple go评论62阅读模式
英文:

How to connect pyspark (in local mode) to bigquery?

问题

我正在本地模式下运行pyspark,需要连接到bigquery。我找到了这个链接:https://cloud.google.com/dataproc/docs/tutorials/bigquery-connector-spark-example 但它们关注dataproc,而我的spark设置在本地机器上。

请有人帮助我以要点的方式高层次理解,我需要设置连接并将数据查询到数据框的确切步骤是什么?

谢谢

英文:

I am running pyspark in local mode, and I need to connect to bigquery. I have found this: https://cloud.google.com/dataproc/docs/tutorials/bigquery-connector-spark-example but they focus on dataproc, and my spark is set up on a local machine.

Could someone please help me understand at a high level, in points, what exactly are the things I need to set up the connection and query the data into dataframes?

Thank you

答案1

得分: 1

将此内容翻译如下:

根据这个SO帖子,您可以通过以下方式在不使用Dataproc的情况下将pyspark连接到BigQuery:

spark.read.format("bigquery").option("credentialsFile", "</path/to/key/file>").option("table", "<table>").load()
英文:

Posting this as a community wiki.

As per this SO post, you can connect pysparkto bigquery without using dataproc by running :

spark.read.format(&quot;bigquery&quot;).option(&quot;credentialsFile&quot;, &quot;&lt;/path/to/key/file&gt;&quot;).option(&quot;table&quot;, &quot;&lt;table&gt;&quot;).load()

huangapple
  • 本文由 发表于 2023年7月10日 20:22:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/76653706.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定