GithubHelp home page GithubHelp logo

Comments (5)

mkleinbort avatar mkleinbort commented on May 21, 2024 2

I was the one that asked the SO question, and the notebook example helped me fix the issue.

It's probably enough to add something like:


To run this from within a Dataproc Jupyter instance, be sure to start a Python notebook (Not PySpark) and run:

from pyspark.sql import SparkSession

spark = SparkSession.builder \
  .appName('EDA')\
  .config('spark.jars', 'gs://spark-lib/bigquery/spark-bigquery-latest.jar') \
  .getOrCreate()

You can then load data as a spark dataframe through

s = spark.read \
  .format('bigquery') \
  .option('table', '{_project_}.{_database_}.{_table_name_}') \
  .load()

from spark-bigquery-connector.

mkleinbort avatar mkleinbort commented on May 21, 2024

That said, I'm seeing terrible performance when I try to run anything.

Even something like

s = spark.read.format('bigquery').option('table', 'my_project.all_data.stores').load()
s.take(1)

Is taking minutes... and then crashing.

Also

s.columns

results in a crash.

That said, that's nothing to do with this issue. I'll do some googling and then ask again.

from spark-bigquery-connector.

mkleinbort avatar mkleinbort commented on May 21, 2024

A correction on the above, I ran

%%time
s.columns

And got an answer, but it took ~5minutes. This was not registered by the %%time command which clocked a wall time of 57.5 ยตs

from spark-bigquery-connector.

mkleinbort avatar mkleinbort commented on May 21, 2024

Just found that changing things to

s = spark.read \
  .format('bigquery') \
  .option('project', '{_project_name_}') \
  .option('table', '{_database_}.{_table_name_}') \
  .load()

resolved many of my issues, though

s.take(1) 

results in

Server Connection Error
Invalid response: 504

Py4JJavaError: An error occurred while calling o119.collectToPython.
: org.apache.spark.SparkException: Job aborted due to stage failure: 
Task 0 in stage 1.0 failed 4 times, most recent failure: Lost task 0.3 in 
stage 1.0 [...]: java.lang.ClassNotFoundException:
com.google.cloud.spark.bigquery.direct.BigQueryPartition

from spark-bigquery-connector.

davidrabinowitz avatar davidrabinowitz commented on May 21, 2024

https://github.com/GoogleCloudDataproc/spark-bigquery-connector#using-in-jupyter-notebooks

from spark-bigquery-connector.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.