简体   繁体   中英

How to filter on geography data in BigQuery

I am in need to filter my BigQuery table based on column which is of type Geography. I tried below queries SELECT * FROM bigqueryproject1-279667.mycreatedataset1.newTabelwithAllDatatype where location = ST_GEOGPOINT(-6, 6) but this shows me validation error Equality is not defined for arguments of type GEOGRAPHY. If I replcae '=' with like operator I get message stating like is applicable only for String and Byte. I refereed this documentation but not getting how to have filter.

I think you want something like this:

WHERE ST_INTERSECTS(location, ST_GEOGPOINT(-6, 6))

For geography, equality operator is not defined.

You can use ST_Equals , like ST_Equals(location, ST_GEOGPOINT(-6, 6)) if you really want only rows with geography value (almost) exactly equal to this point.

More often you would want to filter on other conditions, eg intersections with specific point, use ST_Intersects(location, ST_GEOGPOINT(-6, 6)) or on condition of being within some distance of a point, use ST_DWithin(location, ST_GEOGPOINT(-6, 6), 100) where last argument is distance in meters.

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