Skip to content

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.


## 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
@furqaankhan furqaankhan deleted the docs-udf branch July 16, 2024 01:38
Kontinuation pushed a commit to Kontinuation/sedona that referenced this pull request Oct 11, 2024
* docs: add UDF example

* docs: add explanation and fix lint

* docs: fix lint

* docs: add missing imports
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.

2 participants