提交 c1696101 编写于 作者: O obdev 提交者: ob-robot

[CP] [GIS] query range shoud be linked by or

上级 47b31944
......@@ -3527,7 +3527,8 @@ int ObQueryRange::pre_extract_and_or_op(const ObOpRawExpr *m_expr,
query_range_ctx_->cur_expr_is_precise_ = false;
if (OB_FAIL(preliminary_extract(m_expr->get_param_expr(i), tmp, dtc_params))) {
LOG_WARN("preliminary_extract failed", K(ret));
} else if (T_OP_AND == m_expr->get_expr_type()) {
} else if (!is_contain_geo_filters() // geo range linked by or
&& T_OP_AND == m_expr->get_expr_type()) {
if (OB_FAIL(add_and_item(key_part_list, tmp))) {
LOG_WARN("push back failed", K(ret));
}
......@@ -3542,7 +3543,8 @@ int ObQueryRange::pre_extract_and_or_op(const ObOpRawExpr *m_expr,
}
if (OB_SUCC(ret)) {
query_range_ctx_->cur_expr_is_precise_ = cur_expr_is_precise;
if (T_OP_AND == m_expr->get_expr_type()) {
if (!is_contain_geo_filters() // geo range linked by or
&& T_OP_AND == m_expr->get_expr_type()) {
if (OB_FAIL(and_range_graph(key_part_list, out_key_part))) {
LOG_WARN("and range graph failed", K(ret));
}
......
......@@ -3226,3 +3226,85 @@ Outputs & filters:
select id, min, max, st_astext(line_geo) from spatial_point_in_line ignore index(geom_idx_1) where ST_Contains(line_geo, LineString(Point(80, 0), Point(91, 0)));
id min max st_astext(line_geo)
2 80 100 LINESTRING(80 0,100 0)
drop table t1;
create table t1 (c1 int primary key, g GEOMETRY NOT NULL SRID 4326, SPATIAL INDEX(g));
insert into t1 values (1, ST_GeomFromText('POINT(1 1)', 4326));
insert into t1 values (2, ST_GeomFromText('POINT(-1 1)', 4326));
insert into t1 values (3, ST_GeomFromText('POINT(-1 -1)', 4326));
insert into t1 values (4, ST_GeomFromText('POINT(1 -1)', 4326));
insert into t1 values (5, ST_GeomFromText('POLYGON((0 0, 1 0, 1 -1, 0 -1, 0 0))', 4326));
insert into t1 values (6, ST_GeomFromText('LINESTRING(-1 -1, 3 3)', 4326));
insert into t1 values (7, ST_GeomFromText('POLYGON((1 1, -1 1, -1 -1, 1 -1, 1 1))', 4326));
insert into t1 values (8, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326));
insert into t1 values (9, ST_GeomFromText('POINT(0 0)', 4326));
select /*+ index(t1 g) */ c1, ST_AsText(g) FROM t1 where ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326)) or (ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326)) and ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
c1 ST_AsText(g)
1 POINT(1 1)
4 POINT(1 -1)
5 POLYGON((0 0,1 0,1 -1,0 -1,0 0))
7 POLYGON((1 1,-1 1,-1 -1,1 -1,1 1))
8 POLYGON((0 0,0 2,2 2,2 0,0 0))
select /*+ full(t1) */ c1, ST_AsText(g) FROM t1 where ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326)) or (ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326)) and ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
c1 ST_AsText(g)
1 POINT(1 1)
4 POINT(1 -1)
5 POLYGON((0 0,1 0,1 -1,0 -1,0 0))
7 POLYGON((1 1,-1 1,-1 -1,1 -1,1 1))
8 POLYGON((0 0,0 2,2 2,2 0,0 0))
select /*+ index(t1 g) */ c1, ST_AsText(g) FROM t1 where ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326))
and (ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326))
or ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
c1 ST_AsText(g)
1 POINT(1 1)
5 POLYGON((0 0,1 0,1 -1,0 -1,0 0))
7 POLYGON((1 1,-1 1,-1 -1,1 -1,1 1))
8 POLYGON((0 0,0 2,2 2,2 0,0 0))
select /*+ full(t1) */ c1, ST_AsText(g) FROM t1 where ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326))
and (ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326))
or ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
c1 ST_AsText(g)
1 POINT(1 1)
5 POLYGON((0 0,1 0,1 -1,0 -1,0 0))
7 POLYGON((1 1,-1 1,-1 -1,1 -1,1 1))
8 POLYGON((0 0,0 2,2 2,2 0,0 0))
select /*+ index(t1 g) */ c1, ST_AsText(g) FROM t1 where (ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326))
and ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 -2, 2 -2, 2 0, 0 0))', 4326)))
or (ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326))
and ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
c1 ST_AsText(g)
1 POINT(1 1)
4 POINT(1 -1)
5 POLYGON((0 0,1 0,1 -1,0 -1,0 0))
7 POLYGON((1 1,-1 1,-1 -1,1 -1,1 1))
8 POLYGON((0 0,0 2,2 2,2 0,0 0))
select /*+ full(t1) */ c1, ST_AsText(g) FROM t1 where (ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326))
and ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 -2, 2 -2, 2 0, 0 0))', 4326)))
or (ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326))
and ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
c1 ST_AsText(g)
1 POINT(1 1)
4 POINT(1 -1)
5 POLYGON((0 0,1 0,1 -1,0 -1,0 0))
7 POLYGON((1 1,-1 1,-1 -1,1 -1,1 1))
8 POLYGON((0 0,0 2,2 2,2 0,0 0))
select /*+ index(t1 g) */ c1, ST_AsText(g) FROM t1 where (ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326))
or ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 -2, 2 -2, 2 0, 0 0))', 4326)))
and (ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326))
or ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
c1 ST_AsText(g)
5 POLYGON((0 0,1 0,1 -1,0 -1,0 0))
6 LINESTRING(-1 -1,3 3)
7 POLYGON((1 1,-1 1,-1 -1,1 -1,1 1))
8 POLYGON((0 0,0 2,2 2,2 0,0 0))
9 POINT(0 0)
select /*+ full(t1) */ c1, ST_AsText(g) FROM t1 where (ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326))
or ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 -2, 2 -2, 2 0, 0 0))', 4326)))
and (ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326))
or ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
c1 ST_AsText(g)
5 POLYGON((0 0,1 0,1 -1,0 -1,0 0))
6 LINESTRING(-1 -1,3 3)
7 POLYGON((1 1,-1 1,-1 -1,1 -1,1 1))
8 POLYGON((0 0,0 2,2 2,2 0,0 0))
9 POINT(0 0)
drop table t1;
......@@ -510,3 +510,52 @@ insert into spatial_point_in_line (min, max, line_geo) values
select id, min, max, st_astext(line_geo) from spatial_point_in_line where ST_Contains(line_geo, LineString(Point(80, 0), Point(91, 0)));
explain select id, min, max, st_astext(line_geo) from spatial_point_in_line where ST_Contains(line_geo, LineString(Point(80, 0), Point(91, 0)));
select id, min, max, st_astext(line_geo) from spatial_point_in_line ignore index(geom_idx_1) where ST_Contains(line_geo, LineString(Point(80, 0), Point(91, 0)));
--error 0,1051
drop table t1;
create table t1 (c1 int primary key, g GEOMETRY NOT NULL SRID 4326, SPATIAL INDEX(g));
insert into t1 values (1, ST_GeomFromText('POINT(1 1)', 4326));
insert into t1 values (2, ST_GeomFromText('POINT(-1 1)', 4326));
insert into t1 values (3, ST_GeomFromText('POINT(-1 -1)', 4326));
insert into t1 values (4, ST_GeomFromText('POINT(1 -1)', 4326));
insert into t1 values (5, ST_GeomFromText('POLYGON((0 0, 1 0, 1 -1, 0 -1, 0 0))', 4326));
insert into t1 values (6, ST_GeomFromText('LINESTRING(-1 -1, 3 3)', 4326));
insert into t1 values (7, ST_GeomFromText('POLYGON((1 1, -1 1, -1 -1, 1 -1, 1 1))', 4326));
insert into t1 values (8, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326));
insert into t1 values (9, ST_GeomFromText('POINT(0 0)', 4326));
# c1 or (c2 and c3)
select /*+ index(t1 g) */ c1, ST_AsText(g) FROM t1 where ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326)) or (ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326)) and ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
select /*+ full(t1) */ c1, ST_AsText(g) FROM t1 where ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326)) or (ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326)) and ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
#c1 and (c2 or c3)
select /*+ index(t1 g) */ c1, ST_AsText(g) FROM t1 where ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326))
and (ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326))
or ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
select /*+ full(t1) */ c1, ST_AsText(g) FROM t1 where ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326))
and (ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326))
or ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
# (c1 and c2) or (c3 and c4)
select /*+ index(t1 g) */ c1, ST_AsText(g) FROM t1 where (ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326))
and ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 -2, 2 -2, 2 0, 0 0))', 4326)))
or (ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326))
and ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
select /*+ full(t1) */ c1, ST_AsText(g) FROM t1 where (ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326))
and ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 -2, 2 -2, 2 0, 0 0))', 4326)))
or (ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326))
and ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
# (c1 or c2) and (c3 or c4)
select /*+ index(t1 g) */ c1, ST_AsText(g) FROM t1 where (ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326))
or ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 -2, 2 -2, 2 0, 0 0))', 4326)))
and (ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326))
or ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
select /*+ full(t1) */ c1, ST_AsText(g) FROM t1 where (ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326))
or ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 -2, 2 -2, 2 0, 0 0))', 4326)))
and (ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326))
or ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
drop table t1;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册