You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "uros-db (via GitHub)" <gi...@apache.org> on 2025/11/18 17:33:19 UTC
[PR] [SPARK-54399][Geo][SQL][PYTHON] Implement the st_setsrid function in Scala and PySpark [spark]
uros-db opened a new pull request, #53117:
URL: https://github.com/apache/spark/pull/53117
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a faster review.
7. If you want to add a new configuration, please read the guideline first for naming configurations in
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
8. If you want to add or modify an error type or message, please read the guideline first in
'common/utils/src/main/resources/error/README.md'.
-->
### What changes were proposed in this pull request?
Implement the `st_setsrid` function in Scala and PySpark API.
### Why are the changes needed?
Expand API support for the `ST_SetSrid` expression.
### Does this PR introduce _any_ user-facing change?
Yes, the new function is now available in Scala and PySpark API.
### How was this patch tested?
Added appropriate Scala function unit tests:
- `STFunctionsSuite`
Added appropriate PySpark function unit tests:
- `test_functions`
### Was this patch authored or co-authored using generative AI tooling?
No.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54399][Geo][SQL][PYTHON] Implement the st_setsrid function in Scala and PySpark [spark]
Posted by "uros-db (via GitHub)" <gi...@apache.org>.
uros-db commented on code in PR #53117:
URL: https://github.com/apache/spark/pull/53117#discussion_r2540550456
##########
python/pyspark/sql/functions/builtin.py:
##########
@@ -26139,6 +26139,33 @@ def st_geomfromwkb(wkb: "ColumnOrName") -> Column:
return _invoke_function_over_columns("st_geomfromwkb", wkb)
+@_try_remote_functions
+def st_setsrid(geo: "ColumnOrName", srid: "ColumnOrName") -> Column:
+ """Returns a new GEOGRAPHY or GEOMETRY value whose SRID is the specified SRID value.
+
+ .. versionadded:: 4.1.0
+
+ Parameters
+ ----------
+ geo : :class:`~pyspark.sql.Column` or str
+ A geospatial value, either a GEOGRAPHY or a GEOMETRY.
+ srid : :class:`~pyspark.sql.Column` or str
+ An INTEGER representing the new SRID of the geospatial value.
+
+ Examples
+ --------
+ >>> from pyspark.sql import functions as sf
+ >>> df = spark.createDataFrame([(bytes.fromhex('0101000000000000000000F03F0000000000000040'),)], ['wkb']) # noqa
+ >>> df.select(sf.st_srid(sf.st_setsrid(sf.st_geogfromwkb('wkb'), 4326)).alias('result')).collect() # noqa
+ [Row(result=4326)]
+ >>> from pyspark.sql import functions as sf
Review Comment:
They look similar, but one uses geograpy, and the other uses geometry.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54399][Geo][SQL][PYTHON] Implement the st_setsrid function in Scala and PySpark [spark]
Posted by "zhengruifeng (via GitHub)" <gi...@apache.org>.
zhengruifeng commented on code in PR #53117:
URL: https://github.com/apache/spark/pull/53117#discussion_r2540132610
##########
python/pyspark/sql/functions/builtin.py:
##########
@@ -26139,6 +26139,33 @@ def st_geomfromwkb(wkb: "ColumnOrName") -> Column:
return _invoke_function_over_columns("st_geomfromwkb", wkb)
+@_try_remote_functions
+def st_setsrid(geo: "ColumnOrName", srid: "ColumnOrName") -> Column:
+ """Returns a new GEOGRAPHY or GEOMETRY value whose SRID is the specified SRID value.
+
+ .. versionadded:: 4.1.0
+
+ Parameters
+ ----------
+ geo : :class:`~pyspark.sql.Column` or str
+ A geospatial value, either a GEOGRAPHY or a GEOMETRY.
+ srid : :class:`~pyspark.sql.Column` or str
+ An INTEGER representing the new SRID of the geospatial value.
+
+ Examples
+ --------
+ >>> from pyspark.sql import functions as sf
+ >>> df = spark.createDataFrame([(bytes.fromhex('0101000000000000000000F03F0000000000000040'),)], ['wkb']) # noqa
+ >>> df.select(sf.st_srid(sf.st_setsrid(sf.st_geogfromwkb('wkb'), 4326)).alias('result')).collect() # noqa
+ [Row(result=4326)]
+ >>> from pyspark.sql import functions as sf
Review Comment:
The two examples are the same?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54399][Geo][SQL][PYTHON] Implement the st_setsrid function in Scala and PySpark [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon closed pull request #53117: [SPARK-54399][Geo][SQL][PYTHON] Implement the st_setsrid function in Scala and PySpark
URL: https://github.com/apache/spark/pull/53117
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54399][Geo][SQL][PYTHON] Implement the st_setsrid function in Scala and PySpark [spark]
Posted by "zhengruifeng (via GitHub)" <gi...@apache.org>.
zhengruifeng commented on code in PR #53117:
URL: https://github.com/apache/spark/pull/53117#discussion_r2540573547
##########
python/pyspark/sql/functions/builtin.py:
##########
@@ -26139,6 +26139,33 @@ def st_geomfromwkb(wkb: "ColumnOrName") -> Column:
return _invoke_function_over_columns("st_geomfromwkb", wkb)
+@_try_remote_functions
+def st_setsrid(geo: "ColumnOrName", srid: "ColumnOrName") -> Column:
+ """Returns a new GEOGRAPHY or GEOMETRY value whose SRID is the specified SRID value.
+
+ .. versionadded:: 4.1.0
+
+ Parameters
+ ----------
+ geo : :class:`~pyspark.sql.Column` or str
+ A geospatial value, either a GEOGRAPHY or a GEOMETRY.
+ srid : :class:`~pyspark.sql.Column` or str
+ An INTEGER representing the new SRID of the geospatial value.
+
+ Examples
+ --------
+ >>> from pyspark.sql import functions as sf
+ >>> df = spark.createDataFrame([(bytes.fromhex('0101000000000000000000F03F0000000000000040'),)], ['wkb']) # noqa
+ >>> df.select(sf.st_srid(sf.st_setsrid(sf.st_geogfromwkb('wkb'), 4326)).alias('result')).collect() # noqa
+ [Row(result=4326)]
+ >>> from pyspark.sql import functions as sf
Review Comment:
then lets split the two examples with explanations: `Example 1: xxx` and `Example 2: xxx`
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54399][Geo][SQL][PYTHON] Implement the st_setsrid function in Scala and PySpark [spark]
Posted by "uros-db (via GitHub)" <gi...@apache.org>.
uros-db commented on code in PR #53117:
URL: https://github.com/apache/spark/pull/53117#discussion_r2540600908
##########
sql/api/src/main/scala/org/apache/spark/sql/functions.scala:
##########
@@ -9471,6 +9471,18 @@ object functions {
def st_geomfromwkb(wkb: Column): Column =
Column.fn("st_geomfromwkb", wkb)
+ /**
+ * Returns a new GEOGRAPHY or GEOMETRY value whose SRID is the specified SRID value.
+ *
+ * @group st_funcs
+ * @since 4.1.0
+ */
+ def st_setsrid(geo: Column, srid: Column): Column =
+ Column.fn("st_setsrid", geo, srid)
+
+ def st_setsrid(geo: Column, srid: Int): Column =
Review Comment:
@HyukjinKwon @zhengruifeng Do we need a doc comment for the second overload as well, or is the first one sufficient?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54399][Geo][SQL][PYTHON] Implement the st_setsrid function in Scala and PySpark [spark]
Posted by "uros-db (via GitHub)" <gi...@apache.org>.
uros-db commented on code in PR #53117:
URL: https://github.com/apache/spark/pull/53117#discussion_r2541324722
##########
sql/api/src/main/scala/org/apache/spark/sql/functions.scala:
##########
@@ -9471,6 +9471,18 @@ object functions {
def st_geomfromwkb(wkb: Column): Column =
Column.fn("st_geomfromwkb", wkb)
+ /**
+ * Returns a new GEOGRAPHY or GEOMETRY value whose SRID is the specified SRID value.
+ *
+ * @group st_funcs
+ * @since 4.1.0
+ */
+ def st_setsrid(geo: Column, srid: Column): Column =
+ Column.fn("st_setsrid", geo, srid)
+
+ def st_setsrid(geo: Column, srid: Int): Column =
Review Comment:
Done, thanks.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54399][Geo][SQL][PYTHON] Implement the st_setsrid function in Scala and PySpark [spark]
Posted by "uros-db (via GitHub)" <gi...@apache.org>.
uros-db commented on code in PR #53117:
URL: https://github.com/apache/spark/pull/53117#discussion_r2540594804
##########
python/pyspark/sql/functions/builtin.py:
##########
@@ -26139,6 +26139,33 @@ def st_geomfromwkb(wkb: "ColumnOrName") -> Column:
return _invoke_function_over_columns("st_geomfromwkb", wkb)
+@_try_remote_functions
+def st_setsrid(geo: "ColumnOrName", srid: "ColumnOrName") -> Column:
+ """Returns a new GEOGRAPHY or GEOMETRY value whose SRID is the specified SRID value.
+
+ .. versionadded:: 4.1.0
+
+ Parameters
+ ----------
+ geo : :class:`~pyspark.sql.Column` or str
+ A geospatial value, either a GEOGRAPHY or a GEOMETRY.
+ srid : :class:`~pyspark.sql.Column` or str
+ An INTEGER representing the new SRID of the geospatial value.
+
+ Examples
+ --------
+ >>> from pyspark.sql import functions as sf
+ >>> df = spark.createDataFrame([(bytes.fromhex('0101000000000000000000F03F0000000000000040'),)], ['wkb']) # noqa
+ >>> df.select(sf.st_srid(sf.st_setsrid(sf.st_geogfromwkb('wkb'), 4326)).alias('result')).collect() # noqa
+ [Row(result=4326)]
+ >>> from pyspark.sql import functions as sf
Review Comment:
Updated.
##########
python/pyspark/sql/functions/builtin.py:
##########
@@ -26139,6 +26139,33 @@ def st_geomfromwkb(wkb: "ColumnOrName") -> Column:
return _invoke_function_over_columns("st_geomfromwkb", wkb)
+@_try_remote_functions
+def st_setsrid(geo: "ColumnOrName", srid: "ColumnOrName") -> Column:
+ """Returns a new GEOGRAPHY or GEOMETRY value whose SRID is the specified SRID value.
+
+ .. versionadded:: 4.1.0
+
+ Parameters
+ ----------
+ geo : :class:`~pyspark.sql.Column` or str
+ A geospatial value, either a GEOGRAPHY or a GEOMETRY.
+ srid : :class:`~pyspark.sql.Column` or str
+ An INTEGER representing the new SRID of the geospatial value.
+
+ Examples
+ --------
+ >>> from pyspark.sql import functions as sf
+ >>> df = spark.createDataFrame([(bytes.fromhex('0101000000000000000000F03F0000000000000040'),)], ['wkb']) # noqa
+ >>> df.select(sf.st_srid(sf.st_setsrid(sf.st_geogfromwkb('wkb'), 4326)).alias('result')).collect() # noqa
Review Comment:
Updated.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54399][Geo][SQL][PYTHON] Implement the st_setsrid function in Scala and PySpark [spark]
Posted by "zhengruifeng (via GitHub)" <gi...@apache.org>.
zhengruifeng commented on code in PR #53117:
URL: https://github.com/apache/spark/pull/53117#discussion_r2540133390
##########
python/pyspark/sql/functions/builtin.py:
##########
@@ -26139,6 +26139,33 @@ def st_geomfromwkb(wkb: "ColumnOrName") -> Column:
return _invoke_function_over_columns("st_geomfromwkb", wkb)
+@_try_remote_functions
+def st_setsrid(geo: "ColumnOrName", srid: "ColumnOrName") -> Column:
+ """Returns a new GEOGRAPHY or GEOMETRY value whose SRID is the specified SRID value.
+
+ .. versionadded:: 4.1.0
+
+ Parameters
+ ----------
+ geo : :class:`~pyspark.sql.Column` or str
+ A geospatial value, either a GEOGRAPHY or a GEOMETRY.
+ srid : :class:`~pyspark.sql.Column` or str
+ An INTEGER representing the new SRID of the geospatial value.
+
+ Examples
+ --------
+ >>> from pyspark.sql import functions as sf
+ >>> df = spark.createDataFrame([(bytes.fromhex('0101000000000000000000F03F0000000000000040'),)], ['wkb']) # noqa
+ >>> df.select(sf.st_srid(sf.st_setsrid(sf.st_geogfromwkb('wkb'), 4326)).alias('result')).collect() # noqa
Review Comment:
```suggestion
>>> df.select(sf.st_srid(sf.st_setsrid(sf.st_geogfromwkb('wkb'), 4326))).show()
```
let's remove the alias to also check the default column name
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54399][Geo][SQL][PYTHON] Implement the st_setsrid function in Scala and PySpark [spark]
Posted by "uros-db (via GitHub)" <gi...@apache.org>.
uros-db commented on PR #53117:
URL: https://github.com/apache/spark/pull/53117#issuecomment-3553212705
@HyukjinKwon @zhengruifeng Please merge into master & 4.1 (if possible).
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54399][Geo][SQL][PYTHON] Implement the st_setsrid function in Scala and PySpark [spark]
Posted by "zhengruifeng (via GitHub)" <gi...@apache.org>.
zhengruifeng commented on code in PR #53117:
URL: https://github.com/apache/spark/pull/53117#discussion_r2541319241
##########
sql/api/src/main/scala/org/apache/spark/sql/functions.scala:
##########
@@ -9471,6 +9471,18 @@ object functions {
def st_geomfromwkb(wkb: Column): Column =
Column.fn("st_geomfromwkb", wkb)
+ /**
+ * Returns a new GEOGRAPHY or GEOMETRY value whose SRID is the specified SRID value.
+ *
+ * @group st_funcs
+ * @since 4.1.0
+ */
+ def st_setsrid(geo: Column, srid: Column): Column =
+ Column.fn("st_setsrid", geo, srid)
+
+ def st_setsrid(geo: Column, srid: Int): Column =
Review Comment:
yeah, let's add one more doc. To be consistent with other functions
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54399][Geo][SQL][PYTHON] Implement the st_setsrid function in Scala and PySpark [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on PR #53117:
URL: https://github.com/apache/spark/pull/53117#issuecomment-3555102817
Yeah let me hold merging those PRs. Was sort of my bad but should be fine to leave few ones non reverted for now.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54399][Geo][SQL][PYTHON] Implement the st_setsrid function in Scala and PySpark [spark]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #53117:
URL: https://github.com/apache/spark/pull/53117#issuecomment-3554908952
Looks okay to have this specific one under the experimental config.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54399][Geo][SQL][PYTHON] Implement the st_setsrid function in Scala and PySpark [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on PR #53117:
URL: https://github.com/apache/spark/pull/53117#issuecomment-3554825955
Merged to master and branch-4.1.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org