Skip to content

Commit

Permalink
Merge #48446
Browse files Browse the repository at this point in the history
48446: opt: add geo functions to constant folding whitelist r=mjibson a=mjibson

Fixes #48213

Release notes: None

Co-authored-by: Matt Jibson <[email protected]>
  • Loading branch information
craig[bot] and maddyblue committed May 5, 2020
2 parents 19ab717 + b2affa4 commit 683f0d5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
33 changes: 33 additions & 0 deletions pkg/sql/opt/norm/fold_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,4 +490,37 @@ var FoldFunctionWhitelist = map[string]struct{}{
"json_array_length": {},
"jsonb_array_length": {},
"crdb_internal.locality_value": {},
"st_geomfromtext": {},
"st_geometryfromtext": {},
"st_geomfromewkt": {},
"st_geomfromwkb": {},
"st_geomfromewkb": {},
"st_geomfromgeojson": {},
"st_geogfromtext": {},
"st_geographyfromtext": {},
"st_geogfromewkt": {},
"st_geogfromwkb": {},
"st_geogfromewkb": {},
"st_geogfromgeojson": {},
"st_astext": {},
"st_asewkt": {},
"st_asbinary": {},
"st_asewkb": {},
"st_ashexwkb": {},
"st_ashexewkb": {},
"st_askml": {},
"st_asgeojson": {},
"st_area": {},
"st_length": {},
"st_perimeter": {},
"st_distance": {},
"st_covers": {},
"st_coveredby": {},
"st_contains": {},
"st_crosses": {},
"st_equals": {},
"st_intersects": {},
"st_overlaps": {},
"st_touches": {},
"st_within": {},
}
10 changes: 10 additions & 0 deletions pkg/sql/opt/norm/testdata/rules/fold_constants
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,16 @@ values
├── fd: ()-->(1)
└── (NULL,)

norm expect=FoldFunction
SELECT ST_Length(ST_GeomFromText('LINESTRING(743238 2967416,743238 2967450)', 2249));
----
values
├── columns: st_length:1!null
├── cardinality: [1 - 1]
├── key: ()
├── fd: ()-->(1)
└── (34.0,)

norm expect-not=FoldFunction
SELECT now(), current_user(), current_database()
----
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/sem/builtins/geo_builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ var geographyFromText = makeBuiltin(
},
)

// geoBuiltins must be kept in sync with sql/opt/norm/fold_constants.go.
var geoBuiltins = map[string]builtinDefinition{
//
// Input (Geometry)
Expand Down

0 comments on commit 683f0d5

Please sign in to comment.