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

feat: Add Spark to_json function #11995

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

wecharyu
Copy link

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 31, 2024
Copy link

netlify bot commented Dec 31, 2024

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit e0e7f28
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/6790d51185bfbc0008cffa9a

@zhouyuan
Copy link
Contributor

zhouyuan commented Jan 2, 2025

CC @rui-mo

Copy link
Collaborator

@assignUser assignUser left a comment

Choose a reason for hiding this comment

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

CMake 👍

Copy link
Collaborator

@rui-mo rui-mo left a comment

Choose a reason for hiding this comment

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

Thanks! Added some initial comments.

@@ -44,3 +44,14 @@ JSON Functions
SELECT json_object_keys(''); -- NULL
SELECT json_object_keys(1); -- NULL
SELECT json_object_keys('"hello"'); -- NULL

.. spark:function:: to_json(json_object) -> jsonString
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: use camel-case naming style for 'json_object'.


namespace facebook::velox::functions::sparksql {

class ToJsonCallToSpecialForm : public exec::FunctionCallToSpecialForm {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since the result type is determined (varchar), we might don't need to implement 'to_json' as a special form. Special form is only used for the functions whose result type cannot be inferred from input type. For this case, we can implement it as a simple function.
More information on simple functions: https://github.com/facebookincubator/velox/blob/main/velox/docs/develop/scalar-functions.rst.

Copy link
Author

Choose a reason for hiding this comment

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

Remove the special form, pls take a look again.

@wecharyu wecharyu requested a review from rui-mo January 22, 2025 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants