Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

staticSchema error in chapter 3 in s #62

Open
LeilaGhods opened this issue Jan 19, 2021 · 1 comment
Open

staticSchema error in chapter 3 in s #62

LeilaGhods opened this issue Jan 19, 2021 · 1 comment

Comments

@LeilaGhods
Copy link

I get the following error in the running of the following code from Chapter 3 (Structured Streaming)

in Python

streamingDataFrame = spark.readStream
.schema(staticSchema)
.option("maxFilesPerTrigger", 1)
.format("csv")
.option("header", "true")
.load("/data/retail-data/by-day/*.csv")

NameError: name 'staticSchema' is not defined

NameError Traceback (most recent call last)
in
2 #How many files read together is identified by maxFilesPerTrigger
3 streamingDataFrame = spark.readStream
----> 4 .schema(staticSchema)
5 .option("maxFilesPerTrigger", 1)
6 .format("csv")\

NameError: name 'staticSchema' is not defined

Can anyone guide me about it? I am running the code on Databricks community cluster.

Thanks,

@Silverlight42
Copy link

I think you are missing this:

staticDataFrame = spark.read.format("csv")\ 
.option("header", "true")\ 
.option("inferSchema", "true")\ 
.load("/data/retail-data/ by-day/*.csv") 

staticSchema = staticDataFrame.schema

For reference:

Chambers, Bill; Zaharia, Matei. Spark: The Definitive Guide: Big Data Processing Made Simple (p. 63). O'Reilly Media. Kindle Edition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants