• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: filter data in Spark SQL in Databrick

Resolved: filter data in Spark SQL in Databrick

0
By Isaac Tonny on 18/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

When I run below command in Databrick , I get output where I have three columns called name, id and age but when I try to filter on name by running below I get below error as Name column do not exist. What wrong am i doing?
This gives me a table with 3 column correctly.
Now I do filter oon Name like this
and I get error as Name table do not exist.What wis wrong here. Also if someone can tell me how can I export the resultant output.
Thanks

Answer:

Filtering happens before your expand your array of structs. You have two choices here:
  1. Use common table expressions to explode first & then filter:

  1. Use the filter function to filter out data inside the array with something like that (not tested), but it may require doing the filtering two times:

If you have better answer, please add a comment about this, thank you!

apache-spark-sql databricks databricks-sql
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Unable to run Docker .NET 6 console image

02/04/2023

Resolved: Input Focus between two React Components

02/04/2023

Resolved: linq2db throws exception when filtering by nested collection

02/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.