Skip to content

Commit

Permalink
Merge #59745 #60013
Browse files Browse the repository at this point in the history
59745: go.mod: update goavro from v2.8.1 to v2.9.8 r=pbardea a=pbardea

Release note: None

60013: geo/wkt: add support for parsing multipoints with Z and M dimensions r=otan a=andyyang890

This patch extends the capabilities of the WKT parser to include
parsing of multipoints with Z and M dimensions.

Refs: #53091

Release note: None

Co-authored-by: Paul Bardea <[email protected]>
Co-authored-by: Andy Yang <[email protected]>
  • Loading branch information
3 people committed Feb 9, 2021
3 parents 7e18ab9 + 4fb2248 + 7451591 commit ef1ea06
Show file tree
Hide file tree
Showing 9 changed files with 635 additions and 201 deletions.
4 changes: 2 additions & 2 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1752,8 +1752,8 @@ def go_deps():
name = "com_github_linkedin_goavro_v2",
build_file_proto_mode = "disable_global",
importpath = "github.com/linkedin/goavro/v2",
sum = "h1:4OGyN6pvutqmVtObCSzm0BQ+wQQNxSuHCN0t8UAfrjk=",
version = "v2.8.1",
sum = "h1:jN50elxBsGBDGVDEKqUlDuU1cFwJ11K/yrJCBMe/7Wg=",
version = "v2.9.8",
)
go_repository(
name = "com_github_lufia_iostat",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ require (
github.com/lib/pq v1.8.0
github.com/lib/pq/auth/kerberos v0.0.0-20200720160335-984a6aa1ca46
github.com/lightstep/lightstep-tracer-go v0.15.6
github.com/linkedin/goavro/v2 v2.8.1
github.com/linkedin/goavro/v2 v2.9.8
github.com/lufia/iostat v1.0.0
github.com/lusis/go-slackbot v0.0.0-20180109053408-401027ccfef5 // indirect
github.com/lusis/slack-test v0.0.0-20190426140909-c40012f20018 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,8 @@ github.com/lib/pq/auth/kerberos v0.0.0-20200720160335-984a6aa1ca46 h1:q7hY+WNJTc
github.com/lib/pq/auth/kerberos v0.0.0-20200720160335-984a6aa1ca46/go.mod h1:jydegJvs5JvVcuFD/YAT8JRmRVeOoRhtnGEgRnAoPpE=
github.com/lightstep/lightstep-tracer-go v0.15.6 h1:D0GGa7afJ7GcQvu5as6ssLEEKYXvRgKI5d5cevtz8r4=
github.com/lightstep/lightstep-tracer-go v0.15.6/go.mod h1:6AMpwZpsyCFwSovxzM78e+AsYxE8sGwiM6C3TytaWeI=
github.com/linkedin/goavro/v2 v2.8.1 h1:4OGyN6pvutqmVtObCSzm0BQ+wQQNxSuHCN0t8UAfrjk=
github.com/linkedin/goavro/v2 v2.8.1/go.mod h1:UgQUb2N/pmueQYH9bfqFioWxzYCZXSfF8Jw03O5sjqA=
github.com/linkedin/goavro/v2 v2.9.8 h1:jN50elxBsGBDGVDEKqUlDuU1cFwJ11K/yrJCBMe/7Wg=
github.com/linkedin/goavro/v2 v2.9.8/go.mod h1:UgQUb2N/pmueQYH9bfqFioWxzYCZXSfF8Jw03O5sjqA=
github.com/lufia/iostat v1.0.0 h1:umdPgllno4d03WCBsA0UIwzGIJYV8FfV4325kOYIhBU=
github.com/lufia/iostat v1.0.0/go.mod h1:lRgtFVamD7L7GaXOSwBiuXMwU3Aicfn5h66LVs4u2SA=
github.com/lusis/go-slackbot v0.0.0-20180109053408-401027ccfef5 h1:AsEBgzv3DhuYHI/GiQh2HxvTP71HCCE9E/tzGUzGdtU=
Expand Down
6 changes: 3 additions & 3 deletions pkg/ccl/changefeedccl/encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,10 +598,10 @@ func TestAvroLedger(t *testing.T) {
`entry: {"id":{"long":1543039099823358511}}->{"after":{"entry":{"amount":{"bytes.decimal":"0"},"created_ts":{"long.timestamp-micros":"1990-12-09T23:47:23.811124Z"},"customer_id":{"long":0},"id":{"long":1543039099823358511},"money_type":{"string":"C"},"system_amount":{"bytes.decimal":"44061/500"},"transaction_id":{"string":"payment:a8c7f832-281a-39c5-8820-1fb960ff6465"}}}}`,
`entry: {"id":{"long":2244708090865615074}}->{"after":{"entry":{"amount":{"bytes.decimal":"1/50"},"created_ts":{"long.timestamp-micros":"2075-11-08T22:07:12.055686Z"},"customer_id":{"long":0},"id":{"long":2244708090865615074},"money_type":{"string":"C"},"system_amount":{"bytes.decimal":"44061/500"},"transaction_id":{"string":"payment:a8c7f832-281a-39c5-8820-1fb960ff6465"}}}}`,
`entry: {"id":{"long":3305628230121721621}}->{"after":{"entry":{"amount":{"bytes.decimal":"1/25"},"created_ts":{"long.timestamp-micros":"2185-01-30T21:38:15.06669Z"},"customer_id":{"long":0},"id":{"long":3305628230121721621},"money_type":{"string":"C"},"system_amount":{"bytes.decimal":"44061/500"},"transaction_id":{"string":"payment:e3757ca7-d646-66ea-2b8d-6116831cbb05"}}}}`,
`entry: {"id":{"long":4151935814835861840}}->{"after":{"entry":{"amount":{"bytes.decimal":"3/50"},"created_ts":{"long.timestamp-micros":"1684-10-05T17:51:40.795101Z"},"customer_id":{"long":0},"id":{"long":4151935814835861840},"money_type":{"string":"C"},"system_amount":{"bytes.decimal":"44061/500"},"transaction_id":{"string":"payment:e3757ca7-d646-66ea-2b8d-6116831cbb05"}}}}`,
`entry: {"id":{"long":4151935814835861840}}->{"after":{"entry":{"amount":{"bytes.decimal":"3/50"},"created_ts":{"long.timestamp-micros":"2269-04-26T17:26:14.504652Z"},"customer_id":{"long":0},"id":{"long":4151935814835861840},"money_type":{"string":"C"},"system_amount":{"bytes.decimal":"44061/500"},"transaction_id":{"string":"payment:e3757ca7-d646-66ea-2b8d-6116831cbb05"}}}}`,
`entry: {"id":{"long":5577006791947779410}}->{"after":{"entry":{"amount":{"bytes.decimal":"0"},"created_ts":{"long.timestamp-micros":"2185-11-07T09:42:42.666146Z"},"customer_id":{"long":0},"id":{"long":5577006791947779410},"money_type":{"string":"C"},"system_amount":{"bytes.decimal":"-88123/1000"},"transaction_id":{"string":"payment:a8c7f832-281a-39c5-8820-1fb960ff6465"}}}}`,
`entry: {"id":{"long":6640668014774057861}}->{"after":{"entry":{"amount":{"bytes.decimal":"-1/50"},"created_ts":{"long.timestamp-micros":"1690-05-19T13:29:46.145044Z"},"customer_id":{"long":0},"id":{"long":6640668014774057861},"money_type":{"string":"C"},"system_amount":{"bytes.decimal":"-88123/1000"},"transaction_id":{"string":"payment:a8c7f832-281a-39c5-8820-1fb960ff6465"}}}}`,
`entry: {"id":{"long":7414159922357799360}}->{"after":{"entry":{"amount":{"bytes.decimal":"-1/25"},"created_ts":{"long.timestamp-micros":"1706-02-05T02:38:08.15195Z"},"customer_id":{"long":0},"id":{"long":7414159922357799360},"money_type":{"string":"C"},"system_amount":{"bytes.decimal":"-88123/1000"},"transaction_id":{"string":"payment:e3757ca7-d646-66ea-2b8d-6116831cbb05"}}}}`,
`entry: {"id":{"long":6640668014774057861}}->{"after":{"entry":{"amount":{"bytes.decimal":"-1/50"},"created_ts":{"long.timestamp-micros":"2274-12-08T13:04:19.854595Z"},"customer_id":{"long":0},"id":{"long":6640668014774057861},"money_type":{"string":"C"},"system_amount":{"bytes.decimal":"-88123/1000"},"transaction_id":{"string":"payment:a8c7f832-281a-39c5-8820-1fb960ff6465"}}}}`,
`entry: {"id":{"long":7414159922357799360}}->{"after":{"entry":{"amount":{"bytes.decimal":"-1/25"},"created_ts":{"long.timestamp-micros":"2290-08-26T02:12:41.861501Z"},"customer_id":{"long":0},"id":{"long":7414159922357799360},"money_type":{"string":"C"},"system_amount":{"bytes.decimal":"-88123/1000"},"transaction_id":{"string":"payment:e3757ca7-d646-66ea-2b8d-6116831cbb05"}}}}`,
`entry: {"id":{"long":8475284246537043955}}->{"after":{"entry":{"amount":{"bytes.decimal":"-3/50"},"created_ts":{"long.timestamp-micros":"2048-07-21T10:02:40.114474Z"},"customer_id":{"long":0},"id":{"long":8475284246537043955},"money_type":{"string":"C"},"system_amount":{"bytes.decimal":"-88123/1000"},"transaction_id":{"string":"payment:e3757ca7-d646-66ea-2b8d-6116831cbb05"}}}}`,
`session: {"session_id":{"string":"pLnfgDsc3WD9F3qNfHK6a95jjJkwzDkh0h3fhfUVuS0jZ9uVbhV4vC6AWX40IV"}}->{"after":{"session":{"data":{"string":"SP3NcHciWvqZTa3N06RxRTZHWUsaD7HEdz1ThbXfQ7pYSQ4n378l2VQKGNbSuJE0fQbzONJAAwdCxmM9BIabKERsUhPNmMmdf3eSJyYtqwcFiUILzXv3fcNIrWO8sToFgoilA1U2WxNeW2gdgUVDsEWJ88aX8tLF"},"expiry_timestamp":{"long.timestamp-micros":"2052-05-14T04:02:49.264975Z"},"last_update":{"long.timestamp-micros":"2070-03-19T02:10:22.552438Z"},"session_id":{"string":"pLnfgDsc3WD9F3qNfHK6a95jjJkwzDkh0h3fhfUVuS0jZ9uVbhV4vC6AWX40IV"}}}}`,
`transaction: {"external_id":{"string":"payment:a8c7f832-281a-39c5-8820-1fb960ff6465"}}->{"after":{"transaction":{"context":{"string":"BpLnfgDsc3WD9F3qNfHK6a95jjJkwzDkh0h3fhfUVuS0jZ9uVbhV4vC6"},"created_ts":{"long.timestamp-micros":"2178-08-01T19:10:30.064819Z"},"external_id":{"string":"payment:a8c7f832-281a-39c5-8820-1fb960ff6465"},"response":{"bytes":"MDZSeFJUWkhXVXNhRDdIRWR6MVRoYlhmUTdwWVNRNG4zNzhsMlZRS0dOYlN1SkUwZlFiek9OSkFBd2RDeG1NOUJJYWJLRVJzVWhQTm1NbWRmM2VTSnlZdHF3Y0ZpVUlMelh2M2ZjTklyV084c1RvRmdvaWxBMVUyV3hOZVcyZ2RnVVZEc0VXSjg4YVg4dExGSjk1cVlVN1VyTjljdGVjd1p0NlM1empoRDF0WFJUbWtZS1FvTjAyRm1XblFTSzN3UkM2VUhLM0txQXR4alAzWm1EMmp0dDR6Z3I2TWVVam9BamNPMGF6TW10VTRZdHYxUDhPUG1tU05hOThkN3RzdGF4eTZuYWNuSkJTdUZwT2h5SVhFN1BKMURoVWtMWHFZWW5FTnVucWRzd3BUdzVVREdEUzM0bVNQWUs4dm11YjNYOXVYSXU3Rk5jSmpBUlFUM1JWaFZydDI0UDdpNnhDckw2RmM0R2N1SEMxNGthdW5BVFVQUkhqR211Vm14SHN5enpCYnlPb25xVlVTREsxVg=="},"reversed_by":null,"systimestamp":{"long.timestamp-micros":"2215-07-28T23:47:01.795499Z"},"tcomment":null,"transaction_type_reference":{"long":400},"username":{"string":"WX40IVUWSP3NcHciWvqZ"}}}}`,
Expand Down
8 changes: 8 additions & 0 deletions pkg/geo/wkt/lex.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ func getKeywordToken(tokStr string) int {
return POLYGONZ
case "POLYGONZM":
return POLYGONZM
case "MULTIPOINT":
return MULTIPOINT
case "MULTIPOINTM":
return MULTIPOINTM
case "MULTIPOINTZ":
return MULTIPOINTZ
case "MULTIPOINTZM":
return MULTIPOINTZM
default:
return eof
}
Expand Down
196 changes: 176 additions & 20 deletions pkg/geo/wkt/wkt.y
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ type geomPair struct {
ends []int
}

func appendGeomPairs(p1 geomPair, p2 geomPair) geomPair {
if len(p1.ends) > 0 {
p1LastEnd := p1.ends[len(p1.ends)-1]
for i, _ := range p2.ends {
p2.ends[i] += p1LastEnd
}
}
return geomPair{append(p1.flatCoords, p2.flatCoords...), append(p1.ends, p2.ends...)}
}

%}

%union {
Expand All @@ -54,17 +64,26 @@ type geomPair struct {
%token <str> POINT POINTM POINTZ POINTZM
%token <str> LINESTRING LINESTRINGM LINESTRINGZ LINESTRINGZM
%token <str> POLYGON POLYGONM POLYGONZ POLYGONZM
%token <str> MULTIPOINT MULTIPOINTM MULTIPOINTZ MULTIPOINTZM
%token <str> EMPTY
//%token <str> MULTIPOINT MULTILINESTRING MULTIPOLYGON GEOMETRYCOLLECTION
//%token <str> MULTILINESTRING MULTIPOLYGON GEOMETRYCOLLECTION
%token <coord> NUM

%type <geom> geometry
%type <geom> point linestring polygon
%type <geom> point linestring polygon multipoint
%type <coordList> two_coords three_coords four_coords
%type <coordList> two_coords_point_with_parens three_coords_point_with_parens four_coords_point_with_parens
%type <coordList> two_coords_list three_coords_list four_coords_list
%type <coordList> two_coords_line three_coords_line four_coords_line
%type <pair> two_coords_ring three_coords_ring four_coords_ring
%type <pair> two_coords_ring_list three_coords_ring_list four_coords_ring_list
%type <coordList> two_coords_point three_coords_point four_coords_point
%type <coordList> three_coords_point_list four_coords_point_list
%type <pair> empty_point
%type <pair> two_coords_point_allowing_empty three_coords_point_allowing_empty four_coords_point_allowing_empty
%type <pair> two_coords_point_list_allowing_empty_points
%type <pair> three_coords_point_list_allowing_empty_points
%type <pair> four_coords_point_list_allowing_empty_points

%%

Expand All @@ -78,31 +97,32 @@ geometry:
point
| linestring
| polygon
| multipoint

point:
POINT '(' two_coords ')'
POINT two_coords_point_with_parens
{
$$ = geom.NewPointFlat(geom.XY, $3)
$$ = geom.NewPointFlat(geom.XY, $2)
}
| POINT '(' three_coords ')'
| POINT three_coords_point_with_parens
{
$$ = geom.NewPointFlat(geom.XYZ, $3)
$$ = geom.NewPointFlat(geom.XYZ, $2)
}
| POINT '(' four_coords ')'
| POINT four_coords_point_with_parens
{
$$ = geom.NewPointFlat(geom.XYZM, $3)
$$ = geom.NewPointFlat(geom.XYZM, $2)
}
| POINTM '(' three_coords ')'
| POINTM three_coords_point_with_parens
{
$$ = geom.NewPointFlat(geom.XYM, $3)
$$ = geom.NewPointFlat(geom.XYM, $2)
}
| POINTZ '(' three_coords ')'
| POINTZ three_coords_point_with_parens
{
$$ = geom.NewPointFlat(geom.XYZ, $3)
$$ = geom.NewPointFlat(geom.XYZ, $2)
}
| POINTZM '(' four_coords ')'
| POINTZM four_coords_point_with_parens
{
$$ = geom.NewPointFlat(geom.XYZM, $3)
$$ = geom.NewPointFlat(geom.XYZM, $2)
}
| POINT EMPTY
{
Expand Down Expand Up @@ -223,24 +243,66 @@ polygon:
$$ = geom.NewPolygon(geom.XYZM)
}

multipoint:
MULTIPOINT '(' two_coords_point_list_allowing_empty_points ')'
{
$$ = geom.NewMultiPointFlat(geom.XY, $3.flatCoords, geom.NewMultiPointFlatOptionWithEnds($3.ends))
}
| MULTIPOINT '(' three_coords_point_list ')'
{
$$ = geom.NewMultiPointFlat(geom.XYZ, $3)
}
| MULTIPOINT '(' four_coords_point_list ')'
{
$$ = geom.NewMultiPointFlat(geom.XYZM, $3)
}
| MULTIPOINTM '(' three_coords_point_list_allowing_empty_points ')'
{
$$ = geom.NewMultiPointFlat(geom.XYM, $3.flatCoords, geom.NewMultiPointFlatOptionWithEnds($3.ends))
}
| MULTIPOINTZ '(' three_coords_point_list_allowing_empty_points ')'
{
$$ = geom.NewMultiPointFlat(geom.XYZ, $3.flatCoords, geom.NewMultiPointFlatOptionWithEnds($3.ends))
}
| MULTIPOINTZM '(' four_coords_point_list_allowing_empty_points ')'
{
$$ = geom.NewMultiPointFlat(geom.XYZM, $3.flatCoords, geom.NewMultiPointFlatOptionWithEnds($3.ends))
}
| MULTIPOINT EMPTY
{
$$ = geom.NewMultiPoint(geom.XY)
}
| MULTIPOINTM EMPTY
{
$$ = geom.NewMultiPoint(geom.XYM)
}
| MULTIPOINTZ EMPTY
{
$$ = geom.NewMultiPoint(geom.XYZ)
}
| MULTIPOINTZM EMPTY
{
$$ = geom.NewMultiPoint(geom.XYZM)
}

two_coords_ring_list:
two_coords_ring_list ',' two_coords_ring
{
$$ = geomPair{append($1.flatCoords, $3.flatCoords...), append($1.ends, $1.ends[len($1.ends)-1] + $3.ends[0])}
$$ = appendGeomPairs($1, $3)
}
| two_coords_ring

three_coords_ring_list:
three_coords_ring_list ',' three_coords_ring
{
$$ = geomPair{append($1.flatCoords, $3.flatCoords...), append($1.ends, $1.ends[len($1.ends)-1] + $3.ends[0])}
$$ = appendGeomPairs($1, $3)
}
| three_coords_ring

four_coords_ring_list:
four_coords_ring_list ',' four_coords_ring
{
$$ = geomPair{append($1.flatCoords, $3.flatCoords...), append($1.ends, $1.ends[len($1.ends)-1] + $3.ends[0])}
$$ = appendGeomPairs($1, $3)
}
| four_coords_ring

Expand Down Expand Up @@ -290,26 +352,120 @@ four_coords_line:
}

two_coords_list:
two_coords ',' two_coords_list
two_coords_list ',' two_coords
{
$$ = append($1, $3...)
}
| two_coords

three_coords_list:
three_coords ',' three_coords_list
three_coords_list ',' three_coords
{
$$ = append($1, $3...)
}
| three_coords

four_coords_list:
four_coords ',' four_coords_list
four_coords_list ',' four_coords
{
$$ = append($1, $3...)
}
| four_coords

// NB: A two_coords_point_list is not required since a 2D list inside a MULTIPOINT is always allowed to have EMPTYs.

three_coords_point_list:
three_coords_point_list ',' three_coords_point
{
$$ = append($1, $3...)
}
| three_coords_point

four_coords_point_list:
four_coords_point_list ',' four_coords_point
{
$$ = append($1, $3...)
}
| four_coords_point

two_coords_point_list_allowing_empty_points:
two_coords_point_list_allowing_empty_points ',' two_coords_point_allowing_empty
{
$$ = appendGeomPairs($1, $3)
}
| two_coords_point_allowing_empty

three_coords_point_list_allowing_empty_points:
three_coords_point_list_allowing_empty_points ',' three_coords_point_allowing_empty
{
$$ = appendGeomPairs($1, $3)
}
| three_coords_point_allowing_empty

four_coords_point_list_allowing_empty_points:
four_coords_point_list_allowing_empty_points ',' four_coords_point_allowing_empty
{
$$ = appendGeomPairs($1, $3)
}
| four_coords_point_allowing_empty

two_coords_point_allowing_empty:
two_coords_point
{
$$ = geomPair{$1, []int{2}}
}
| empty_point

three_coords_point_allowing_empty:
three_coords_point
{
$$ = geomPair{$1, []int{3}}
}
| empty_point

four_coords_point_allowing_empty:
four_coords_point
{
$$ = geomPair{$1, []int{4}}
}
| empty_point

two_coords_point:
two_coords
| two_coords_point_with_parens

three_coords_point:
three_coords
| three_coords_point_with_parens

four_coords_point:
four_coords
| four_coords_point_with_parens

empty_point:
EMPTY
{
$$ = geomPair{nil, []int{0}}
}

two_coords_point_with_parens:
'(' two_coords ')'
{
$$ = $2
}

three_coords_point_with_parens:
'(' three_coords ')'
{
$$ = $2
}

four_coords_point_with_parens:
'(' four_coords ')'
{
$$ = $2
}

two_coords:
NUM NUM
{
Expand Down
Loading

0 comments on commit ef1ea06

Please sign in to comment.