cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

query array in SQL

Raymond_Garcia
Contributor II

Hello I have a databricks question I was not able to answer myself

I have this query

select count(*) from table

where object[0].value is not null and object[0].value.value1 = "s"

and created_year = 2022 and created_month = 7 and created_day = 4

you can see object[0] is an array

The question is: how can I query the whole array?

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

Raymond_Garcia
Contributor II

SELECT count(*)

FROM (

 SELECT explode(mmycolumn)

 FROM table

 WHERE created_year = 2022 and created_month = 7 and created_day = 5

)

WHERE col.field is not null and col.field.field! = "signal"

View solution in original post

1 REPLY 1

Raymond_Garcia
Contributor II

SELECT count(*)

FROM (

 SELECT explode(mmycolumn)

 FROM table

 WHERE created_year = 2022 and created_month = 7 and created_day = 5

)

WHERE col.field is not null and col.field.field! = "signal"

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group