-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix e2e.RequireEqualRecordBatches (#967)
I introduced regression in #923 Function was returning bool while callers expect testify/require semantics --------- Co-authored-by: Amogh-Bharadwaj <[email protected]> Co-authored-by: Kevin Biju <[email protected]>
- Loading branch information
1 parent
c18b45e
commit 20ed252
Showing
9 changed files
with
154 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
//nolint:all | ||
package geo | ||
|
||
import ( | ||
"encoding/hex" | ||
"errors" | ||
"fmt" | ||
"log/slog" | ||
|
||
geom "github.com/twpayne/go-geos" | ||
) | ||
|
||
// returns the WKT representation of the geometry object if it is valid | ||
func GeoValidate(hexWkb string) (string, error) { | ||
// Decode the WKB hex string into binary | ||
wkb, hexErr := hex.DecodeString(hexWkb) | ||
if hexErr != nil { | ||
slog.Warn(fmt.Sprintf("Ignoring invalid WKB: %s", hexWkb)) | ||
return "", hexErr | ||
} | ||
|
||
// UnmarshalWKB performs geometry validation along with WKB parsing | ||
geometryObject, geoErr := geom.NewGeomFromWKB(wkb) | ||
if geoErr != nil { | ||
return "", geoErr | ||
} | ||
|
||
invalidReason := geometryObject.IsValidReason() | ||
if invalidReason != "Valid Geometry" { | ||
slog.Warn(fmt.Sprintf("Ignoring invalid geometry shape %s: %s", hexWkb, invalidReason)) | ||
return "", errors.New(invalidReason) | ||
} | ||
|
||
wkt := geometryObject.ToWKT() | ||
return wkt, nil | ||
} | ||
|
||
// compares WKTs | ||
func GeoCompare(wkt1, wkt2 string) bool { | ||
geom1, geoErr := geom.NewGeomFromWKT(wkt1) | ||
if geoErr != nil { | ||
return false | ||
} | ||
|
||
geom2, geoErr := geom.NewGeomFromWKT(wkt2) | ||
if geoErr != nil { | ||
return false | ||
} | ||
|
||
return geom1.Equals(geom2) | ||
} |
Oops, something went wrong.