Skip to content
This repository was archived by the owner on Aug 12, 2026. It is now read-only.

ValkeyJSON RFC - #2

Merged
madolson merged 15 commits into
valkey-io:mainfrom
joehu21:json_rfc
Aug 12, 2024
Merged

madolson merged 15 commits into
valkey-io:mainfrom
joehu21:json_rfc

Conversation

@joehu21

@joehu21 joehu21 commented Jul 17, 2024 •

Copy link
Copy Markdown
Contributor

The proposed Valkey JSON module, named ValkeyJSON, supports the native JavaScript Object Notation (JSON) format to encode complex datasets inside Valkey. It is compliant with RFC7159 and ECMA-404 JSON data interchange standard. With this feature, users can natively store, query, and modify JSON data structures in ValKey using the popular JSONPath query language. To help users migrate from Redis and RedisJSON, as well as capitalize on existing OSS RedisJSON client libraries, the module is designed to be API-compatible and RDB-compatible with Redis Ltd.’s RedisJSON v2.

joehu21 pushed a commit to joehu21/valkey-rfc that referenced this pull request Jul 17, 2024
Signed-off-by: Joe Hu <jowhuw@amazon.com>
Signed-off-by: Joe Hu <jowhuw@amazon.com>

@zuiderkwast zuiderkwast left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

The content looks very good in general, but I think some should be moved from design considerations to specification. I don't know if others agree. The RFC process is new for all of us.

Comment thread JSON.md Outdated
Comment thread JSON.md Outdated
Comment thread JSON.md Outdated
@zuiderkwast

Copy link
Copy Markdown
Contributor

One more thing: Valkey is spelled with lowercase "k". 😄

@joehu21

joehu21 commented Jul 26, 2024

Copy link
Copy Markdown
Contributor Author

Updated all occurrences of "ValKey" to "Valkey", including the work in graphs.

Signed-off-by: Joe Hu <jowhuw@amazon.com>
@joehu21 joehu21 changed the title ValKey JSON module RFC Jul 26, 2024
@joehu21 joehu21 changed the title ValKeyJSON RFC Jul 26, 2024
Joe Hu added 2 commits July 26, 2024 13:00
Signed-off-by: Joe Hu <jowhuw@amazon.com>
Signed-off-by: Joe Hu <jowhuw@amazon.com>

@zuiderkwast zuiderkwast left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@zuiderkwast
zuiderkwast requested a review from madolson July 28, 2024 03:57
@zuiderkwast

Copy link
Copy Markdown
Contributor

@madolson do you want to take a quick look before we merge this?

@madolson madolson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@zuiderkwast since it becomes harder to comment after it's merged. I thought we should let everyone comment first before merging it as a proposal.

Comment thread ValkeyJSON.md Outdated
Comment thread ValkeyJSON.md Outdated
Comment thread ValkeyJSON.md Outdated
@zuiderkwast

Copy link
Copy Markdown
Contributor

@zuiderkwast since it becomes harder to comment after it's merged. I thought we should let everyone comment first before merging it as a proposal.

Sounds reasonable. If this is the process we want, we should probably clarify that in the README at some point. The README says we'll merge the PR once the style and format is fine.

Comment thread ValkeyJSON.md Outdated
Comment thread ValkeyJSON.md Outdated
Comment thread ValkeyJSON.md Outdated
Comment thread ValkeyJSON.md Outdated
Comment thread ValkeyJSON.md Outdated
Comment thread ValkeyJSON.md Outdated
Comment thread ValkeyJSON.md Outdated
Comment thread ValkeyJSON.md Outdated
Comment thread ValkeyJSON.md Outdated
Comment thread ValkeyJSON.md Outdated
Comment thread ValkeyJSON.md Outdated
Comment thread ValkeyJSON.md Outdated
Signed-off-by: Joe Hu <jowhuw@amazon.com>
Joe Hu added 2 commits July 30, 2024 11:28
…ause the command API refers to JSON query syntax

Signed-off-by: Joe Hu <jowhuw@amazon.com>
Signed-off-by: Joe Hu <jowhuw@amazon.com>
@bbarani

bbarani commented Aug 5, 2024

Copy link
Copy Markdown

@madolson @daniel-house @zuiderkwast Whats the next step here? Are we good to merge this PR?

Comment thread ValkeyJSON.md Outdated
Comment thread ValkeyJSON.md
Comment on lines +167 to +168
The API is compatible with RedisJSON v2. Note that API compatibility here means our command API is a superset of RedisJSON API.
For example, we have command “JSON.DEBUG DEPTH” and “JSON.DEBUG FIELDS”, while they do not.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would like to know why not have two separate commands, JSON.DEPTH and JSON.FIELDs ? Having a debug command doesn't really make that much sense.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The intent is to avoid diverging from RedisJSON unnecessarily. If we introduce new commands, they won't be supported by the existing OSS RedisJSON client libraries. If we have our own ValkeyJSON client library ecosystem, then it would make sense to have them as new commands, instead of sub-commands of JSON.DEBUG.

@joehu21 joehu21 Aug 6, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In the RFC, “JSON.DEBUG DEPTH” and “JSON.DEBUG FIELDS” are the only extension. We consider "depth of a json tree/sub-tree" and "number of fields in a json tree/sub-tree" as debug information. Hence, they are subcommands of JSON.DEBUG. However, it doesn't mean in the future, all extensions should be subcommands of JSON.DEBUG. I am open to adding new JSON commands in the future if necessary.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I tried to look up the list of commands elsewhere and my best source for the RedisJSON v2 API didn't agree with this. Probably I am not looking in the right place. Please point to it for me.

I saw JSON.DEBUG without arguments (which is not in the PR), and JSON.DEBUG MEMORY (which is), but not JSON.DEBUG HELP (an extension?). I also saw JSON.MSET (an oversight?).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I also saw JSON.MSET (an oversight?)

Yeah, we missed this. This was added sort of randomly by Redis at some point.

@joehu21 joehu21 Aug 6, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

RedisJSON API is evolving. Missed JSON.MSET. Will add it to the RFC when I get a chance.

Interestingly, their documentation doesn't seem to match the latest docker image redis/redis-stack:latest. I don't see json.mset:

docker run -p 6379:6379 redis/redis-stack:latest
...
% ./redis-cli command |grep -i json
json.arrtrim
json.arrpop
json.clear
json.arrappend
json.objlen
json.nummultby
json.mget
json.strappend
json.toggle
json.get
json.arrlen
json.strlen
json.numpowby
json.resp
json.type
json.forget
json.arrindex
json.arrinsert
json.set
json.del
json.numincrby
json.debug
json.objkeys

I saw JSON.DEBUG without arguments (which is not in the PR), and JSON.DEBUG MEMORY (which is), but not JSON.DEBUG HELP (an extension?).

That's not what I see in the docker image. Using the same docker image, I see JSON.DEBUG HELP is valid and JSON.DEBUG is invalid. I think this behavior matches their API doc of JSON.DEBUG - "This is a container command for debugging related tasks." My understanding is that "container command" doesn't necessarily mean JSON.DEBUG without arguments is a valid command.

127.0.0.1:6379> json.debug help
1) "MEMORY <key> [path] - reports memory usage"
2) "HELP                - this message"
127.0.0.1:6379> json.debug
(error) ERR wrong number of arguments for 'json.debug' command

@joehu21 joehu21 Aug 6, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just realized the docker image above has json.numpowby which I was not aware of. However, I don't see this command in RedisJSON API documentation. Not sure what we'll do with it.

Anyway, we do observe the following with RedisJSON:

  1. Their published API may not match the latest docker binary.
  2. Occasionally they add some new commands.
  3. OSS JSON client libraries may not match the latest API doc and/or docker binary.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have a feeling it might be deprecated. I found out the json.nummultiply is deprecated as per https://github.com/redis/redis-py/blob/1cbb97ecd7a0bf87aec332a257b589919385d90d/redis/commands/json/commands.py#L144C6-L144C25.

@madolson

madolson commented Aug 5, 2024 •

Copy link
Copy Markdown
Member

This RFC looks good to me as well. As per our updated guidance, @valkey-io/core-team please take a look and review offline. We'll schedule to review this next week in our team meeting: 2024-08-12. I'll send an invite to Joe.

Co-authored-by: Madelyn Olson <madelyneolson@gmail.com>
Signed-off-by: Joe Hu <jowhuw@amazon.com>

@enjoy-binbin enjoy-binbin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i did not review all the lines carefully, LGTM with a rough look.

Comment thread ValkeyJSON.md Outdated
Comment thread ValkeyJSON.md Outdated
Comment thread ValkeyJSON.md Outdated
Comment thread ValkeyJSON.md Outdated
Comment thread ValkeyJSON.md Outdated
Comment thread ValkeyJSON.md Outdated
Signed-off-by: Joe Hu <jowhuw@amazon.com>
Joe Hu and others added 3 commits August 8, 2024 15:59
Co-authored-by: Binbin <binloveplay1314@qq.com>
Signed-off-by: Joe Hu <jowhuw@amazon.com>
Co-authored-by: Binbin <binloveplay1314@qq.com>
Signed-off-by: Joe Hu <jowhuw@amazon.com>
Co-authored-by: Binbin <binloveplay1314@qq.com>
Signed-off-by: Joe Hu <jowhuw@amazon.com>
Comment thread ValkeyJSON.md
Comment thread ValkeyJSON.md Outdated
Signed-off-by: Joe Hu <jowhuw@amazon.com>
Co-authored-by: Binbin <binloveplay1314@qq.com>
Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Comment thread ValkeyJSON.md Outdated
Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.