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

[SEDONA-458] The docs should have examples for UDF #1179

Merged
merged 4 commits into from
Jan 4, 2024

Conversation

furqaankhan
Copy link
Contributor

Did you read the Contributor Guide?

Is this PR related to a JIRA ticket?

What changes were proposed in this PR?

  • Add UDF examples in SQL tutorial.

How was this patch tested?

Did this PR include necessary documentation updates?

  • Yes, I have updated the documentation update.

@@ -632,6 +632,277 @@ can also be found in the example notebook available [here](https://github.com/ap

Details on all the APIs available by SedonaKepler are listed in the [SedonaKepler API docs](../../api/sql/Visualization_SedonaKepler)

## Create a User-Defined Function (UDF)

User-Defined Functions (UDFs) are user-created procedures that can perform operations on a single row of information. To cover almost all use cases, we will showcase 4 types of UDFs for a better understanding of how to use geometry with UDFs.
Copy link
Member

Choose a reason for hiding this comment

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

Please add that:

Sedona's serializer deserializes the SQL geometry type to JTS Geometry (Scala/Java) or Shapely Geometry (Python). You can implement any custom logic using the rich ecosystem around these two libraries.

@jiayuasu
Copy link
Member

jiayuasu commented Jan 4, 2024

@furqaankhan Note that you can run pre-commit run --all-files in your local machine to let it automatically fix all lint issues. You will need to install pre-commit via brew

from sedona.sql.types import GeometryType
from pyspark.sql.types import DoubleType

schemaUDF = StructType([
Copy link
Member

Choose a reason for hiding this comment

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

Where to import the struct type in Python?

@jiayuasu jiayuasu added the docs label Jan 4, 2024
@jiayuasu jiayuasu merged commit a54976e into apache:master Jan 4, 2024
2 checks passed
@furqaankhan furqaankhan deleted the docs-udf branch July 16, 2024 01:38
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