Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add FPHA (floating-point homogeneous array) arg support to JSON.SET#4011

Merged
petyaslavova merged 6 commits into
masterfrom
ps_add_json_set_fpha_arg
Apr 8, 2026
Merged

Add FPHA (floating-point homogeneous array) arg support to JSON.SET#4011
petyaslavova merged 6 commits into
masterfrom
ps_add_json_set_fpha_arg

Conversation

@petyaslavova

@petyaslavova petyaslavova commented Mar 30, 2026

Copy link
Copy Markdown
Collaborator

Add FPHA (floating-point homogeneous array) support to JSON.SET

This PR adds support for the FPHA (Floating-Point Homogeneous Array) argument in JSON.SET, available in Redis 8.8+. The new fpha parameter allows users to specify a floating-point storage type (BF16, FP16, FP32, or FP64) for numeric arrays, enabling memory optimization by forcing Redis to store all floating-point values in an array using a specific precision.
The parameter is added to set(), set_file(), and set_path() methods, with full sync/async parity including all @overload signatures and the AsyncJSON class overrides.

A new FPHAType(str, Enum) is introduced and exported from redis.commands.json for convenient, type-safe usage (e.g., fpha=FPHAType.FP32). Plain strings are also accepted and validated client-side — invalid values raise a DataError before reaching the server. Case-insensitive string input is supported (e.g., "fp32" is normalized to "FP32").

Tests cover all FPHA types, enum usage, case-insensitive input, combination with NX/XX modifiers, and client-side validation of invalid types. Server-dependent tests are gated behind @skip_if_server_version_lt("8.7.0"), while client-side validation tests run unconditionally.


Note

Medium Risk
Adds a new argument that changes how JSON.SET commands are constructed and validated client-side; behavior now depends on server support/version and incorrect handling could affect writes for callers using the new option.

Overview
Adds support for RedisJSON’s FPHA modifier on JSON.SET via a new optional fpha parameter across sync and asyncio JSON clients, including set(), set_file(), and set_path().

Introduces an FPHAType enum with case-insensitive string normalization and client-side validation (raising DataError for invalid values), and appends FPHA <type> to the executed command when provided. Tests (sync + asyncio) cover valid types, enum usage, NX/XX interactions, case-insensitivity, and invalid-type errors, with server-dependent cases gated by skip_if_server_version_lt.

Reviewed by Cursor Bugbot for commit b5effe9. Bugbot is set up for automated code reviews on this repo. Configure here.

@petyaslavova petyaslavova added the feature New feature label Mar 30, 2026
@jit-ci

jit-ci Bot commented Mar 30, 2026

Copy link
Copy Markdown

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread tests/test_json.py
Comment thread redis/commands/json/commands.py Outdated
@petyaslavova petyaslavova merged commit 7021617 into master Apr 8, 2026
128 of 130 checks passed
@petyaslavova petyaslavova deleted the ps_add_json_set_fpha_arg branch April 8, 2026 11:07
petyaslavova added a commit that referenced this pull request May 26, 2026
…4011)

* Add FPHA (floating-point homogeneous array) arg support to JSON.SET

* Move FPHA data validation into FPHAType enum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants