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


##########
sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/util/Geography.java:
##########
@@ -185,4 +188,11 @@ private ByteBuffer getWrapper() {
     return ByteBuffer.wrap(getBytes()).order(DEFAULT_ENDIANNESS);
   }
 
+  // Validates that the given SRID is supported for GEOGRAPHY values.
+  private static void validateSrid(int srid) {
+    if (!GeographyType.isSridSupported(srid)) {
+      throw new IllegalArgumentException("Unsupported SRID value: " + srid);

Review Comment:
   Users cannot currently trigger this error through normal SQL execution. We 
already added proper Spark exceptions one layer above, but this adds a 
defense-in-depth invariant check on the data layer as well.
   
   As for Parquet in particular, we use WKBConverterStrategy which goes through 
STUtils (throws a structured SparkIllegalArgumentException). So under normal 
circumstances, that should fire before execution reaches this point.
   
   However, this additional check here provides defense against any other 
direct internal code calls to these methods which may supply invalid SRID to 
geospatial objects (now or in the future).



-- 
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