Skip to content

Commit

Permalink
optbuilder: add ST_Collect/ST_MakeLine to isOrderingSensitive
Browse files Browse the repository at this point in the history
Release note (bug fix): Fix a bug where ST_MakeLine and ST_Collect
did not respect ordering when used over a window clause.
  • Loading branch information
otan committed Dec 9, 2020
1 parent 1ccc24d commit ab28f4a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/geospatial
Original file line number Diff line number Diff line change
Expand Up @@ -5014,6 +5014,11 @@ SELECT ST_AsEWKT(ST_MakeLine(g::geometry)) FROM ( VALUES
----
NULL

query T
SELECT ST_AsText(ST_MakeLine(geom ORDER BY geom)) FROM geo_table
----
LINESTRING (1 1, 2 2, 2.22 -2.445)

query T
SELECT ST_Extent(g::geometry) FROM ( VALUES
(NULL),
Expand Down Expand Up @@ -5091,6 +5096,16 @@ SELECT ST_AsEWKT(ST_Collect(g::geometry)) FROM ( VALUES ('GEOMETRYCOLLECTION (PO
----
GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (1 1)), GEOMETRYCOLLECTION (POINT (2 2)))

query T
SELECT ST_AsText(ST_Collect(geom ORDER BY geom)) FROM geo_table
----
MULTIPOINT (1 1, 2 2, 2.22 -2.445)

query T
SELECT ST_AsText(ST_MemCollect(geom ORDER BY geom)) FROM geo_table
----
MULTIPOINT (1 1, 2 2, 2.22 -2.445)

query T
SELECT ST_AsEWKT(ST_MemCollect(g::geometry)) FROM ( VALUES (NULL), ('POINT (1 1)'), ('POINT EMPTY'), ('POINT (2 2)')) tbl(g)
----
Expand Down
3 changes: 2 additions & 1 deletion pkg/sql/opt/optbuilder/groupby.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ func (a aggregateInfo) isOrderingSensitive() bool {
return true
}
switch a.def.Name {
case "array_agg", "concat_agg", "string_agg", "json_agg", "jsonb_agg", "json_object_agg", "jsonb_object_agg":
case "array_agg", "concat_agg", "string_agg", "json_agg", "jsonb_agg", "json_object_agg", "jsonb_object_agg",
"st_makeline", "st_collect", "st_memcollect":
return true
default:
return false
Expand Down

0 comments on commit ab28f4a

Please sign in to comment.