refactor(query): Enhance OBJECT_INSERT
and Rename JSON Functions
#18199
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/
Summary
This PR introduces two key changes to enhance Databend's compatibility with Snowflake, specifically focusing on JSON/OBJECT manipulation functions:
1.
OBJECT_INSERT
Enhancement:Behavior Modification: The
OBJECT_INSERT
function is modified to align with Snowflake's behavior. When thevalue
argument isNULL
and theupdate_flag
argument is set toTRUE
, the function will now delete the correspondingkey
from the object, rather than keep the orignal key. The new key can support any types as well as string type, and the key will be auto converted to string.Example:
2. Function Renaming for Snowflake Compatibility:
Function Renames: The following JSON-related functions have been renamed to align with Snowflake's naming conventions:
json_array
array_construct
json_array_distinct
array_distinct
json_array_except
array_except
json_array_insert
array_insert
json_array_intersection
array_intersection
json_array_overlap
array_overlap
json_object_insert
object_insert
json_object_delete
object_delete
json_object_pick
object_pick
json_object
object_construct
try_json_object
try_object_construct
json_object_keep_null
object_construct_keep_null
try_json_object_keep_null
try_object_construct_keep_null
Aliases: To ensure backward compatibility, the original function names are retained as aliases. Users can continue to use the old names without any code changes. The new names are preferred for new development.
Tests
Type of change
This change is