简体   繁体   中英

Bigquery non-null(geographypoint) in grouped dataset

I need to pick non-null(geographypoint) from my grouped dataset. The max function gives the following error.

MAX is not defined for arguments of type GEOGRAPHY at [65:11]

Consider the sample data:

╔════════════════════╦══════════════════════════════╗
║id                  ║Point                         ║
╠════════════════════╬══════════════════════════════╣             
║1                   ║POINT(-79.3123031 43.6839641) ║       
║1                   ║null                          ║      
╚════════════════════╩══════════════════════════════╝

I need to pick out the non null value from the grouped data. For numeric/string values, we can use max Is there a way to tackle this for Geography data in bigquery?

I need to pick out the non null value from the grouped data

Consider below approach

select id, any_value(point) point
from data
where not point is null
group by id

MAX is not meaningful for spatial types because they are not simple values. I think you need to use the Geography functions and either

  • Extract a simple datatype (using a function like ST_X, or ST_AREA for example), and then you could use a MAX meaningfully to find for example the MAX longitude or the MAX area
  • Use a function like ST_BOUNDARY if you're looking for something like a spatial boundary from multiple GEOGRAPHY values

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM