Skip to content

Conversation

@uros-db
Copy link
Contributor

@uros-db uros-db commented Nov 3, 2025

What changes were proposed in this pull request?

Implement the ST_SetSrid expression in Catalyst, and add the corresponding st_setsrid SQL function.

Description

Returns a new GEOGRAPHY or GEOMETRY value whose SRID is the specified SRID value.

Syntax

st_setsrid(geo, srid)

Arguments

  • geo: A GEOGRAPHY or GEOMETRY value.
  • srid: An INTEGER value.

Returns

  • A value of type GEOGRAPHY or GEOMETRY.

Notes

  • The function returns NULL if the input is NULL.
  • The function returns an ST_INVALID_SRID_VALUE error if the provided srid is not valid.

Examples

> SELECT st_srid(st_setsrid(ST_GeogFromWKB(X'0101000000000000000000F03F0000000000000040'), 4326));
4326
> SELECT st_srid(st_setsrid(ST_GeomFromWKB(X'0101000000000000000000F03F0000000000000040'), 3857));
3857

Why are the changes needed?

Does this PR introduce any user-facing change?

Yes, a new SQL function is added: st_setsrid.

How was this patch tested?

New unit tests in Java/Scala suites:

  • STExpressionsSuite.scala
  • StUtilsSuite.java

New end-to-end SQL tests:

  • st-functions.sql

Finally, manually testing using Spark shell.

Was this patch authored or co-authored using generative AI tooling?

No.

@github-actions github-actions bot added the SQL label Nov 3, 2025
Copy link
Contributor Author

@uros-db uros-db left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cloud-fan
Copy link
Contributor

thanks, merging to master/4.1!

@cloud-fan cloud-fan closed this in 6b91d83 Nov 5, 2025
cloud-fan pushed a commit that referenced this pull request Nov 5, 2025
### What changes were proposed in this pull request?
Implement the `ST_SetSrid` expression in Catalyst, and add the corresponding `st_setsrid` SQL function.

#### Description
Returns a new `GEOGRAPHY` or `GEOMETRY` value whose `SRID` is the specified SRID value.

#### Syntax
```
st_setsrid(geo, srid)
```

#### Arguments
- `geo`: A `GEOGRAPHY` or `GEOMETRY` value.
- `srid`: An `INTEGER` value.

#### Returns
- A value of type `GEOGRAPHY` or `GEOMETRY`.

#### Notes
- The function returns `NULL` if the input is `NULL`.
- The function returns an `ST_INVALID_SRID_VALUE` error if the provided `srid` is not valid.

#### Examples
```
> SELECT st_srid(st_setsrid(ST_GeogFromWKB(X'0101000000000000000000F03F0000000000000040'), 4326));
4326
```

```
> SELECT st_srid(st_setsrid(ST_GeomFromWKB(X'0101000000000000000000F03F0000000000000040'), 3857));
3857
```

### Why are the changes needed?

### Does this PR introduce _any_ user-facing change?
Yes, a new SQL function is added: `st_setsrid`.

### How was this patch tested?
New unit tests in Java/Scala suites:
- `STExpressionsSuite.scala`
- `StUtilsSuite.java`

New end-to-end SQL tests:
- `st-functions.sql`

Finally, manually testing using Spark shell.

### Was this patch authored or co-authored using generative AI tooling?
No.

Closes #52858 from uros-db/geo-ST_SetSrid.

Authored-by: Uros Bojanic <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants