uros-db commented on code in PR #54227:
URL: https://github.com/apache/spark/pull/54227#discussion_r2797030322


##########
sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/util/geo/WkbReader.java:
##########
@@ -69,6 +101,32 @@ private static boolean isValidCoordinateAllowEmpty(double 
value) {
     return Double.isFinite(value) || Double.isNaN(value);
   }
 
+  /**
+   * Returns true if the longitude value is within valid geography bounds 
[-180, 180].
+   */
+  private static boolean isValidLongitude(double value) {
+    return value >= MIN_LONGITUDE && value <= MAX_LONGITUDE;
+  }
+
+  /**
+   * Returns true if the latitude value is within valid geography bounds [-90, 
90].
+   */
+  private static boolean isValidLatitude(double value) {
+    return value >= MIN_LATITUDE && value <= MAX_LATITUDE;
+  }
+
+  /**
+   * Validates geography coordinate bounds for a point. In geography mode with 
validation
+   * level > 0, longitude must be between -180 and 180, and latitude must be 
between -90 and 90.
+   */
+  private void validateGeographyBounds(Point point, long pos) {
+    if (geographyMode && validationLevel > 0 && !point.isEmpty()) {
+      if (!isValidLongitude(point.getX()) || !isValidLatitude(point.getY())) {
+        throw new WkbParseException("Invalid coordinate value found", pos, 
currentWkb);

Review Comment:
   This is following the existing error handling paradigm, and we already have 
`pos` for debuggability, so I'll just keep it as-is.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to