Class ExtractSpatialJoins
- java.lang.Object
-
- io.trino.sql.planner.iterative.rule.ExtractSpatialJoins
-
public class ExtractSpatialJoins extends Object
Applies to broadcast spatial joins, inner and left, expressed via ST_Contains, ST_Intersects and ST_Distance functions.For example:
- SELECT ... FROM a, b WHERE ST_Contains(b.geometry, a.geometry)
- SELECT ... FROM a, b WHERE ST_Intersects(b.geometry, a.geometry)
- SELECT ... FROM a, b WHERE ST_Distance(b.geometry, a.geometry) <= 300
- SELECT ... FROM a, b WHERE 15.5 > ST_Distance(b.geometry, a.geometry)
Joins expressed via ST_Contains and ST_Intersects functions must match all of the following criteria:
- arguments of the spatial function are non-scalar expressions; - one of the arguments uses symbols from left side of the join, the other from right.
Joins expressed via ST_Distance function must use less than or less than or equals operator to compare ST_Distance value with a radius and must match all of the following criteria:
- arguments of the spatial function are non-scalar expressions; - one of the arguments uses symbols from left side of the join, the other from right; - radius is either scalar expression or uses symbols only from the right (build) side of the join.
For inner join, replaces cross join node and a qualifying filter on top with a single spatial join node.
For both inner and left joins, pushes non-trivial expressions of the spatial function arguments and radius into projections on top of join child nodes.
Examples:
Point-in-polygon inner join ST_Contains(ST_GeometryFromText(a.wkt), ST_Point(b.longitude, b.latitude)) becomes a spatial join ST_Contains(st_geometryfromtext, st_point) with st_geometryfromtext -> 'ST_GeometryFromText(a.wkt)' and st_point -> 'ST_Point(b.longitude, b.latitude)' projections on top of child nodes. Distance query ST_Distance(ST_Point(a.lon, a.lat), ST_Point(b.lon, b.lat)) <= 10 / (111.321 * cos(radians(b.lat))) becomes a spatial join ST_Distance(st_point_a, st_point_b) <= radius with st_point_a -> 'ST_Point(a.lon, a.lat)', st_point_b -> 'ST_Point(b.lon, b.lat)' and radius -> '10 / (111.321 * cos(radians(b.lat)))' projections on top of child nodes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classExtractSpatialJoins.ExtractSpatialInnerJoinstatic classExtractSpatialJoins.ExtractSpatialLeftJoin
-
Constructor Summary
Constructors Constructor Description ExtractSpatialJoins(Metadata metadata, SplitManager splitManager, PageSourceManager pageSourceManager, TypeAnalyzer typeAnalyzer)
-
-
-
Constructor Detail
-
ExtractSpatialJoins
public ExtractSpatialJoins(Metadata metadata, SplitManager splitManager, PageSourceManager pageSourceManager, TypeAnalyzer typeAnalyzer)
-
-