[英]py4JJavaError: An error occurred while calling o253.load. : java.lang.ClassNotFoundException: Failed to find data source: bigquery
Trying to read data from bigquery to jupyter notebook with pyspark libraries.尝试使用 pyspark 库将数据从 bigquery 读取到 jupyter notebook。 All of the apache spark and java hvae been downloaded to my C:Drive.所有 apache spark 和 java hvae 都已下载到我的 C:Drive。 Read and watched tutorial videos but none of them which seem to work.阅读并观看了教程视频,但它们似乎都不起作用。 looking for guidance寻求指导
Code:代码:
import pyspark
import findspark
from pyspark import SparkContext,SparkConf
from pyspark.sql import SparkSession
from pyspark.sql.functions import window, col, year, month, aggregate, date_add,
timestamp_seconds, rank, split
from pyspark.sql.types import StructField, StructType, StringType, BooleanType, DoubleType,
StringType, IntegerType, FloatType
#import com.google.cloud.spark.bigquery
#this creates spark UI - check current spark session
spark =SparkSession.builder.master('local[*]').appName('conversions').enableHiveSupport().getOrCreate()
df = spark.read.format('bigquery').load('table')
df.show()
error: Py4JJavaError: An error occurred while calling o253.load.错误:Py4JJavaError:调用 o253.load 时出错。 : java.lang.ClassNotFoundException: Failed to find data source: bigquery. :java.lang.ClassNotFoundException:找不到数据源:bigquery。 Please find packages at http://spark.apache.org/third-party-projects.html请在http://spark.apache.org/third-party-projects.html找到包
Please change the SparkSession creation to请将 SparkSession 创建更改为
spark =SparkSession.builder \
.master('local[*]') \
.appName('conversions') \
.enableHiveSupport() \
.conf('spark.jars.packages', 'com.google.cloud.spark:spark-bigquery-with-dependencies_2.12:0.23.2') \
.getOrCreate()
Also, please make sure you are using a python notebook rather than a pyspark notebook - otherwise Jupyter will create the SparkSession for you and no additional packages can be added.另外,请确保您使用的是 python 笔记本而不是 pyspark 笔记本 - 否则 Jupyter 将为您创建 SparkSession,并且无法添加其他包。
See more documentation in theconnector's repo .在连接器的 repo中查看更多文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.