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"

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!