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

ch 6 map -> create_map #40

Open
dpuddu86 opened this issue May 30, 2019 · 3 comments
Open

ch 6 map -> create_map #40

dpuddu86 opened this issue May 30, 2019 · 3 comments

Comments

@dpuddu86
Copy link

df.select(map(col("Description"), col("InvoiceNo")).alias("complex_map"))\

It seems SCALA version, same as #L319

@bllchmbrs
Copy link
Contributor

Sorry, what's the issue? Could you open a pull request with the change?

@dpuddu86
Copy link
Author

Hi,
lines 313 to 320 seem not working using pySpark.
The map command seems SCALA and not pyspark language, I think it should be replaced with create_map.
Even the book "Spark, The Definitive Guide" seems affected by the same error at pag 109.

I'm sorry but I'm not able to open a pull request. I'm just using the code as a reference for a tutorial on Databricks community available online. This is the first issue I report.

The following lines may help to understand.
L307(WORKING using create_map)
df.select(create_map(col("Description"), col("InvoiceNo")).alias("complex_map"))
.show(2)

L313 (NOT WORKING, here we have map instead of create_map of line 307)
df.select(map(col("Description"), col("InvoiceNo")).alias("complex_map"))
.selectExpr("complex_map['WHITE METAL LANTERN']").show(2)

L319 (NOT WORKING, here we have map instead of create_map of line 307)
df.select(map(col("Description"), col("InvoiceNo")).alias("complex_map"))
.selectExpr("explode(complex_map)").show(2)

@JoeKastner
Copy link

Just came across this as well - I'll submit a PR with the fix.

JoeKastner added a commit to JoeKastner/Spark-The-Definitive-Guide that referenced this issue Mar 10, 2020
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

3 participants