diff --git a/pkg/sql/opt/norm/fold_constants.go b/pkg/sql/opt/norm/fold_constants.go index 9d23501db126..b1b854676071 100644 --- a/pkg/sql/opt/norm/fold_constants.go +++ b/pkg/sql/opt/norm/fold_constants.go @@ -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": {}, } diff --git a/pkg/sql/opt/norm/testdata/rules/fold_constants b/pkg/sql/opt/norm/testdata/rules/fold_constants index 469db12f2a2a..b063044eee63 100644 --- a/pkg/sql/opt/norm/testdata/rules/fold_constants +++ b/pkg/sql/opt/norm/testdata/rules/fold_constants @@ -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() ---- diff --git a/pkg/sql/sem/builtins/geo_builtins.go b/pkg/sql/sem/builtins/geo_builtins.go index f6031ec787cc..7a773c6e5b52 100644 --- a/pkg/sql/sem/builtins/geo_builtins.go +++ b/pkg/sql/sem/builtins/geo_builtins.go @@ -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)