You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sedona.apache.org by "umartin (via GitHub)" <gi...@apache.org> on 2023/03/24 07:37:05 UTC
[GitHub] [sedona] umartin opened a new pull request, #809: [DOC] Document how to load GeoJSON using Spark SQL's built-in JSON da…
umartin opened a new pull request, #809:
URL: https://github.com/apache/sedona/pull/809
…ta source.
## Did you read the Contributor Guide?
- Yes, I have read [Contributor Rules](https://sedona.apache.org/latest-snapshot/community/rule/) and [Contributor Development Guide](https://sedona.apache.org/latest-snapshot/community/develop/)
## Is this PR related to a JIRA ticket?
- No, this is a documentation update. The PR name follows the format `[DOCS] my subject`.
## What changes were proposed in this PR?
Document how to use the built-in JSON data source in Spark SQL to read GeoJSON
## How was this patch tested?
## Did this PR include necessary documentation updates?
--
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: dev-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [sedona] umartin commented on a diff in pull request #809: [DOC] Document how to load GeoJSON using Spark SQL's built-in JSON da…
Posted by "umartin (via GitHub)" <gi...@apache.org>.
umartin commented on code in PR #809:
URL: https://github.com/apache/sedona/pull/809#discussion_r1148862814
##########
docs/tutorial/sql.md:
##########
@@ -212,10 +212,50 @@ root
!!!note
SedonaSQL provides lots of functions to create a Geometry column, please read [SedonaSQL constructor API](../api/sql/Constructor.md).
+
+## Load GeoJSON using Spark JSON Data Source
+
+Spark SQL's built-in JSON data source supports reading GeoJSON data.
+To ensure proper parsing of the geometry property, we can define a schema with the geometry property set to type 'string'.
+This prevents Spark from interpreting the property and allows us to use the ST_GeomFromGeoJSON function for accurate geometry parsing.
+
+=== "Scala/Java"
Review Comment:
Fixed
##########
docs/tutorial/sql.md:
##########
@@ -256,6 +296,66 @@ root
Sedona supports spatial predicate push-down for GeoParquet files, please refer to the [SedonaSQL query optimizer](../api/sql/Optimizer.md) documentation for details.
+## Load data from JDBC data sources
+
+The 'query' option in Spark SQL's JDBC data source can be used to convert geometry columns to a format that Sedona can interpret.
+This should work for most spatial JDBC data sources.
+For Postgis there is no need to add a query to convert geometry types since it's already using EWKB as it's wire format.
+
+=== "Scala/Java"
Review Comment:
Fixed
--
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: dev-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [sedona] jiayuasu merged pull request #809: [DOC] Document how to load GeoJSON using Spark SQL's built-in JSON da…
Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu merged PR #809:
URL: https://github.com/apache/sedona/pull/809
--
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: dev-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [sedona] umartin commented on pull request #809: [DOC] Document how to load GeoJSON using Spark SQL's built-in JSON da…
Posted by "umartin (via GitHub)" <gi...@apache.org>.
umartin commented on PR #809:
URL: https://github.com/apache/sedona/pull/809#issuecomment-1485090752
> BTW, is there a way that we could leverage Spark built-in JSON data source and ST_AsGeoJSON to save data back to GeoJSON file?
That's a good question. I haven't tried it but in theory you could build the coordinate part with ST_AsGeoJSON and then build the rest of the json with the to_json function or the json data source. For this to work there needs to be some option in Spark to not quote the output from ST_AsGeoJSON.
Processing GeoJSON in Spark SQL is a bit of a hack. GeoJSON is really the worst imaginable big data format. Since all rows (features) are wrapped up in an envelope object there is no way it can be written or read in parallel. Reading and writing that kind of format in Spark SQL means all data is pushed to a singe task.
--
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: dev-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [sedona] umartin commented on pull request #809: [DOC] Document how to load GeoJSON using Spark SQL's built-in JSON da…
Posted by "umartin (via GitHub)" <gi...@apache.org>.
umartin commented on PR #809:
URL: https://github.com/apache/sedona/pull/809#issuecomment-1482653238
I accidentally pushed some other changes. Now this PR only contains documentation updates. I really shouldn't multitask.
--
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: dev-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [sedona] jiayuasu commented on a diff in pull request #809: [DOC] Document how to load GeoJSON using Spark SQL's built-in JSON da…
Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu commented on code in PR #809:
URL: https://github.com/apache/sedona/pull/809#discussion_r1148273815
##########
docs/tutorial/sql.md:
##########
@@ -212,10 +212,50 @@ root
!!!note
SedonaSQL provides lots of functions to create a Geometry column, please read [SedonaSQL constructor API](../api/sql/Constructor.md).
+
+## Load GeoJSON using Spark JSON Data Source
+
+Spark SQL's built-in JSON data source supports reading GeoJSON data.
+To ensure proper parsing of the geometry property, we can define a schema with the geometry property set to type 'string'.
+This prevents Spark from interpreting the property and allows us to use the ST_GeomFromGeoJSON function for accurate geometry parsing.
+
+=== "Scala/Java"
Review Comment:
Should be `Scala`
##########
docs/tutorial/sql.md:
##########
@@ -256,6 +296,66 @@ root
Sedona supports spatial predicate push-down for GeoParquet files, please refer to the [SedonaSQL query optimizer](../api/sql/Optimizer.md) documentation for details.
+## Load data from JDBC data sources
+
+The 'query' option in Spark SQL's JDBC data source can be used to convert geometry columns to a format that Sedona can interpret.
+This should work for most spatial JDBC data sources.
+For Postgis there is no need to add a query to convert geometry types since it's already using EWKB as it's wire format.
+
+=== "Scala/Java"
Review Comment:
Should be `Scala`
--
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: dev-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [sedona] umartin commented on pull request #809: [DOC] Document how to load GeoJSON using Spark SQL's built-in JSON da…
Posted by "umartin (via GitHub)" <gi...@apache.org>.
umartin commented on PR #809:
URL: https://github.com/apache/sedona/pull/809#issuecomment-1482594942
I also added documentation on how to work with JDBC data sources.
Reading geometries should be quite general across different databases. Writing I think is more specific. I only added documentation on how to write to Postgis.
--
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: dev-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org