Skip to content

Commit d299684

Browse files
uros-dbcloud-fan
authored andcommitted
[SPARK-54253][GEO][SQL] Add a guarding config for geospatial support
### What changes were proposed in this pull request? Introduce a new SQL config for controlling the geospatial feature: ``` spark.sql.geospatial.enabled ``` The default value is `false`, and enabled only in testing. ### Why are the changes needed? Guard the geospatial feature until it's fully finished. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Added appropriate unit tests to confirm that the config is effective: - `STExpressionsSuite` ### Was this patch authored or co-authored using generative AI tooling? No. Closes #53009 from uros-db/geo-config. Authored-by: Uros Bojanic <[email protected]> Signed-off-by: Wenchen Fan <[email protected]>
1 parent c5468b9 commit d299684

File tree

24 files changed

+291
-20
lines changed

24 files changed

+291
-20
lines changed

common/unsafe/src/main/java/org/apache/spark/unsafe/types/GeographyVal.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717

1818
package org.apache.spark.unsafe.types;
1919

20+
import org.apache.spark.annotation.Unstable;
21+
2022
import java.io.Serializable;
2123

2224
// This class represents the physical type for the GEOGRAPHY data type.
25+
@Unstable
2326
public final class GeographyVal implements Comparable<GeographyVal>, Serializable {
2427

2528
// The GEOGRAPHY type is implemented as a byte array. We provide `getBytes` and `fromBytes`

common/unsafe/src/main/java/org/apache/spark/unsafe/types/GeometryVal.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717

1818
package org.apache.spark.unsafe.types;
1919

20+
import org.apache.spark.annotation.Unstable;
21+
2022
import java.io.Serializable;
2123

2224
// This class represents the physical type for the GEOMETRY data type.
25+
@Unstable
2326
public final class GeometryVal implements Comparable<GeometryVal>, Serializable {
2427

2528
// The GEOMETRY type is implemented as a byte array. We provide `getBytes` and `fromBytes`

common/utils/src/main/resources/error/error-conditions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6654,6 +6654,11 @@
66546654
"Drop the namespace <namespace>."
66556655
]
66566656
},
6657+
"GEOSPATIAL_DISABLED" : {
6658+
"message" : [
6659+
"Geospatial feature is disabled."
6660+
]
6661+
},
66576662
"HIVE_TABLE_TYPE" : {
66586663
"message" : [
66596664
"The <tableName> is hive <tableType>."

sql/api/src/main/java/org/apache/spark/sql/types/Geography.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@
1717

1818
package org.apache.spark.sql.types;
1919

20+
import org.apache.spark.annotation.Unstable;
21+
2022
import java.io.Serializable;
2123
import java.util.Arrays;
2224

2325
// This class represents the Geography data for clients.
26+
@Unstable
2427
public final class Geography implements Serializable {
2528
// The GEOGRAPHY type is implemented as WKB bytes + SRID integer stored in class itself.
2629
protected final byte[] value;

sql/api/src/main/java/org/apache/spark/sql/types/Geometry.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@
1717

1818
package org.apache.spark.sql.types;
1919

20+
import org.apache.spark.annotation.Unstable;
21+
2022
import java.io.Serializable;
2123
import java.util.Arrays;
2224

2325
// This class represents the Geometry data for clients.
26+
@Unstable
2427
public final class Geometry implements Serializable {
2528
// The GEOMETRY type is implemented as WKB bytes + SRID integer stored in class itself.
2629
protected final byte[] value;

sql/api/src/main/scala/org/apache/spark/sql/internal/types/CartesianSpatialReferenceSystemMapper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717

1818
package org.apache.spark.sql.internal.types;
1919

20+
import org.apache.spark.annotation.Unstable;
21+
2022
/**
2123
* Class for providing SRS mappings for cartesian spatial reference systems.
2224
*/
25+
@Unstable
2326
public class CartesianSpatialReferenceSystemMapper extends SpatialReferenceSystemMapper {
2427
// Returns the string ID corresponding to the input SRID. If not supported, returns `null`.
2528
public static String getStringId(int srid) {

sql/api/src/main/scala/org/apache/spark/sql/internal/types/GeographicSpatialReferenceSystemMapper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717

1818
package org.apache.spark.sql.internal.types;
1919

20+
import org.apache.spark.annotation.Unstable;
21+
2022
/**
2123
* Class for providing SRS mappings for geographic spatial reference systems.
2224
*/
25+
@Unstable
2326
public class GeographicSpatialReferenceSystemMapper extends SpatialReferenceSystemMapper {
2427
// Returns the string ID corresponding to the input SRID. If not supported, returns `null`.
2528
public static String getStringId(int srid) {

sql/api/src/main/scala/org/apache/spark/sql/internal/types/SpatialReferenceSystemCache.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@
1717

1818
package org.apache.spark.sql.internal.types;
1919

20+
import org.apache.spark.annotation.Unstable;
21+
2022
import java.util.HashMap;
2123
import java.util.List;
2224

2325
/**
2426
* Class for maintaining the mappings between supported SRID/CRS values and the corresponding SRS.
2527
*/
28+
@Unstable
2629
public class SpatialReferenceSystemCache {
2730

2831
// Private constructor to prevent external instantiation of this singleton class.

sql/api/src/main/scala/org/apache/spark/sql/internal/types/SpatialReferenceSystemInformation.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717

1818
package org.apache.spark.sql.internal.types;
1919

20+
import org.apache.spark.annotation.Unstable;
21+
2022
/**
2123
* Class for maintaining information about a spatial reference system (SRS).
2224
*/
25+
@Unstable
2326
public record SpatialReferenceSystemInformation(
2427
// Field storing the spatial reference identifier (SRID) value of this SRS.
2528
int srid,

sql/api/src/main/scala/org/apache/spark/sql/internal/types/SpatialReferenceSystemMapper.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@
1717

1818
package org.apache.spark.sql.internal.types;
1919

20+
import org.apache.spark.annotation.Unstable;
21+
2022
/**
2123
* Abstract class for providing SRS mappings for spatial reference systems.
2224
*/
25+
26+
@Unstable
2327
public abstract class SpatialReferenceSystemMapper {
2428
protected static final SpatialReferenceSystemCache srsCache =
2529
SpatialReferenceSystemCache.getInstance();

0 commit comments

Comments
 (0)