From 87cffa692873d9ae1acfcbb4f3885f063b2e0f38 Mon Sep 17 00:00:00 2001 From: James Cor Date: Thu, 13 Oct 2022 11:14:07 -0700 Subject: [PATCH 01/14] handling small refactor of deserialize --- .../doltcore/sqle/index/prolly_fields.go | 14 ++++++++------ go/store/types/read_geometry.go | 12 ++++++------ go/store/types/write_geometry.go | 16 ++++++++-------- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/go/libraries/doltcore/sqle/index/prolly_fields.go b/go/libraries/doltcore/sqle/index/prolly_fields.go index 55b9af0d14..63a0bead3f 100644 --- a/go/libraries/doltcore/sqle/index/prolly_fields.go +++ b/go/libraries/doltcore/sqle/index/prolly_fields.go @@ -277,17 +277,19 @@ func deserializeGeometry(buf []byte) (v interface{}) { buf = buf[sql.EWKBHeaderSize:] switch typ { case sql.WKBPointID: - v, _ = sql.DeserializePoint(buf, false, srid) + v, _, _ = sql.DeserializePoint(buf, false, srid) case sql.WKBLineID: - v, _ = sql.DeserializeLine(buf, false, srid) + v, _, _ = sql.DeserializeLine(buf, false, srid) case sql.WKBPolyID: - v, _ = sql.DeserializePoly(buf, false, srid) + v, _, _ = sql.DeserializePoly(buf, false, srid) case sql.WKBMultiPointID: - v, _ = sql.DeserializeMPoint(buf, false, srid) + v, _, _ = sql.DeserializeMPoint(buf, false, srid) case sql.WKBMultiLineID: - v, _ = sql.DeserializeMLine(buf, false, srid) + v, _, _ = sql.DeserializeMLine(buf, false, srid) case sql.WKBMultiPolyID: - v, _ = sql.DeserializeMPoly(buf, false, srid) + v, _, _ = sql.DeserializeMPoly(buf, false, srid) + case sql.WKBGeomCollID: + v, _, _ = sql.DeserializeGeomColl(buf, false, srid) default: panic(fmt.Sprintf("unknown geometry type %d", typ)) } diff --git a/go/store/types/read_geometry.go b/go/store/types/read_geometry.go index 169eb20099..838282941a 100644 --- a/go/store/types/read_geometry.go +++ b/go/store/types/read_geometry.go @@ -149,7 +149,7 @@ func DeserializeWKBHeader(buf []byte) (bool, uint32, error) { } func DeserializePoint(buf []byte, isBig bool, srid uint32) sql.Point { - p, err := sql.DeserializePoint(buf, isBig, srid) + p, _, err := sql.DeserializePoint(buf, isBig, srid) if err != nil { panic(err) } @@ -157,7 +157,7 @@ func DeserializePoint(buf []byte, isBig bool, srid uint32) sql.Point { } func DeserializeLine(buf []byte, isBig bool, srid uint32) sql.LineString { - l, err := sql.DeserializeLine(buf, isBig, srid) + l, _, err := sql.DeserializeLine(buf, isBig, srid) if err != nil { panic(err) } @@ -165,7 +165,7 @@ func DeserializeLine(buf []byte, isBig bool, srid uint32) sql.LineString { } func DeserializePoly(buf []byte, isBig bool, srid uint32) sql.Polygon { - p, err := sql.DeserializePoly(buf, isBig, srid) + p, _, err := sql.DeserializePoly(buf, isBig, srid) if err != nil { panic(err) } @@ -173,7 +173,7 @@ func DeserializePoly(buf []byte, isBig bool, srid uint32) sql.Polygon { } func DeserializeMPoint(buf []byte, isBig bool, srid uint32) sql.MultiPoint { - p, err := sql.DeserializeMPoint(buf, isBig, srid) + p, _, err := sql.DeserializeMPoint(buf, isBig, srid) if err != nil { panic(err) } @@ -181,7 +181,7 @@ func DeserializeMPoint(buf []byte, isBig bool, srid uint32) sql.MultiPoint { } func DeserializeMLine(buf []byte, isBig bool, srid uint32) sql.MultiLineString { - p, err := sql.DeserializeMLine(buf, isBig, srid) + p, _, err := sql.DeserializeMLine(buf, isBig, srid) if err != nil { panic(err) } @@ -189,7 +189,7 @@ func DeserializeMLine(buf []byte, isBig bool, srid uint32) sql.MultiLineString { } func DeserializeMPoly(buf []byte, isBig bool, srid uint32) sql.MultiPolygon { - p, err := sql.DeserializeMPoly(buf, isBig, srid) + p, _, err := sql.DeserializeMPoly(buf, isBig, srid) if err != nil { panic(err) } diff --git a/go/store/types/write_geometry.go b/go/store/types/write_geometry.go index 1f83a09f17..21378a9c35 100644 --- a/go/store/types/write_geometry.go +++ b/go/store/types/write_geometry.go @@ -34,14 +34,14 @@ const ( ) const ( - WKBUnknown = sql.WKBUnknown - WKBPointID = sql.WKBPointID - WKBLineID = sql.WKBLineID - WKBPolyID = sql.WKBPolyID - WKBMultiPointID = sql.WKBMultiPointID - WKBMultiLineID = sql.WKBMultiLineID - WKBMultiPolyID = sql.WKBMultiPolyID - WKBGeomCollectionID = sql.WKBGeomCollectionID + WKBUnknown = sql.WKBUnknown + WKBPointID = sql.WKBPointID + WKBLineID = sql.WKBLineID + WKBPolyID = sql.WKBPolyID + WKBMultiPointID = sql.WKBMultiPointID + WKBMultiLineID = sql.WKBMultiLineID + WKBMultiPolyID = sql.WKBMultiPolyID + WKBGeomCollID = sql.WKBGeomCollID ) // TODO: all methods here just defer to their SQL equivalents, and assume we always receive good data From 4963c1c31261847e7975e96da606154c4e36de15 Mon Sep 17 00:00:00 2001 From: James Cor Date: Sun, 16 Oct 2022 21:32:49 -0700 Subject: [PATCH 02/14] serialize and deserailize methods --- go/store/types/geometry_collection.go | 161 ++++++++++++++++++++++++++ go/store/types/read_geometry.go | 58 ++++++++++ go/store/types/write_geometry.go | 4 + 3 files changed, 223 insertions(+) create mode 100644 go/store/types/geometry_collection.go diff --git a/go/store/types/geometry_collection.go b/go/store/types/geometry_collection.go new file mode 100644 index 0000000000..c53de02c03 --- /dev/null +++ b/go/store/types/geometry_collection.go @@ -0,0 +1,161 @@ +// Copyright 2022 Dolthub, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "context" + "errors" + "fmt" + "strconv" + "strings" + + "github.com/dolthub/dolt/go/store/hash" +) + +// GeomColl is a Noms Value wrapper around a string. +type GeomColl struct { + SRID uint32 + Geometries []Value // not sure if worth replacing with types version of sql.GeometryValue +} + +// Value interface +func (v GeomColl) Value(ctx context.Context) (Value, error) { + return v, nil +} + +func (v GeomColl) Equals(other Value) bool { + // Compare types + v2, ok := other.(GeomColl) + if !ok { + return false + } + // Compare SRID + if v.SRID != v2.SRID { + return false + } + // Compare lengths of geometries + if len(v.Geometries) != len(v2.Geometries) { + return false + } + // Compare each geometry + for i := 0; i < len(v.Geometries); i++ { + if !v.Geometries[i].Equals(v2.Geometries[i]) { + return false + } + } + return true +} + +func (v GeomColl) Less(nbf *NomsBinFormat, other LesserValuable) (bool, error) { + // Compare types + v2, ok := other.(GeomColl) + if !ok { + return GeometryCollectionKind < other.Kind(), nil + } + // Compare SRID + if v.SRID != v2.SRID { + return v.SRID < v2.SRID, nil + } + // Get shorter length + var n int + len1 := len(v.Geometries) + len2 := len(v2.Geometries) + if len1 < len2 { + n = len1 + } else { + n = len2 + } + // Compare each polygon until there is one that is less + for i := 0; i < n; i++ { + if !v.Geometries[i].Equals(v2.Geometries[i]) { + return v.Geometries[i].Less(nbf, v2.Geometries[i]) + } + } + // Determine based off length + return len1 < len2, nil +} + +func (v GeomColl) Hash(nbf *NomsBinFormat) (hash.Hash, error) { + return getHash(v, nbf) +} + +func (v GeomColl) isPrimitive() bool { + return true +} + +func (v GeomColl) walkRefs(nbf *NomsBinFormat, cb RefCallback) error { + return nil +} + +func (v GeomColl) typeOf() (*Type, error) { + return PrimitiveTypeMap[GeometryCollectionKind], nil +} + +func (v GeomColl) Kind() NomsKind { + return GeometryCollectionKind +} + +func (v GeomColl) valueReadWriter() ValueReadWriter { + return nil +} + +func (v GeomColl) writeTo(w nomsWriter, nbf *NomsBinFormat) error { + err := GeometryCollectionKind.writeTo(w, nbf) + if err != nil { + return err + } + + w.writeString(string(SerializeGeomColl(v))) + return nil +} + +func readGeomColl(nbf *NomsBinFormat, b *valueDecoder) (GeomColl, error) { + buf := []byte(b.ReadString()) + srid, _, geomType, err := DeserializeEWKBHeader(buf) + if err != nil { + return GeomColl{}, err + } + if geomType != WKBGeomCollID { + return GeomColl{}, errors.New("not a geometry collection") + } + buf = buf[EWKBHeaderSize:] + return DeserializeTypesGeomColl(buf, false, srid), nil +} + +func (v GeomColl) readFrom(nbf *NomsBinFormat, b *binaryNomsReader) (Value, error) { + buf := []byte(b.ReadString()) + srid, _, geomType, err := DeserializeEWKBHeader(buf) + if err != nil { + return GeomColl{}, err + } + if geomType != WKBGeomCollID { + return GeomColl{}, errors.New("not a geometry collection") + } + buf = buf[EWKBHeaderSize:] + return DeserializeTypesGeomColl(buf, false, srid), nil +} + +func (v GeomColl) skip(nbf *NomsBinFormat, b *binaryNomsReader) { + b.skipString() +} + +func (v GeomColl) HumanReadableString() string { + geoms := make([]string, len(v.Geometries)) + for i, l := range v.Geometries { + geoms[i] = l.HumanReadableString() + } + s := fmt.Sprintf("SRID: %d GEOMETRIES(%s)", v.SRID, strings.Join(geoms, ",")) + return strconv.Quote(s) +} diff --git a/go/store/types/read_geometry.go b/go/store/types/read_geometry.go index 838282941a..af552dad34 100644 --- a/go/store/types/read_geometry.go +++ b/go/store/types/read_geometry.go @@ -75,6 +75,29 @@ func ConvertTypesMultiPolygonToSQLMultiPolygon(p MultiPolygon) sql.MultiPolygon return sql.MultiPolygon{SRID: p.SRID, Polygons: polys} } +func ConvertTypesGeomCollToSQLGeomColl(g GeomColl) sql.GeomColl { + geoms := make([]sql.GeometryValue, len(g.Geometries)) + for i, geom := range g.Geometries { + switch geo := geom.(type) { + case Point: + geoms[i] = ConvertTypesPointToSQLPoint(geo) + case LineString: + geoms[i] = ConvertTypesLineStringToSQLLineString(geo) + case Polygon: + geoms[i] = ConvertTypesPolygonToSQLPolygon(geo) + case MultiPoint: + geoms[i] = ConvertTypesMultiPointToSQLMultiPoint(geo) + case MultiLineString: + geoms[i] = ConvertTypesMultiLineStringToSQLMultiLineString(geo) + case MultiPolygon: + geoms[i] = ConvertTypesMultiPolygonToSQLMultiPolygon(geo) + case GeomColl: + geoms[i] = ConvertTypesGeomCollToSQLGeomColl(geo) + } + } + return sql.GeomColl{SRID: g.SRID, Geoms: geoms} +} + func ConvertSQLGeometryToTypesGeometry(p interface{}) Value { switch inner := p.(type) { case sql.Point: @@ -138,6 +161,29 @@ func ConvertSQLMultiPolygonToTypesMultiPolygon(p sql.MultiPolygon) MultiPolygon return MultiPolygon{SRID: p.SRID, Polygons: polys} } +func ConvertSQLGeomCollToTypesGeomColl(g sql.GeomColl) GeomColl { + geoms := make([]Value, len(g.Geoms)) + for i, geom := range g.Geoms { + switch geo := geom.(type) { + case sql.Point: + geoms[i] = ConvertSQLPointToTypesPoint(geo) + case sql.LineString: + geoms[i] = ConvertSQLLineStringToTypesLineString(geo) + case sql.Polygon: + geoms[i] = ConvertSQLPolygonToTypesPolygon(geo) + case sql.MultiPoint: + geoms[i] = ConvertSQLMultiPointToTypesMultiPoint(geo) + case sql.MultiLineString: + geoms[i] = ConvertSQLMultiLineStringToTypesMultiLineString(geo) + case sql.MultiPolygon: + geoms[i] = ConvertSQLMultiPolygonToTypesMultiPolygon(geo) + case sql.GeomColl: + geoms[i] = ConvertSQLGeomCollToTypesGeomColl(geo) + } + } + return GeomColl{SRID: g.SRID, Geometries: geoms} +} + // TODO: all methods here just defer to their SQL equivalents, and assume we always receive good data func DeserializeEWKBHeader(buf []byte) (uint32, bool, uint32, error) { @@ -196,6 +242,14 @@ func DeserializeMPoly(buf []byte, isBig bool, srid uint32) sql.MultiPolygon { return p } +func DeserializeGeomColl(buf []byte, isBig bool, srid uint32) sql.GeomColl { + g, _, err := sql.DeserializeGeomColl(buf, isBig, srid) + if err != nil { + panic(err) + } + return g +} + // TODO: noms needs results to be in types func DeserializeTypesPoint(buf []byte, isBig bool, srid uint32) Point { @@ -221,3 +275,7 @@ func DeserializeTypesMLine(buf []byte, isBig bool, srid uint32) MultiLineString func DeserializeTypesMPoly(buf []byte, isBig bool, srid uint32) MultiPolygon { return ConvertSQLMultiPolygonToTypesMultiPolygon(DeserializeMPoly(buf, isBig, srid)) } + +func DeserializeTypesGeomColl(buf []byte, isBig bool, srid uint32) GeomColl { + return ConvertSQLGeomCollToTypesGeomColl(DeserializeGeomColl(buf, isBig, srid)) +} diff --git a/go/store/types/write_geometry.go b/go/store/types/write_geometry.go index 21378a9c35..ded388fb9c 100644 --- a/go/store/types/write_geometry.go +++ b/go/store/types/write_geometry.go @@ -73,3 +73,7 @@ func SerializeMultiLineString(p MultiLineString) []byte { func SerializeMultiPolygon(p MultiPolygon) []byte { return ConvertTypesMultiPolygonToSQLMultiPolygon(p).Serialize() } + +func SerializeGeomColl(g GeomColl) []byte { + return ConvertTypesGeomCollToSQLGeomColl(g).Serialize() +} From 0b60662a4df9c1967ffb4339ea6173d9c71860e3 Mon Sep 17 00:00:00 2001 From: James Cor Date: Sun, 16 Oct 2022 21:57:30 -0700 Subject: [PATCH 03/14] aaa --- .../doltcore/schema/typeinfo/geometry.go | 4 + .../doltcore/schema/typeinfo/typeinfo.go | 108 +++++++++--------- go/libraries/doltcore/sqle/sqlfmt/row_fmt.go | 9 +- go/store/types/noms_kind.go | 65 ++++++----- go/store/types/value_decoder.go | 5 + 5 files changed, 107 insertions(+), 84 deletions(-) diff --git a/go/libraries/doltcore/schema/typeinfo/geometry.go b/go/libraries/doltcore/schema/typeinfo/geometry.go index c6a9decd96..cde355190f 100644 --- a/go/libraries/doltcore/schema/typeinfo/geometry.go +++ b/go/libraries/doltcore/schema/typeinfo/geometry.go @@ -93,6 +93,10 @@ func (ti *geometryType) ReadFrom(nbf *types.NomsBinFormat, reader types.CodecRea if val, err = reader.ReadMultiPolygon(); err != nil { return nil, err } + case types.GeometryCollectionKind: + if val, err = reader.ReadGeomColl(); err != nil { + return nil, err + } case types.GeometryKind: // Note: GeometryKind is no longer written // included here for backward compatibility diff --git a/go/libraries/doltcore/schema/typeinfo/typeinfo.go b/go/libraries/doltcore/schema/typeinfo/typeinfo.go index 595d7647d8..db38436996 100644 --- a/go/libraries/doltcore/schema/typeinfo/typeinfo.go +++ b/go/libraries/doltcore/schema/typeinfo/typeinfo.go @@ -28,61 +28,63 @@ import ( type Identifier string const ( - UnknownTypeIdentifier Identifier = "unknown" - BitTypeIdentifier Identifier = "bit" - BlobStringTypeIdentifier Identifier = "blobstring" - BoolTypeIdentifier Identifier = "bool" - DatetimeTypeIdentifier Identifier = "datetime" - DecimalTypeIdentifier Identifier = "decimal" - EnumTypeIdentifier Identifier = "enum" - FloatTypeIdentifier Identifier = "float" - JSONTypeIdentifier Identifier = "json" - InlineBlobTypeIdentifier Identifier = "inlineblob" - IntTypeIdentifier Identifier = "int" - SetTypeIdentifier Identifier = "set" - TimeTypeIdentifier Identifier = "time" - TupleTypeIdentifier Identifier = "tuple" - UintTypeIdentifier Identifier = "uint" - UuidTypeIdentifier Identifier = "uuid" - VarBinaryTypeIdentifier Identifier = "varbinary" - VarStringTypeIdentifier Identifier = "varstring" - YearTypeIdentifier Identifier = "year" - GeometryTypeIdentifier Identifier = "geometry" - PointTypeIdentifier Identifier = "point" - LineStringTypeIdentifier Identifier = "linestring" - PolygonTypeIdentifier Identifier = "polygon" - MultiPointTypeIdentifier Identifier = "multipoint" - MultiLineStringTypeIdentifier Identifier = "multilinestring" - MultiPolygonTypeIdentifier Identifier = "multipolygon" + UnknownTypeIdentifier Identifier = "unknown" + BitTypeIdentifier Identifier = "bit" + BlobStringTypeIdentifier Identifier = "blobstring" + BoolTypeIdentifier Identifier = "bool" + DatetimeTypeIdentifier Identifier = "datetime" + DecimalTypeIdentifier Identifier = "decimal" + EnumTypeIdentifier Identifier = "enum" + FloatTypeIdentifier Identifier = "float" + JSONTypeIdentifier Identifier = "json" + InlineBlobTypeIdentifier Identifier = "inlineblob" + IntTypeIdentifier Identifier = "int" + SetTypeIdentifier Identifier = "set" + TimeTypeIdentifier Identifier = "time" + TupleTypeIdentifier Identifier = "tuple" + UintTypeIdentifier Identifier = "uint" + UuidTypeIdentifier Identifier = "uuid" + VarBinaryTypeIdentifier Identifier = "varbinary" + VarStringTypeIdentifier Identifier = "varstring" + YearTypeIdentifier Identifier = "year" + GeometryTypeIdentifier Identifier = "geometry" + PointTypeIdentifier Identifier = "point" + LineStringTypeIdentifier Identifier = "linestring" + PolygonTypeIdentifier Identifier = "polygon" + MultiPointTypeIdentifier Identifier = "multipoint" + MultiLineStringTypeIdentifier Identifier = "multilinestring" + MultiPolygonTypeIdentifier Identifier = "multipolygon" + GeometryCollectionTypeIdentifier Identifier = "geometrycollection" ) var Identifiers = map[Identifier]struct{}{ - UnknownTypeIdentifier: {}, - BitTypeIdentifier: {}, - BlobStringTypeIdentifier: {}, - BoolTypeIdentifier: {}, - DatetimeTypeIdentifier: {}, - DecimalTypeIdentifier: {}, - EnumTypeIdentifier: {}, - FloatTypeIdentifier: {}, - JSONTypeIdentifier: {}, - InlineBlobTypeIdentifier: {}, - IntTypeIdentifier: {}, - SetTypeIdentifier: {}, - TimeTypeIdentifier: {}, - TupleTypeIdentifier: {}, - UintTypeIdentifier: {}, - UuidTypeIdentifier: {}, - VarBinaryTypeIdentifier: {}, - VarStringTypeIdentifier: {}, - YearTypeIdentifier: {}, - GeometryTypeIdentifier: {}, - PointTypeIdentifier: {}, - LineStringTypeIdentifier: {}, - PolygonTypeIdentifier: {}, - MultiPointTypeIdentifier: {}, - MultiLineStringTypeIdentifier: {}, - MultiPolygonTypeIdentifier: {}, + UnknownTypeIdentifier: {}, + BitTypeIdentifier: {}, + BlobStringTypeIdentifier: {}, + BoolTypeIdentifier: {}, + DatetimeTypeIdentifier: {}, + DecimalTypeIdentifier: {}, + EnumTypeIdentifier: {}, + FloatTypeIdentifier: {}, + JSONTypeIdentifier: {}, + InlineBlobTypeIdentifier: {}, + IntTypeIdentifier: {}, + SetTypeIdentifier: {}, + TimeTypeIdentifier: {}, + TupleTypeIdentifier: {}, + UintTypeIdentifier: {}, + UuidTypeIdentifier: {}, + VarBinaryTypeIdentifier: {}, + VarStringTypeIdentifier: {}, + YearTypeIdentifier: {}, + GeometryTypeIdentifier: {}, + PointTypeIdentifier: {}, + LineStringTypeIdentifier: {}, + PolygonTypeIdentifier: {}, + MultiPointTypeIdentifier: {}, + MultiLineStringTypeIdentifier: {}, + MultiPolygonTypeIdentifier: {}, + GeometryCollectionTypeIdentifier: {}, } // TypeInfo is an interface used for encoding type information. @@ -183,6 +185,8 @@ func FromSqlType(sqlType sql.Type) (TypeInfo, error) { return &multilinestringType{}, nil case sql.MultiPolygonType{}.String(): return &multipolygonType{}, nil + case sql.GeomCollType{}.String(): + return &geomcollType{}, nil case sql.GeometryType{}.String(): return &geometryType{sqlGeometryType: sqlType.(sql.GeometryType)}, nil default: diff --git a/go/libraries/doltcore/sqle/sqlfmt/row_fmt.go b/go/libraries/doltcore/sqle/sqlfmt/row_fmt.go index 9f0fa55b04..52c77fdedd 100644 --- a/go/libraries/doltcore/sqle/sqlfmt/row_fmt.go +++ b/go/libraries/doltcore/sqle/sqlfmt/row_fmt.go @@ -534,7 +534,14 @@ func interfaceValueAsSqlString(ti typeinfo.TypeInfo, value interface{}) (string, return "", fmt.Errorf("typeinfo.VarStringTypeIdentifier is not types.String") } return quoteAndEscapeString(string(s)), nil - case typeinfo.GeometryTypeIdentifier, typeinfo.PointTypeIdentifier, typeinfo.LineStringTypeIdentifier, typeinfo.PolygonTypeIdentifier, typeinfo.MultiPointTypeIdentifier, typeinfo.MultiLineStringTypeIdentifier, typeinfo.MultiPolygonTypeIdentifier: + case typeinfo.GeometryTypeIdentifier, + typeinfo.PointTypeIdentifier, + typeinfo.LineStringTypeIdentifier, + typeinfo.PolygonTypeIdentifier, + typeinfo.MultiPointTypeIdentifier, + typeinfo.MultiLineStringTypeIdentifier, + typeinfo.MultiPolygonTypeIdentifier, + typeinfo.GeometryCollectionTypeIdentifier: return singleQuote + str + singleQuote, nil default: return str, nil diff --git a/go/store/types/noms_kind.go b/go/store/types/noms_kind.go index 577074d067..b009c84c45 100644 --- a/go/store/types/noms_kind.go +++ b/go/store/types/noms_kind.go @@ -106,6 +106,7 @@ func init() { KindToType[MultiPointKind] = MultiPoint{} KindToType[MultiLineStringKind] = MultiLineString{} KindToType[MultiPolygonKind] = MultiPolygon{} + KindToType[GeometryCollectionKind] = GeomColl{} SupportedKinds[BlobKind] = true SupportedKinds[BoolKind] = true @@ -137,6 +138,7 @@ func init() { SupportedKinds[MultiPointKind] = true SupportedKinds[MultiLineStringKind] = true SupportedKinds[MultiPolygonKind] = true + SupportedKinds[GeometryCollectionKind] = true if serial.MessageTypesKind != int(SerialMessageKind) { panic("internal error: serial.MessageTypesKind != SerialMessageKind") @@ -146,37 +148,38 @@ func init() { var KindToTypeSlice []Value var KindToString = map[NomsKind]string{ - UnknownKind: "unknown", - BlobKind: "Blob", - BoolKind: "Bool", - CycleKind: "Cycle", - ListKind: "List", - MapKind: "Map", - FloatKind: "Float", - RefKind: "Ref", - SetKind: "Set", - StructKind: "Struct", - StringKind: "String", - TypeKind: "Type", - UnionKind: "Union", - ValueKind: "Value", - UUIDKind: "UUID", - IntKind: "Int", - UintKind: "Uint", - NullKind: "Null", - TupleKind: "Tuple", - InlineBlobKind: "InlineBlob", - TimestampKind: "Timestamp", - DecimalKind: "Decimal", - JSONKind: "JSON", - GeometryKind: "Geometry", - PointKind: "Point", - LineStringKind: "LineString", - PolygonKind: "Polygon", - SerialMessageKind: "SerialMessage", - MultiPointKind: "MultiPoint", - MultiLineStringKind: "MultiLineString", - MultiPolygonKind: "MultiPolygon", + UnknownKind: "unknown", + BlobKind: "Blob", + BoolKind: "Bool", + CycleKind: "Cycle", + ListKind: "List", + MapKind: "Map", + FloatKind: "Float", + RefKind: "Ref", + SetKind: "Set", + StructKind: "Struct", + StringKind: "String", + TypeKind: "Type", + UnionKind: "Union", + ValueKind: "Value", + UUIDKind: "UUID", + IntKind: "Int", + UintKind: "Uint", + NullKind: "Null", + TupleKind: "Tuple", + InlineBlobKind: "InlineBlob", + TimestampKind: "Timestamp", + DecimalKind: "Decimal", + JSONKind: "JSON", + GeometryKind: "Geometry", + PointKind: "Point", + LineStringKind: "LineString", + PolygonKind: "Polygon", + SerialMessageKind: "SerialMessage", + MultiPointKind: "MultiPoint", + MultiLineStringKind: "MultiLineString", + MultiPolygonKind: "MultiPolygon", + GeometryCollectionKind: "GeometryCollection", } // String returns the name of the kind. diff --git a/go/store/types/value_decoder.go b/go/store/types/value_decoder.go index 1e990b7af7..15184d28c2 100644 --- a/go/store/types/value_decoder.go +++ b/go/store/types/value_decoder.go @@ -53,6 +53,7 @@ type CodecReader interface { ReadMultiPoint() (MultiPoint, error) ReadMultiLineString() (MultiLineString, error) ReadMultiPolygon() (MultiPolygon, error) + ReadGeomColl() (GeomColl, error) ReadBlob() (Blob, error) ReadJSON() (JSON, error) } @@ -115,6 +116,10 @@ func (r *valueDecoder) ReadMultiPolygon() (MultiPolygon, error) { return readMultiPolygon(nil, r) } +func (r *valueDecoder) ReadGeomColl() (GeomColl, error) { + return readGeomColl(nil, r) +} + func (r *valueDecoder) ReadJSON() (JSON, error) { return readJSON(r.vrw.Format(), r) } From 605bd64d2aab9abee27a952de34d80b12b9a8d92 Mon Sep 17 00:00:00 2001 From: James Cor Date: Sun, 16 Oct 2022 22:03:38 -0700 Subject: [PATCH 04/14] adding type info --- .../schema/typeinfo/geometry_collection.go | 231 ++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 go/libraries/doltcore/schema/typeinfo/geometry_collection.go diff --git a/go/libraries/doltcore/schema/typeinfo/geometry_collection.go b/go/libraries/doltcore/schema/typeinfo/geometry_collection.go new file mode 100644 index 0000000000..8f56e0c6f7 --- /dev/null +++ b/go/libraries/doltcore/schema/typeinfo/geometry_collection.go @@ -0,0 +1,231 @@ +// Copyright 2020 Dolthub, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package typeinfo + +import ( + "context" + "fmt" + "strconv" + + "github.com/dolthub/go-mysql-server/sql" + + "github.com/dolthub/dolt/go/store/types" +) + +// This is a dolt implementation of the MySQL type Point, thus most of the functionality +// within is directly reliant on the go-mysql-server implementation. +type geomcollType struct { + sqlGeomCollType sql.GeomCollType +} + +var _ TypeInfo = (*geomcollType)(nil) + +var GeomCollType = &geomcollType{sql.GeomCollType{}} + +// ConvertNomsValueToValue implements TypeInfo interface. +func (ti *geomcollType) ConvertNomsValueToValue(v types.Value) (interface{}, error) { + // Check for null + if _, ok := v.(types.Null); ok || v == nil { + return nil, nil + } + // Expect a types.GeomColl, return a sql.GeomColl + if val, ok := v.(types.GeomColl); ok { + return types.ConvertTypesGeomCollToSQLGeomColl(val), nil + } + + return nil, fmt.Errorf(`"%v" cannot convert NomsKind "%v" to a value`, ti.String(), v.Kind()) +} + +// ReadFrom reads a go value from a noms types.CodecReader directly +func (ti *geomcollType) ReadFrom(nbf *types.NomsBinFormat, reader types.CodecReader) (interface{}, error) { + k := reader.ReadKind() + switch k { + case types.GeometryCollectionKind: + p, err := reader.ReadGeomColl() + if err != nil { + return nil, err + } + return ti.ConvertNomsValueToValue(p) + case types.NullKind: + return nil, nil + } + + return nil, fmt.Errorf(`"%v" cannot convert NomsKind "%v" to a value`, ti.String(), k) +} + +// ConvertValueToNomsValue implements TypeInfo interface. +func (ti *geomcollType) ConvertValueToNomsValue(ctx context.Context, vrw types.ValueReadWriter, v interface{}) (types.Value, error) { + // Check for null + if v == nil { + return types.NullValue, nil + } + + // Convert to sql.GeomColl + geomColl, err := ti.sqlGeomCollType.Convert(v) + if err != nil { + return nil, err + } + + return types.ConvertSQLGeomCollToTypesGeomColl(geomColl.(sql.GeomColl)), nil +} + +// Equals implements TypeInfo interface. +func (ti *geomcollType) Equals(other TypeInfo) bool { + if other == nil { + return false + } + if o, ok := other.(*geomcollType); ok { + // if either ti or other has defined SRID, then check SRID value; otherwise, + return (!ti.sqlGeomCollType.DefinedSRID && !o.sqlGeomCollType.DefinedSRID) || ti.sqlGeomCollType.SRID == o.sqlGeomCollType.SRID + } + return false +} + +// FormatValue implements TypeInfo interface. +func (ti *geomcollType) FormatValue(v types.Value) (*string, error) { + if val, ok := v.(types.GeomColl); ok { + resStr := string(types.SerializeGeomColl(val)) + return &resStr, nil + } + if _, ok := v.(types.Null); ok || v == nil { + return nil, nil + } + + return nil, fmt.Errorf(`"%v" has unexpectedly encountered a value of type "%T" from embedded type`, ti.String(), v.Kind()) +} + +// GetTypeIdentifier implements TypeInfo interface. +func (ti *geomcollType) GetTypeIdentifier() Identifier { + return GeometryCollectionTypeIdentifier +} + +// GetTypeParams implements TypeInfo interface. +func (ti *geomcollType) GetTypeParams() map[string]string { + return map[string]string{"SRID": strconv.FormatUint(uint64(ti.sqlGeomCollType.SRID), 10), + "DefinedSRID": strconv.FormatBool(ti.sqlGeomCollType.DefinedSRID)} +} + +// IsValid implements TypeInfo interface. +func (ti *geomcollType) IsValid(v types.Value) bool { + if _, ok := v.(types.GeomColl); ok { + return true + } + if _, ok := v.(types.Null); ok || v == nil { + return true + } + return false +} + +// NomsKind implements TypeInfo interface. +func (ti *geomcollType) NomsKind() types.NomsKind { + return types.GeometryCollectionKind +} + +// Promote implements TypeInfo interface. +func (ti *geomcollType) Promote() TypeInfo { + return &geomcollType{ti.sqlGeomCollType.Promote().(sql.GeomCollType)} +} + +// String implements TypeInfo interface. +func (ti *geomcollType) String() string { + return "GeometryCollection" +} + +// ToSqlType implements TypeInfo interface. +func (ti *geomcollType) ToSqlType() sql.Type { + return ti.sqlGeomCollType +} + +// geomcollTypeConverter is an internal function for GetTypeConverter that handles the specific type as the source TypeInfo. +func geomcollTypeConverter(ctx context.Context, src *geomcollType, destTi TypeInfo) (tc TypeConverter, needsConversion bool, err error) { + switch dest := destTi.(type) { + case *bitType: + return func(ctx context.Context, vrw types.ValueReadWriter, v types.Value) (types.Value, error) { + return types.Uint(0), nil + }, true, nil + case *blobStringType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *boolType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *datetimeType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *decimalType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *enumType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *floatType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geometryType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *inlineBlobType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *intType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *jsonType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *linestringType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *multilinestringType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *multipointType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *multipolygonType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *pointType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *polygonType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *setType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *timeType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *uintType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *uuidType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *varBinaryType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *varStringType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *yearType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + default: + return nil, false, UnhandledTypeConversion.New(src.String(), destTi.String()) + } +} + +func CreateGeomCollTypeFromParams(params map[string]string) (TypeInfo, error) { + var ( + err error + sridVal uint64 + def bool + ) + if s, ok := params["SRID"]; ok { + sridVal, err = strconv.ParseUint(s, 10, 32) + if err != nil { + return nil, err + } + } + if d, ok := params["DefinedSRID"]; ok { + def, err = strconv.ParseBool(d) + if err != nil { + return nil, err + } + } + + return &geomcollType{sqlGeomCollType: sql.GeomCollType{SRID: uint32(sridVal), DefinedSRID: def}}, nil +} From ae90ad0d1d021531c489757cad7a9ea26a8b4c8c Mon Sep 17 00:00:00 2001 From: James Cor Date: Sun, 16 Oct 2022 22:09:57 -0700 Subject: [PATCH 05/14] adding conversions --- go/libraries/doltcore/schema/typeinfo/bit.go | 2 ++ go/libraries/doltcore/schema/typeinfo/blobstring.go | 2 ++ go/libraries/doltcore/schema/typeinfo/bool.go | 2 ++ go/libraries/doltcore/schema/typeinfo/datetime.go | 2 ++ go/libraries/doltcore/schema/typeinfo/decimal.go | 2 ++ go/libraries/doltcore/schema/typeinfo/enum.go | 2 ++ go/libraries/doltcore/schema/typeinfo/float.go | 2 ++ go/libraries/doltcore/schema/typeinfo/geometry.go | 2 ++ go/libraries/doltcore/schema/typeinfo/geometry_collection.go | 4 ++-- go/libraries/doltcore/schema/typeinfo/inlineblob.go | 2 ++ go/libraries/doltcore/schema/typeinfo/int.go | 2 ++ go/libraries/doltcore/schema/typeinfo/json.go | 2 ++ go/libraries/doltcore/schema/typeinfo/linestring.go | 2 ++ go/libraries/doltcore/schema/typeinfo/multilinestring.go | 2 ++ go/libraries/doltcore/schema/typeinfo/multipoint.go | 2 ++ go/libraries/doltcore/schema/typeinfo/multipolygon.go | 2 ++ go/libraries/doltcore/schema/typeinfo/point.go | 2 ++ go/libraries/doltcore/schema/typeinfo/polygon.go | 2 ++ go/libraries/doltcore/schema/typeinfo/set.go | 2 ++ go/libraries/doltcore/schema/typeinfo/time.go | 2 ++ go/libraries/doltcore/schema/typeinfo/typeconverter.go | 2 ++ go/libraries/doltcore/schema/typeinfo/uint.go | 2 ++ go/libraries/doltcore/schema/typeinfo/uuid.go | 2 ++ go/libraries/doltcore/schema/typeinfo/varbinary.go | 2 ++ go/libraries/doltcore/schema/typeinfo/varstring.go | 2 ++ go/libraries/doltcore/schema/typeinfo/year.go | 2 ++ 26 files changed, 52 insertions(+), 2 deletions(-) diff --git a/go/libraries/doltcore/schema/typeinfo/bit.go b/go/libraries/doltcore/schema/typeinfo/bit.go index 3a02a82f45..e9f882a24f 100644 --- a/go/libraries/doltcore/schema/typeinfo/bit.go +++ b/go/libraries/doltcore/schema/typeinfo/bit.go @@ -208,6 +208,8 @@ func bitTypeConverter(ctx context.Context, src *bitType, destTi TypeInfo) (tc Ty return wrapIsValid(dest.IsValid, src, dest) case *floatType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: diff --git a/go/libraries/doltcore/schema/typeinfo/blobstring.go b/go/libraries/doltcore/schema/typeinfo/blobstring.go index 15ad5aa097..c866a331e7 100644 --- a/go/libraries/doltcore/schema/typeinfo/blobstring.go +++ b/go/libraries/doltcore/schema/typeinfo/blobstring.go @@ -238,6 +238,8 @@ func blobStringTypeConverter(ctx context.Context, src *blobStringType, destTi Ty return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *floatType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: diff --git a/go/libraries/doltcore/schema/typeinfo/bool.go b/go/libraries/doltcore/schema/typeinfo/bool.go index 9c16851bc9..0f2bf8f33a 100644 --- a/go/libraries/doltcore/schema/typeinfo/bool.go +++ b/go/libraries/doltcore/schema/typeinfo/bool.go @@ -215,6 +215,8 @@ func boolTypeConverter(ctx context.Context, src *boolType, destTi TypeInfo) (tc return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *floatType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: diff --git a/go/libraries/doltcore/schema/typeinfo/datetime.go b/go/libraries/doltcore/schema/typeinfo/datetime.go index 76525989cf..fc4ae2c106 100644 --- a/go/libraries/doltcore/schema/typeinfo/datetime.go +++ b/go/libraries/doltcore/schema/typeinfo/datetime.go @@ -219,6 +219,8 @@ func datetimeTypeConverter(ctx context.Context, src *datetimeType, destTi TypeIn return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *floatType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: diff --git a/go/libraries/doltcore/schema/typeinfo/decimal.go b/go/libraries/doltcore/schema/typeinfo/decimal.go index aa82501731..f48d460b65 100644 --- a/go/libraries/doltcore/schema/typeinfo/decimal.go +++ b/go/libraries/doltcore/schema/typeinfo/decimal.go @@ -243,6 +243,8 @@ func decimalTypeConverter(ctx context.Context, src *decimalType, destTi TypeInfo }, true, nil case *floatType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: diff --git a/go/libraries/doltcore/schema/typeinfo/enum.go b/go/libraries/doltcore/schema/typeinfo/enum.go index aebb75ae41..e7ceb8d04a 100644 --- a/go/libraries/doltcore/schema/typeinfo/enum.go +++ b/go/libraries/doltcore/schema/typeinfo/enum.go @@ -225,6 +225,8 @@ func enumTypeConverter(ctx context.Context, src *enumType, destTi TypeInfo) (tc }, true, nil case *floatType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: diff --git a/go/libraries/doltcore/schema/typeinfo/float.go b/go/libraries/doltcore/schema/typeinfo/float.go index 390fdf149c..30c21062f1 100644 --- a/go/libraries/doltcore/schema/typeinfo/float.go +++ b/go/libraries/doltcore/schema/typeinfo/float.go @@ -249,6 +249,8 @@ func floatTypeConverter(ctx context.Context, src *floatType, destTi TypeInfo) (t }, true, nil case *floatType: return wrapIsValid(dest.IsValid, src, dest) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: diff --git a/go/libraries/doltcore/schema/typeinfo/geometry.go b/go/libraries/doltcore/schema/typeinfo/geometry.go index cde355190f..1cfb5b79cf 100644 --- a/go/libraries/doltcore/schema/typeinfo/geometry.go +++ b/go/libraries/doltcore/schema/typeinfo/geometry.go @@ -252,6 +252,8 @@ func geometryTypeConverter(ctx context.Context, src *geometryType, destTi TypeIn return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *floatType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: diff --git a/go/libraries/doltcore/schema/typeinfo/geometry_collection.go b/go/libraries/doltcore/schema/typeinfo/geometry_collection.go index 8f56e0c6f7..3c25c99309 100644 --- a/go/libraries/doltcore/schema/typeinfo/geometry_collection.go +++ b/go/libraries/doltcore/schema/typeinfo/geometry_collection.go @@ -167,6 +167,8 @@ func geomcollTypeConverter(ctx context.Context, src *geomcollType, destTi TypeIn return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *floatType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: @@ -183,8 +185,6 @@ func geomcollTypeConverter(ctx context.Context, src *geomcollType, destTi TypeIn return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *multipolygonType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) - case *geomcollType: - return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *pointType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *polygonType: diff --git a/go/libraries/doltcore/schema/typeinfo/inlineblob.go b/go/libraries/doltcore/schema/typeinfo/inlineblob.go index 5838da0c22..449dafd541 100644 --- a/go/libraries/doltcore/schema/typeinfo/inlineblob.go +++ b/go/libraries/doltcore/schema/typeinfo/inlineblob.go @@ -239,6 +239,8 @@ func inlineBlobTypeConverter(ctx context.Context, src *inlineBlobType, destTi Ty return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *floatType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: diff --git a/go/libraries/doltcore/schema/typeinfo/int.go b/go/libraries/doltcore/schema/typeinfo/int.go index 3f44dc225c..548a07121d 100644 --- a/go/libraries/doltcore/schema/typeinfo/int.go +++ b/go/libraries/doltcore/schema/typeinfo/int.go @@ -277,6 +277,8 @@ func intTypeConverter(ctx context.Context, src *intType, destTi TypeInfo) (tc Ty }, true, nil case *floatType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: diff --git a/go/libraries/doltcore/schema/typeinfo/json.go b/go/libraries/doltcore/schema/typeinfo/json.go index 56fa35c05f..9e127afc58 100644 --- a/go/libraries/doltcore/schema/typeinfo/json.go +++ b/go/libraries/doltcore/schema/typeinfo/json.go @@ -167,6 +167,8 @@ func jsonTypeConverter(ctx context.Context, src *jsonType, destTi TypeInfo) (tc return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *floatType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: diff --git a/go/libraries/doltcore/schema/typeinfo/linestring.go b/go/libraries/doltcore/schema/typeinfo/linestring.go index 63ea809417..6e8c3c3ac1 100644 --- a/go/libraries/doltcore/schema/typeinfo/linestring.go +++ b/go/libraries/doltcore/schema/typeinfo/linestring.go @@ -167,6 +167,8 @@ func linestringTypeConverter(ctx context.Context, src *linestringType, destTi Ty return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *floatType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: diff --git a/go/libraries/doltcore/schema/typeinfo/multilinestring.go b/go/libraries/doltcore/schema/typeinfo/multilinestring.go index 816e7e76ea..ddd40e7a54 100644 --- a/go/libraries/doltcore/schema/typeinfo/multilinestring.go +++ b/go/libraries/doltcore/schema/typeinfo/multilinestring.go @@ -167,6 +167,8 @@ func multilinestringTypeConverter(ctx context.Context, src *multilinestringType, return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *floatType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: diff --git a/go/libraries/doltcore/schema/typeinfo/multipoint.go b/go/libraries/doltcore/schema/typeinfo/multipoint.go index b74c5db19c..58b1fe245e 100644 --- a/go/libraries/doltcore/schema/typeinfo/multipoint.go +++ b/go/libraries/doltcore/schema/typeinfo/multipoint.go @@ -167,6 +167,8 @@ func multipointTypeConverter(ctx context.Context, src *multipointType, destTi Ty return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *floatType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: diff --git a/go/libraries/doltcore/schema/typeinfo/multipolygon.go b/go/libraries/doltcore/schema/typeinfo/multipolygon.go index 5f3535bbc0..476765ee7c 100644 --- a/go/libraries/doltcore/schema/typeinfo/multipolygon.go +++ b/go/libraries/doltcore/schema/typeinfo/multipolygon.go @@ -167,6 +167,8 @@ func multipolygonTypeConverter(ctx context.Context, src *multipolygonType, destT return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *floatType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: diff --git a/go/libraries/doltcore/schema/typeinfo/point.go b/go/libraries/doltcore/schema/typeinfo/point.go index f3eb7cac67..c421c7141f 100644 --- a/go/libraries/doltcore/schema/typeinfo/point.go +++ b/go/libraries/doltcore/schema/typeinfo/point.go @@ -167,6 +167,8 @@ func pointTypeConverter(ctx context.Context, src *pointType, destTi TypeInfo) (t return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *floatType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: diff --git a/go/libraries/doltcore/schema/typeinfo/polygon.go b/go/libraries/doltcore/schema/typeinfo/polygon.go index 62e6a3175b..af089b81b3 100644 --- a/go/libraries/doltcore/schema/typeinfo/polygon.go +++ b/go/libraries/doltcore/schema/typeinfo/polygon.go @@ -167,6 +167,8 @@ func polygonTypeConverter(ctx context.Context, src *polygonType, destTi TypeInfo return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *floatType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: diff --git a/go/libraries/doltcore/schema/typeinfo/set.go b/go/libraries/doltcore/schema/typeinfo/set.go index b5dd28c854..b0a5aa96f3 100644 --- a/go/libraries/doltcore/schema/typeinfo/set.go +++ b/go/libraries/doltcore/schema/typeinfo/set.go @@ -208,6 +208,8 @@ func setTypeConverter(ctx context.Context, src *setType, destTi TypeInfo) (tc Ty return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *floatType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: diff --git a/go/libraries/doltcore/schema/typeinfo/time.go b/go/libraries/doltcore/schema/typeinfo/time.go index 270a280940..08958e194b 100644 --- a/go/libraries/doltcore/schema/typeinfo/time.go +++ b/go/libraries/doltcore/schema/typeinfo/time.go @@ -150,6 +150,8 @@ func timeTypeConverter(ctx context.Context, src *timeType, destTi TypeInfo) (tc return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *floatType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: diff --git a/go/libraries/doltcore/schema/typeinfo/typeconverter.go b/go/libraries/doltcore/schema/typeinfo/typeconverter.go index 3a14c6ea0b..807f750085 100644 --- a/go/libraries/doltcore/schema/typeinfo/typeconverter.go +++ b/go/libraries/doltcore/schema/typeinfo/typeconverter.go @@ -65,6 +65,8 @@ func GetTypeConverter(ctx context.Context, srcTi TypeInfo, destTi TypeInfo) (tc return enumTypeConverter(ctx, src, destTi) case *floatType: return floatTypeConverter(ctx, src, destTi) + case *geomcollType: + return geomcollTypeConverter(ctx, src, destTi) case *geometryType: return geometryTypeConverter(ctx, src, destTi) case *inlineBlobType: diff --git a/go/libraries/doltcore/schema/typeinfo/uint.go b/go/libraries/doltcore/schema/typeinfo/uint.go index af8254170d..24306bc8ea 100644 --- a/go/libraries/doltcore/schema/typeinfo/uint.go +++ b/go/libraries/doltcore/schema/typeinfo/uint.go @@ -277,6 +277,8 @@ func uintTypeConverter(ctx context.Context, src *uintType, destTi TypeInfo) (tc }, true, nil case *floatType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: diff --git a/go/libraries/doltcore/schema/typeinfo/uuid.go b/go/libraries/doltcore/schema/typeinfo/uuid.go index eea0c8bf5a..7e83d92c0f 100644 --- a/go/libraries/doltcore/schema/typeinfo/uuid.go +++ b/go/libraries/doltcore/schema/typeinfo/uuid.go @@ -155,6 +155,8 @@ func uuidTypeConverter(ctx context.Context, src *uuidType, destTi TypeInfo) (tc return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *floatType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: diff --git a/go/libraries/doltcore/schema/typeinfo/varbinary.go b/go/libraries/doltcore/schema/typeinfo/varbinary.go index 9f92a9485a..ea64981e9d 100644 --- a/go/libraries/doltcore/schema/typeinfo/varbinary.go +++ b/go/libraries/doltcore/schema/typeinfo/varbinary.go @@ -267,6 +267,8 @@ func varBinaryTypeConverter(ctx context.Context, src *varBinaryType, destTi Type return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *floatType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: diff --git a/go/libraries/doltcore/schema/typeinfo/varstring.go b/go/libraries/doltcore/schema/typeinfo/varstring.go index 763885e4f4..7f3dcc5597 100644 --- a/go/libraries/doltcore/schema/typeinfo/varstring.go +++ b/go/libraries/doltcore/schema/typeinfo/varstring.go @@ -290,6 +290,8 @@ func varStringTypeConverter(ctx context.Context, src *varStringType, destTi Type return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *floatType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: diff --git a/go/libraries/doltcore/schema/typeinfo/year.go b/go/libraries/doltcore/schema/typeinfo/year.go index 1f43510ce2..212e626f6d 100644 --- a/go/libraries/doltcore/schema/typeinfo/year.go +++ b/go/libraries/doltcore/schema/typeinfo/year.go @@ -166,6 +166,8 @@ func yearTypeConverter(ctx context.Context, src *yearType, destTi TypeInfo) (tc return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *floatType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) + case *geomcollType: + return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *geometryType: return wrapConvertValueToNomsValue(dest.ConvertValueToNomsValue) case *inlineBlobType: From 206aa9ee290c7a902a424c31e32877d9180a2365 Mon Sep 17 00:00:00 2001 From: James Cor Date: Sun, 16 Oct 2022 22:12:41 -0700 Subject: [PATCH 06/14] tests --- go/libraries/doltcore/schema/typeinfo/typeinfo_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/go/libraries/doltcore/schema/typeinfo/typeinfo_test.go b/go/libraries/doltcore/schema/typeinfo/typeinfo_test.go index c777a82746..8b2a7276bd 100644 --- a/go/libraries/doltcore/schema/typeinfo/typeinfo_test.go +++ b/go/libraries/doltcore/schema/typeinfo/typeinfo_test.go @@ -360,6 +360,7 @@ func generateTypeInfoArrays(t *testing.T) ([][]TypeInfo, [][]types.Value) { {MultiPointType}, {MultiLineStringType}, {MultiPolygonType}, + {GeomCollType}, {GeometryType}, generateSetTypes(t, 16), {TimeType}, @@ -399,6 +400,7 @@ func generateTypeInfoArrays(t *testing.T) ([][]TypeInfo, [][]types.Value) { {types.MultiPoint{SRID: 0, Points: []types.Point{{SRID: 0, X: 1, Y: 2}, {SRID: 0, X: 3, Y: 4}}}}, // MultiPoint {types.MultiLineString{SRID: 0, Lines: []types.LineString{{SRID: 0, Points: []types.Point{{SRID: 0, X: 0, Y: 0}, {SRID: 0, X: 0, Y: 1}, {SRID: 0, X: 1, Y: 1}, {SRID: 0, X: 0, Y: 0}}}}}}, // MultiLineString {types.MultiPolygon{SRID: 0, Polygons: []types.Polygon{{SRID: 0, Lines: []types.LineString{{SRID: 0, Points: []types.Point{{SRID: 0, X: 0, Y: 0}, {SRID: 0, X: 0, Y: 1}, {SRID: 0, X: 1, Y: 1}, {SRID: 0, X: 0, Y: 0}}}}}}}}, // MultiPolygon + {types.GeomColl{SRID: 0, Geometries: []types.Value{types.GeomColl{SRID: 0, Geometries: []types.Value{}}}}}, // Geometry Collection {types.Geometry{Inner: types.Point{SRID: 0, X: 1, Y: 2}}}, // Geometry holding a Point {types.Uint(1), types.Uint(5), types.Uint(64), types.Uint(42), types.Uint(192)}, //Set {types.Int(0), types.Int(1000000 /*"00:00:01"*/), types.Int(113000000 /*"00:01:53"*/), types.Int(247019000000 /*"68:36:59"*/), types.Int(458830485214 /*"127:27:10.485214"*/)}, //Time From 2b153b61fb7a7fcb40e1571d9b8601c91216ccf9 Mon Sep 17 00:00:00 2001 From: James Cor Date: Sun, 16 Oct 2022 22:15:07 -0700 Subject: [PATCH 07/14] conversions --- go/libraries/doltcore/schema/typeinfo/geometry.go | 2 ++ go/store/types/read_geometry.go | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/go/libraries/doltcore/schema/typeinfo/geometry.go b/go/libraries/doltcore/schema/typeinfo/geometry.go index 1cfb5b79cf..5afb1de924 100644 --- a/go/libraries/doltcore/schema/typeinfo/geometry.go +++ b/go/libraries/doltcore/schema/typeinfo/geometry.go @@ -57,6 +57,8 @@ func (ti *geometryType) ConvertNomsValueToValue(v types.Value) (interface{}, err return types.ConvertTypesMultiLineStringToSQLMultiLineString(val), nil case types.MultiPolygon: return types.ConvertTypesMultiPolygonToSQLMultiPolygon(val), nil + case types.GeomColl: + return types.ConvertTypesGeomCollToSQLGeomColl(val), nil default: return nil, fmt.Errorf(`"%v" cannot convert NomsKind "%v" to a value`, ti.String(), v.Kind()) } diff --git a/go/store/types/read_geometry.go b/go/store/types/read_geometry.go index af552dad34..6784f4e1ac 100644 --- a/go/store/types/read_geometry.go +++ b/go/store/types/read_geometry.go @@ -26,6 +26,14 @@ func ConvertTypesGeometryToSQLGeometry(g Geometry) interface{} { return ConvertTypesLineStringToSQLLineString(inner) case Polygon: return ConvertTypesPolygonToSQLPolygon(inner) + case MultiPoint: + return ConvertTypesMultiPointToSQLMultiPoint(inner) + case MultiLineString: + return ConvertTypesMultiLineStringToSQLMultiLineString(inner) + case MultiPolygon: + return ConvertTypesMultiPolygonToSQLMultiPolygon(inner) + case GeomColl: + return ConvertTypesGeomCollToSQLGeomColl(inner) default: panic("used an invalid type types.Geometry.Inner") } From 6ee6877c09875f4f56dfe68c478993837d94c6ff Mon Sep 17 00:00:00 2001 From: James Cor Date: Sun, 16 Oct 2022 22:18:37 -0700 Subject: [PATCH 08/14] hopefully passing tests --- go/libraries/doltcore/schema/typeinfo/geometry.go | 4 ++++ go/libraries/doltcore/schema/typeinfo/typeinfo.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/go/libraries/doltcore/schema/typeinfo/geometry.go b/go/libraries/doltcore/schema/typeinfo/geometry.go index 5afb1de924..f7c9029eb8 100644 --- a/go/libraries/doltcore/schema/typeinfo/geometry.go +++ b/go/libraries/doltcore/schema/typeinfo/geometry.go @@ -162,6 +162,8 @@ func (ti *geometryType) FormatValue(v types.Value) (*string, error) { return MultiLineStringType.FormatValue(val) case types.MultiPolygon: return MultiPolygonType.FormatValue(val) + case types.GeomColl: + return GeomCollType.FormatValue(val) case types.Geometry: switch inner := val.Inner.(type) { case types.Point: @@ -176,6 +178,8 @@ func (ti *geometryType) FormatValue(v types.Value) (*string, error) { return MultiLineStringType.FormatValue(inner) case types.MultiPolygon: return MultiPolygonType.FormatValue(val) + case types.GeomColl: + return GeomCollType.FormatValue(val) default: return nil, fmt.Errorf(`"%v" has unexpectedly encountered a value of type "%T" from embedded type`, ti.String(), v.Kind()) } diff --git a/go/libraries/doltcore/schema/typeinfo/typeinfo.go b/go/libraries/doltcore/schema/typeinfo/typeinfo.go index db38436996..3453eb0764 100644 --- a/go/libraries/doltcore/schema/typeinfo/typeinfo.go +++ b/go/libraries/doltcore/schema/typeinfo/typeinfo.go @@ -300,6 +300,8 @@ func FromTypeParams(id Identifier, params map[string]string) (TypeInfo, error) { return CreateMultiLineStringTypeFromParams(params) case MultiPolygonTypeIdentifier: return CreateMultiPolygonTypeFromParams(params) + case GeometryCollectionTypeIdentifier: + return CreateGeomCollTypeFromParams(params) case SetTypeIdentifier: return CreateSetTypeFromParams(params) case TimeTypeIdentifier: From 71fd4ab09a414733d35b521818da4374d7e9ed1c Mon Sep 17 00:00:00 2001 From: James Cor Date: Sun, 16 Oct 2022 22:20:24 -0700 Subject: [PATCH 09/14] bump --- go/go.mod | 2 +- go/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go/go.mod b/go/go.mod index c1b1eaa8d3..78c4105fed 100644 --- a/go/go.mod +++ b/go/go.mod @@ -57,7 +57,7 @@ require ( require ( github.com/aliyun/aliyun-oss-go-sdk v2.2.5+incompatible github.com/cenkalti/backoff/v4 v4.1.3 - github.com/dolthub/go-mysql-server v0.12.1-0.20221014214651-c2bf09248ff9 + github.com/dolthub/go-mysql-server v0.12.1-0.20221016093001-b3a64089af44 github.com/google/flatbuffers v2.0.6+incompatible github.com/kch42/buzhash v0.0.0-20160816060738-9bdec3dec7c6 github.com/mitchellh/go-ps v1.0.0 diff --git a/go/go.sum b/go/go.sum index 87c19d39fb..20be44c5ca 100644 --- a/go/go.sum +++ b/go/go.sum @@ -178,8 +178,8 @@ github.com/dolthub/flatbuffers v1.13.0-dh.1 h1:OWJdaPep22N52O/0xsUevxJ6Qfw1M2txC github.com/dolthub/flatbuffers v1.13.0-dh.1/go.mod h1:CorYGaDmXjHz1Z7i50PYXG1Ricn31GcA2wNOTFIQAKE= github.com/dolthub/fslock v0.0.3 h1:iLMpUIvJKMKm92+N1fmHVdxJP5NdyDK5bK7z7Ba2s2U= github.com/dolthub/fslock v0.0.3/go.mod h1:QWql+P17oAAMLnL4HGB5tiovtDuAjdDTPbuqx7bYfa0= -github.com/dolthub/go-mysql-server v0.12.1-0.20221014214651-c2bf09248ff9 h1:xGTHflXQ6gWZFvgXIyHHrBtmIEWoLEc70dSY6SGPl/g= -github.com/dolthub/go-mysql-server v0.12.1-0.20221014214651-c2bf09248ff9/go.mod h1:9Q9FhWO82GrV4he13V2ZuDE0T/eDZbPVMOWLcZluOvg= +github.com/dolthub/go-mysql-server v0.12.1-0.20221016093001-b3a64089af44 h1:1vNYVBicOD85Czp0Og0L4xJXGRHoMb2IVweRI8xSy1s= +github.com/dolthub/go-mysql-server v0.12.1-0.20221016093001-b3a64089af44/go.mod h1:9Q9FhWO82GrV4he13V2ZuDE0T/eDZbPVMOWLcZluOvg= github.com/dolthub/ishell v0.0.0-20220112232610-14e753f0f371 h1:oyPHJlzumKta1vnOQqUnfdz+pk3EmnHS3Nd0cCT0I2g= github.com/dolthub/ishell v0.0.0-20220112232610-14e753f0f371/go.mod h1:dhGBqcCEfK5kuFmeO5+WOx3hqc1k3M29c1oS/R7N4ms= github.com/dolthub/jsonpath v0.0.0-20210609232853-d49537a30474 h1:xTrR+l5l+1Lfq0NvhiEsctylXinUMFhhsqaEcl414p8= From cfc33a675fe207fcaff0eda25e0f362d6473ae59 Mon Sep 17 00:00:00 2001 From: James Cor Date: Sun, 16 Oct 2022 22:23:18 -0700 Subject: [PATCH 10/14] asdf --- go/libraries/doltcore/migrate/tuples.go | 12 +++++++++++- go/libraries/doltcore/migrate/validation.go | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/go/libraries/doltcore/migrate/tuples.go b/go/libraries/doltcore/migrate/tuples.go index ab921161e2..16b305257e 100644 --- a/go/libraries/doltcore/migrate/tuples.go +++ b/go/libraries/doltcore/migrate/tuples.go @@ -160,7 +160,13 @@ func translateNomsField(ctx context.Context, ns tree.NodeStore, value types.Valu v := value.(types.Geometry).Inner translateGeometryField(v, idx, b) - case types.PointKind, types.LineStringKind, types.PolygonKind, types.MultiPointKind: + case types.PointKind, + types.LineStringKind, + types.PolygonKind, + types.MultiPointKind, + types.MultiLineStringKind, + types.MultiPolygonKind, + types.GeometryCollectionKind: translateGeometryField(value, idx, b) case types.JSONKind: @@ -288,6 +294,10 @@ func translateGeometryField(value types.Value, idx int, b *val.TupleBuilder) { p := types.ConvertTypesMultiPolygonToSQLMultiPolygon(value.(types.MultiPolygon)) b.PutGeometry(idx, p.Serialize()) + case types.GeometryCollectionKind: + p := types.ConvertTypesGeomCollToSQLGeomColl(value.(types.GeomColl)) + b.PutGeometry(idx, p.Serialize()) + default: panic(fmt.Sprintf("unexpected NomsKind for geometry (%d)", nk)) } diff --git a/go/libraries/doltcore/migrate/validation.go b/go/libraries/doltcore/migrate/validation.go index 407c004c59..675434e2b7 100644 --- a/go/libraries/doltcore/migrate/validation.go +++ b/go/libraries/doltcore/migrate/validation.go @@ -241,6 +241,7 @@ func nomsKindsFromQueryTypes(qt query.Type) []types.NomsKind { types.MultiPointKind, types.MultiLineStringKind, types.MultiPolygonKind, + types.GeometryCollectionKind, } case query.Type_JSON: From 3efbfdfad2323152c1b965db7efe4fef23cbcbfd Mon Sep 17 00:00:00 2001 From: James Cor Date: Sun, 16 Oct 2022 23:23:27 -0700 Subject: [PATCH 11/14] oops --- go/libraries/doltcore/sqle/index/prolly_fields_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/libraries/doltcore/sqle/index/prolly_fields_test.go b/go/libraries/doltcore/sqle/index/prolly_fields_test.go index 327b890b58..75884c9bf5 100644 --- a/go/libraries/doltcore/sqle/index/prolly_fields_test.go +++ b/go/libraries/doltcore/sqle/index/prolly_fields_test.go @@ -201,7 +201,7 @@ func testRoundTripProllyFields(t *testing.T, test prollyFieldTest) { func mustParseGeometryType(t *testing.T, s string) (v interface{}) { // Determine type, and get data - geomType, data, err := function.ParseWKTHeader(s) + geomType, data, _, err := function.ParseWKTHeader(s) require.NoError(t, err) srid, order := uint32(0), false From 5dc4eeb4b239c92b5dd99740509bf814fcdc31ad Mon Sep 17 00:00:00 2001 From: James Cor Date: Sun, 16 Oct 2022 23:42:30 -0700 Subject: [PATCH 12/14] missed one --- go/store/types/read_geometry.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/go/store/types/read_geometry.go b/go/store/types/read_geometry.go index 6784f4e1ac..a75bb2231d 100644 --- a/go/store/types/read_geometry.go +++ b/go/store/types/read_geometry.go @@ -120,6 +120,8 @@ func ConvertSQLGeometryToTypesGeometry(p interface{}) Value { return ConvertSQLMultiLineStringToTypesMultiLineString(inner) case sql.MultiPolygon: return ConvertSQLMultiPolygonToTypesMultiPolygon(inner) + case sql.GeomColl: + return ConvertSQLGeomCollToTypesGeomColl(inner) default: panic("used an invalid type sql.Geometry.Inner") } From 30fd00f10279eeddb43a975f58edb3fec8e1b419 Mon Sep 17 00:00:00 2001 From: James Cor Date: Mon, 17 Oct 2022 00:42:35 -0700 Subject: [PATCH 13/14] bump --- go/go.mod | 2 +- go/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go/go.mod b/go/go.mod index 78c4105fed..e512c39191 100644 --- a/go/go.mod +++ b/go/go.mod @@ -57,7 +57,7 @@ require ( require ( github.com/aliyun/aliyun-oss-go-sdk v2.2.5+incompatible github.com/cenkalti/backoff/v4 v4.1.3 - github.com/dolthub/go-mysql-server v0.12.1-0.20221016093001-b3a64089af44 + github.com/dolthub/go-mysql-server v0.12.1-0.20221017074119-86f7228536af github.com/google/flatbuffers v2.0.6+incompatible github.com/kch42/buzhash v0.0.0-20160816060738-9bdec3dec7c6 github.com/mitchellh/go-ps v1.0.0 diff --git a/go/go.sum b/go/go.sum index 20be44c5ca..0673395965 100644 --- a/go/go.sum +++ b/go/go.sum @@ -178,8 +178,8 @@ github.com/dolthub/flatbuffers v1.13.0-dh.1 h1:OWJdaPep22N52O/0xsUevxJ6Qfw1M2txC github.com/dolthub/flatbuffers v1.13.0-dh.1/go.mod h1:CorYGaDmXjHz1Z7i50PYXG1Ricn31GcA2wNOTFIQAKE= github.com/dolthub/fslock v0.0.3 h1:iLMpUIvJKMKm92+N1fmHVdxJP5NdyDK5bK7z7Ba2s2U= github.com/dolthub/fslock v0.0.3/go.mod h1:QWql+P17oAAMLnL4HGB5tiovtDuAjdDTPbuqx7bYfa0= -github.com/dolthub/go-mysql-server v0.12.1-0.20221016093001-b3a64089af44 h1:1vNYVBicOD85Czp0Og0L4xJXGRHoMb2IVweRI8xSy1s= -github.com/dolthub/go-mysql-server v0.12.1-0.20221016093001-b3a64089af44/go.mod h1:9Q9FhWO82GrV4he13V2ZuDE0T/eDZbPVMOWLcZluOvg= +github.com/dolthub/go-mysql-server v0.12.1-0.20221017074119-86f7228536af h1:Rck6hB+jn/X9SZRnIRqtz15Oi7VmVKYaaore4CIESdw= +github.com/dolthub/go-mysql-server v0.12.1-0.20221017074119-86f7228536af/go.mod h1:9Q9FhWO82GrV4he13V2ZuDE0T/eDZbPVMOWLcZluOvg= github.com/dolthub/ishell v0.0.0-20220112232610-14e753f0f371 h1:oyPHJlzumKta1vnOQqUnfdz+pk3EmnHS3Nd0cCT0I2g= github.com/dolthub/ishell v0.0.0-20220112232610-14e753f0f371/go.mod h1:dhGBqcCEfK5kuFmeO5+WOx3hqc1k3M29c1oS/R7N4ms= github.com/dolthub/jsonpath v0.0.0-20210609232853-d49537a30474 h1:xTrR+l5l+1Lfq0NvhiEsctylXinUMFhhsqaEcl414p8= From 6e6af4b724acb87c9c166ccf4997a842d90bf260 Mon Sep 17 00:00:00 2001 From: James Cor Date: Tue, 18 Oct 2022 12:09:41 -0700 Subject: [PATCH 14/14] deleting comment --- go/store/types/geometry_collection.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/store/types/geometry_collection.go b/go/store/types/geometry_collection.go index c53de02c03..d4175bf276 100644 --- a/go/store/types/geometry_collection.go +++ b/go/store/types/geometry_collection.go @@ -27,7 +27,7 @@ import ( // GeomColl is a Noms Value wrapper around a string. type GeomColl struct { SRID uint32 - Geometries []Value // not sure if worth replacing with types version of sql.GeometryValue + Geometries []Value } // Value interface