Skip to content
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

geo/geomfn: implement ST_Relate and ST_ContainsProperly #48552

Merged
merged 1 commit into from
May 12, 2020

Conversation

otan
Copy link
Contributor

@otan otan commented May 7, 2020

Commit on top of #48522.

Added ST_ContainsProperly to the optimizer as well that calls it to use
Covers.

Also update the RFC to claim ST_ContainsProperly as indexed backed.

Release note (sql change): Implemented the geometry based builtins
ST_Relate and ST_ContainsProperly.

@otan otan requested review from sumeerbhola and a team May 7, 2020 21:56
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@otan otan force-pushed the st_containsproperly_relate branch from 0fba7b9 to 6484ec4 Compare May 7, 2020 21:58
@maddyblue
Copy link
Contributor

opt parts lgtm

@blathers-crl
Copy link

blathers-crl bot commented May 7, 2020

❌ The GitHub CI (Cockroach) build has failed on 6484ec48.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

@otan otan force-pushed the st_containsproperly_relate branch from 6484ec4 to b95b567 Compare May 8, 2020 01:03
@otan otan changed the title geo/geogfn: implement ST_Relate and ST_ContainsProperly geo/geomfn: implement ST_Relate and ST_ContainsProperly May 8, 2020
@otan otan force-pushed the st_containsproperly_relate branch from b95b567 to 12b5e70 Compare May 8, 2020 07:46
Copy link
Collaborator

@sumeerbhola sumeerbhola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only minor comments -- looks good overall

Reviewed 13 of 13 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @otan and @sumeerbhola)


docs/RFCS/20200421_geospatial.md, line 1043 at r2 (raw file):

* ST_Contains(g, x), ST_Contains(x, g): use contains(g, x) or
  contained-by(g, x)
* ST_ContainsProperly(g, x), ST_ContainsProperly(x, g): see above.

nit: please repeat the text from the previous bullet


pkg/geo/geomfn/binary_predicates.go, line 49 at r2 (raw file):

T**FF*FF*

There is some redundancy in DE-9IM -- when I tried to construct I came up with TF*FF*FF*, but I think it is equivalent to what you wrote above.


pkg/geo/geomfn/de9im.go, line 31 at r2 (raw file):

// MatchesDE9IM checks whether the given DE-9IM relation matches the DE-91M pattern.
// See: https://en.wikipedia.org/wiki/DE-9IM.
func MatchesDE9IM(str string, pattern string) (bool, error) {

I am assuming str cannot have * since it represents the actual computed relation.
If yes, can you add that to this function comment.


pkg/geo/geomfn/de9im.go, line 43 at r2 (raw file):

			continue
		case 't':
			if str[i] < '0' || str[i] > '2' {

when do we expect < 0?
Can you add a comment that f represents false and that 0, 1, 2 are true?
I think it would be easier to read if we added a conversion function to a bool.


pkg/geo/geos/geos.cc, line 430 at r2 (raw file):

//
// DE-9IM related

Please add the wikipedia link

@otan otan force-pushed the st_containsproperly_relate branch from 12b5e70 to 56fe9c0 Compare May 8, 2020 15:59
Copy link
Contributor Author

@otan otan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @sumeerbhola)


pkg/geo/geomfn/binary_predicates.go, line 49 at r2 (raw file):

Previously, sumeerbhola wrote…
T**FF*FF*

There is some redundancy in DE-9IM -- when I tried to construct I came up with TF*FF*FF*, but I think it is equivalent to what you wrote above.

I cheated and used what was on https://postgis.net/docs/ST_ContainsProperly.html.


pkg/geo/geomfn/de9im.go, line 31 at r2 (raw file):

Previously, sumeerbhola wrote…

I am assuming str cannot have * since it represents the actual computed relation.
If yes, can you add that to this function comment.

Done.


pkg/geo/geomfn/de9im.go, line 43 at r2 (raw file):

Previously, sumeerbhola wrote…

when do we expect < 0?
Can you add a comment that f represents false and that 0, 1, 2 are true?
I think it would be easier to read if we added a conversion function to a bool.

Done.


pkg/geo/geos/geos.cc, line 430 at r2 (raw file):

Previously, sumeerbhola wrote…

Please add the wikipedia link

Done.

@otan otan force-pushed the st_containsproperly_relate branch from 56fe9c0 to ff2a00b Compare May 8, 2020 16:00
@blathers-crl
Copy link

blathers-crl bot commented May 8, 2020

❌ The GitHub CI (Cockroach) build has failed on ff2a00be.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

@otan otan force-pushed the st_containsproperly_relate branch from ff2a00b to d74dd01 Compare May 8, 2020 16:35
Copy link
Collaborator

@sumeerbhola sumeerbhola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 7 of 7 files at r3.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @otan and @sumeerbhola)


pkg/geo/geomfn/de9im.go, line 29 at r3 (raw file):

// MatchesDE9IM checks whether the given DE-9IM relation matches the DE-91M pattern.
// Assumes the relation has been computed, and such has no 'T' characters.

did you mean '*'?


pkg/geo/geomfn/de9im.go, line 54 at r3 (raw file):

// Pattern matches are as follows:
// * '*': allow anything.
// * 'T': allow only if the relation is '0' (point), '1' (line) or '2' (polygon).

'T' or 't': allow if the relation is true, which is represented by any of the characters '0' (point), '1' (line) or '2' (area) (representing the dimensionality of the intersection).


pkg/geo/geomfn/de9im.go, line 55 at r3 (raw file):

// * '*': allow anything.
// * 'T': allow only if the relation is '0' (point), '1' (line) or '2' (polygon).
// * 'f': allow only if relation is also false.

'F' or 'f': allow only if the relation is false, which is represented by the characters 'f' or 'F'.


pkg/geo/geomfn/de9im.go, line 62 at r3 (raw file):

	case 't':
		// True should only match characters 0-2. 'T' should never exist
		// in a relation.

I think one can drop this last sentence "'T' should never exist ..."

Copy link
Contributor Author

@otan otan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @sumeerbhola)


pkg/geo/geomfn/de9im.go, line 29 at r3 (raw file):

Previously, sumeerbhola wrote…

did you mean '*'?

both, actually.


pkg/geo/geomfn/de9im.go, line 54 at r3 (raw file):

Previously, sumeerbhola wrote…

'T' or 't': allow if the relation is true, which is represented by any of the characters '0' (point), '1' (line) or '2' (area) (representing the dimensionality of the intersection).

Done.


pkg/geo/geomfn/de9im.go, line 55 at r3 (raw file):

Previously, sumeerbhola wrote…

'F' or 'f': allow only if the relation is false, which is represented by the characters 'f' or 'F'.

Done.


pkg/geo/geomfn/de9im.go, line 62 at r3 (raw file):

Previously, sumeerbhola wrote…

I think one can drop this last sentence "'T' should never exist ..."

Done.

@otan otan force-pushed the st_containsproperly_relate branch from d74dd01 to 060cf58 Compare May 8, 2020 19:56
@blathers-crl
Copy link

blathers-crl bot commented May 8, 2020

❌ The GitHub CI (Cockroach) build has failed on 060cf58b.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

Copy link
Collaborator

@sumeerbhola sumeerbhola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 13 of 16 files at r1, 2 of 2 files at r4.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @otan and @sumeerbhola)


pkg/geo/geomfn/de9im.go, line 54 at r4 (raw file):

// Pattern matches are as follows:
// * '*': allow anything.
// * 't'/'T': allow only if the relation is tryem which is represented any of

s/tryem/true/

... is represented by any of ...


pkg/geo/geomfn/de9im.go, line 55 at r4 (raw file):

// * '*': allow anything.
// * 't'/'T': allow only if the relation is tryem which is represented any of
//   '0' (point), '1' (line) or '2' (polygon) which are the dimensionality of the

s/polygon/area

... which is the dimensionality ...

@otan otan force-pushed the st_containsproperly_relate branch from 060cf58 to 95e93a7 Compare May 9, 2020 00:14
@otan otan requested review from a team as code owners May 9, 2020 00:14
Copy link
Contributor Author

@otan otan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @sumeerbhola)


pkg/geo/geomfn/de9im.go, line 54 at r4 (raw file):

Previously, sumeerbhola wrote…

s/tryem/true/

... is represented by any of ...

Done.


pkg/geo/geomfn/de9im.go, line 55 at r4 (raw file):

Previously, sumeerbhola wrote…

s/polygon/area

... which is the dimensionality ...

Done.

Added ST_ContainsProperly to the optimizer as well that calls it to use
Covers.

Also update the RFC to claim ST_ContainsProperly as indexed backed.

Release note (sql change): Implemented the geometry based builtins
`ST_Relate` and `ST_ContainsProperly`.
@otan otan force-pushed the st_containsproperly_relate branch from 95e93a7 to 616821a Compare May 11, 2020 21:24
Copy link
Collaborator

@sumeerbhola sumeerbhola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 3 of 3 files at r5.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @sumeerbhola)

@otan
Copy link
Contributor Author

otan commented May 12, 2020

bors r=sumeerbhola

craig bot pushed a commit that referenced this pull request May 12, 2020
48552: geo/geomfn: implement ST_Relate and ST_ContainsProperly r=sumeerbhola a=otan

Commit on top of #48522.

Added ST_ContainsProperly to the optimizer as well that calls it to use
Covers.

Also update the RFC to claim ST_ContainsProperly as indexed backed.

Release note (sql change): Implemented the geometry based builtins
`ST_Relate` and `ST_ContainsProperly`.

48659: colexec: fix type schema for LEFT SEMI and LEFT ANTI joins r=yuzefovich a=yuzefovich

LEFT SEMI and LEFT ANTI joins output only all the columns from the left,
however, we mistakenly put the columns from the right into
`result.ColumnTypes`.

Fixes: #48622.

Release note (bug fix): Previously, CockroachDB could encounter an
internal error when a query with LEFT SEMI or LEFT ANTI join was
performed via the vectorized execution engine in some cases, and now
this has been fixed. This is likely to occur only with `vectorize=on`
setting.

Co-authored-by: Oliver Tan <[email protected]>
Co-authored-by: Yahor Yuzefovich <[email protected]>
@craig
Copy link
Contributor

craig bot commented May 12, 2020

Build failed (retrying...)

This was referenced Feb 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants