-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
builtins: add st_asgeojson for recordsets #52715
Conversation
51bbe13
to
e93c568
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 5 of 5 files at r1.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @otan)
pkg/sql/logictest/testdata/logic_test/geospatial, line 426 at r1 (raw file):
CREATE TABLE parse_test_geojson AS SELECT row_number() OVER (ORDER BY id) as id,
I didn't quite understand how this table is different from parse_test
-- isn't it doing a one-to-one mapping of rows and generating an id using the ordering of ids in parse_test
?
pkg/sql/logictest/testdata/logic_test/geospatial, line 433 at r1 (raw file):
query TTT SELECT ST_AsGeoJSON(parse_test_geojson.*),
this one without the geomcolumnname
parameter picks the "geom" column. If there was no column named "geom", what would it do?
pkg/sql/logictest/testdata/logic_test/geospatial, line 462 at r1 (raw file):
}, "properties": { "geom": {
Should geom
be appearing in properties
given that it has already been incorporated into geometry
? The examples at https://postgis.net/docs/ST_AsGeoJSON.html suggest not.
Hmm, is this because we've selected geog
so all the other columns are in properties, which includes geom
?
pkg/sql/sem/builtins/geo_builtins.go, line 4235 at r1 (raw file):
} if label == "" { label = fmt.Sprintf("f%d", i+1)
where is this default labeling specified (from a user's perspective)?
pkg/sql/sem/builtins/geo_builtins.go, line 4260 at r1 (raw file):
} continue }
So empty geoColumn
implies we pick the first one we can parse. Is that consistent with PostGIS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @sumeerbhola)
pkg/sql/logictest/testdata/logic_test/geospatial, line 426 at r1 (raw file):
Previously, sumeerbhola wrote…
I didn't quite understand how this table is different from
parse_test
-- isn't it doing a one-to-one mapping of rows and generating an id using the ordering of ids inparse_test
?
i'll add a comment - parse test relies on row_id which changes betwen runs. i needed this to be a fixed number to get this to work.
pkg/sql/logictest/testdata/logic_test/geospatial, line 433 at r1 (raw file):
Previously, sumeerbhola wrote…
this one without the
geomcolumnname
parameter picks the "geom" column. If there was no column named "geom", what would it do?
pretend it's a NULL geometry
pkg/sql/logictest/testdata/logic_test/geospatial, line 462 at r1 (raw file):
Previously, sumeerbhola wrote…
Should
geom
be appearing inproperties
given that it has already been incorporated intogeometry
? The examples at https://postgis.net/docs/ST_AsGeoJSON.html suggest not.
Hmm, is this because we've selectedgeog
so all the other columns are in properties, which includesgeom
?
yep that's it -- if there's more than one, the rest go in properties.
pkg/sql/sem/builtins/geo_builtins.go, line 4235 at r1 (raw file):
Previously, sumeerbhola wrote…
where is this default labeling specified (from a user's perspective)?
seems to be the default if the tuple isn't labelled in row_to_json
/ for tuple types if there are no labels.
pkg/sql/sem/builtins/geo_builtins.go, line 4260 at r1 (raw file):
Previously, sumeerbhola wrote…
So empty
geoColumn
implies we pick the first one we can parse. Is that consistent with PostGIS?
yep!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @otan and @sumeerbhola)
pkg/sql/sem/builtins/geo_builtins.go, line 4235 at r1 (raw file):
Previously, otan (Oliver Tan) wrote…
seems to be the default if the tuple isn't labelled in
row_to_json
/ for tuple types if there are no labels.
Can you add a code comment with this reference.
Release note (sql change): Add ST_AsGeoJSON for recordsets, putting row contents into the properties field of a GeoJSON object.
bors r=sumeerbhola |
Build succeeded: |
Release note (sql change): Add ST_AsGeoJSON for recordsets, putting row
contents into the properties field of a GeoJSON object.