Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOC] Document how to load GeoJSON using Spark SQL's built-in JSON da… #809

Merged
merged 2 commits into from
Mar 27, 2023

Conversation

umartin
Copy link
Contributor

@umartin umartin commented Mar 24, 2023

…ta source.

Did you read the Contributor Guide?

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?

@umartin umartin force-pushed the master branch 2 times, most recently from ebee212 to 665a94b Compare March 24, 2023 10:39
@umartin
Copy link
Contributor Author

umartin commented Mar 24, 2023

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.

@umartin
Copy link
Contributor Author

umartin commented Mar 24, 2023

I accidentally pushed some other changes. Now this PR only contains documentation updates. I really shouldn't multitask.

Copy link
Member

@jiayuasu jiayuasu left a comment

Choose a reason for hiding this comment

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

Thank you, @umartin ! I don't even know we could do this using Spark's built-in JSON data source. Lesson learned!

Please fix two minor changes.

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?

docs/tutorial/sql.md Outdated Show resolved Hide resolved
docs/tutorial/sql.md Outdated Show resolved Hide resolved
@jiayuasu jiayuasu added the docs label Mar 25, 2023
@jiayuasu jiayuasu merged commit a615773 into apache:master Mar 27, 2023
@umartin
Copy link
Contributor Author

umartin commented Mar 27, 2023

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.

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.

None yet

2 participants