-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for meta-velox canceled.
|
CC @rui-mo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CMake 👍
There was a problem hiding this 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.
velox/docs/functions/spark/json.rst
Outdated
@@ -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 |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Support Spark
to_json
function: https://docs.databricks.com/en/sql/language-manual/functions/to_json.html