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

Adding the guide for using RisingWave UDF API for Python #689

Merged
merged 12 commits into from
Apr 10, 2023
Merged

Conversation

CharlieSYH
Copy link
Contributor

@CharlieSYH CharlieSYH commented Mar 28, 2023

Info

Before merging

  • (For version-specific PR) I have selected the corresponding software version in Milestone and linked the related doc issue to this PR in Development.
  • I have acquired the approval from the owner (and optionally the reviewers) of the code PR and at least one tech writer (bernscode, CharlieSYH, emile-00, & hengm3467).
  • I have checked the doc site preview, and the updated parts look good.
    How?Scroll down and open this link: image

@aws-amplify-us-east-1
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-689.d2fbku9n2b6wde.amplifyapp.com

LANGUAGE python AS series USING LINK 'http://localhost:8815';
```

## 5. Use your functions in RisingWave
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wangrunji0408 Can you provide known limitations for creating/using UDFs in RIsingWave at this stage?

Copy link
Contributor

@wangrunji0408 wangrunji0408 Mar 28, 2023

Choose a reason for hiding this comment

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

  1. ARRAY and JSONB types are not supported now. We will add them soon.
  2. For STRUCT types, field names must be consistent between Python and SQL definitions. Otherwise it will be considered a type mismatch. This requirement may be relaxed in the future.

@@ -310,6 +310,10 @@ const sidebars = {
id: 'sql/query-syntax/query-syntax-with-clause',
label: 'WITH',
},
{
Copy link
Contributor Author

@CharlieSYH CharlieSYH Mar 28, 2023

Choose a reason for hiding this comment

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

@hengm3467 Should I add (a link to) CREATE FUNCTION to the sidebar under SQL - Commands?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@CharlieSYH Yes. Let's do that. And point to the new guide. This ensures findability via both self-navigation and search.


## Prerequisites

- Ensure that you have [Python](https://www.python.org/downloads/) installed on your computer.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please mention that the minimum supported version is Python 3.8.

Comment on lines 197 to 198
| **RETURNS** *return_type* | Specifies the data type of the return value from the UDF. |
| **RETURNS TABLE** | Specifies the structure of the table that the UDF returns. |
Copy link
Contributor

Choose a reason for hiding this comment

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

Please mention that the former is for scalar functions and the latter is for table functions. User should use either of them.

docs/sql/query-syntax/user-defined-functions.md Outdated Show resolved Hide resolved
LANGUAGE python AS series USING LINK 'http://localhost:8815';
```

## 5. Use your functions in RisingWave
Copy link
Contributor

@wangrunji0408 wangrunji0408 Mar 28, 2023

Choose a reason for hiding this comment

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

  1. ARRAY and JSONB types are not supported now. We will add them soon.
  2. For STRUCT types, field names must be consistent between Python and SQL definitions. Otherwise it will be considered a type mismatch. This requirement may be relaxed in the future.

description: Define your own functions with the help of the RisingWave UDF API for Python.
---

You can define your own functions (including table functions) and call these functions in RisingWave. With the user-defined function (UDF), you can tailor RisingWave to your needs and take advantage of the power and flexibility of Python to create complex and customized functionality for your data processing and analysis tasks.
Copy link
Collaborator

Choose a reason for hiding this comment

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

The second paragraph is a bit too wordy. Suggestion: ...-> ..of Python to perform complex and customized data processing and analysis tasks.


## 2. Define your functions in a Python file

To better demonstrate this step, we have prepared a sample script for you to try out. Please create a Python file with the name "udf.py" and insert the script below.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think file names should also be wrapped in code blocks. Correct me if I'm wrong.


#### Example

Here's the SQL statements for declaring the three UDFs defined in [step 2](#2-define-your-functions-in-a-python-file).
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here's -> Here are...

Copy link
Collaborator

@hengm3467 hengm3467 left a comment

Choose a reason for hiding this comment

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

Left some comments. Otherwise looks good to me. Really solid work. Thanks!

@CharlieSYH CharlieSYH merged commit 2678ead into main Apr 10, 2023
@CharlieSYH CharlieSYH deleted the udf-docs branch April 10, 2023 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document UDF
3 participants