Skip to content

Comments

Turn jsonb stringify functions into separate functions#32055

Merged
antiguru merged 1 commit intoMaterializeInc:mainfrom
antiguru:jsonb_stringify
Apr 1, 2025
Merged

Turn jsonb stringify functions into separate functions#32055
antiguru merged 1 commit intoMaterializeInc:mainfrom
antiguru:jsonb_stringify

Conversation

@antiguru
Copy link
Member

Some of the jsonb functions can be used in contexts where the output is either jsonb or strings. Previously, we'd encode this as part of the function call by supplying a bool field. This is an abstraction leak and instead it would be better to have separate functions.

This change absorbs the stringify parameter into different functions. No behavior change expected.

Checklist

  • This PR has adequate test coverage / QA involvement has been duly considered. (trigger-ci for additional test/nightly runs)
  • This PR has an associated up-to-date design doc, is a design doc (template), or is sufficiently small to not require a design.
  • If this PR evolves an existing $T ⇔ Proto$T mapping (possibly in a backwards-incompatible way), then it is tagged with a T-proto label.
  • If this PR will require changes to cloud orchestration or tests, there is a companion cloud PR to account for those changes that is tagged with the release-blocker label (example).
  • If this PR includes major user-facing behavior changes, I have pinged the relevant PM to schedule a changelog post.

@antiguru antiguru requested review from a team as code owners March 31, 2025 14:25
@antiguru antiguru requested review from aljoscha and ggevay March 31, 2025 14:25
Copy link
Contributor

@ggevay ggevay left a comment

Choose a reason for hiding this comment

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

LGTM; the CI failures have straightforward fixes:

The lint is just the protobuf compatibility stuff, also discussed on slack.

The cargo test fail is due to some mzreflect-based tests. There are several occurrences of the functions that are being modified in the PR. For example

(call_binary (jsonb_get_string true) #0 ("created_ms" string))

has to be modified to

(call_binary (jsonb_get_string_stringify) #0 ("created_ms" string))

There are also some mzreflect-based tests that are not complaining, because it seems mzreflect just ignores the extra argument, but still should be changed. For example, there is a

(call_binary (jsonb_get_int64 false) #1 #0))

in src/expr/tests/testdata/reduce.
Normally, I'd debug why mzreflect is ignoring the extra argument, but mzreflect is on its way out, so we can just quickly fix the individual tests. I recommend grepping for jsonb_get_string true/jsonb_get_string false with all the modified functions to find all relevant tests.

The slt fail in test/sqllogictest/distinct_arrangements.slt is because some arrangement names mention JsonbGetString where this is part of the arrangement key in some builtin objects. This just needs a --rewrite-results.

google.protobuf.Empty jsonb_get_string = 99;
google.protobuf.Empty jsonb_get_string_stringify = 198;
google.protobuf.Empty jsonb_get_path = 100;
google.protobuf.Empty jsonb_get_path_stringify = 199;
Copy link
Contributor

Choose a reason for hiding this comment

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

CI is complaining about compatibility, but as discussed on Slack, you could put an ignore into this file.

@antiguru antiguru enabled auto-merge (squash) April 1, 2025 13:30
@antiguru
Copy link
Member Author

antiguru commented Apr 1, 2025

Thanks for the review!

Some of the jsonb functions can be used in contexts where the output is
either jsonb or strings. Previously, we'd encode this as part of the
function call by supplying a `bool` field. This is an abstraction leak and
instead it would be better to have separate functions.

This change absorbs the `stringify` parameter into different functions. No
behavior change expected.

Signed-off-by: Moritz Hoffmann <mh@materialize.com>
@antiguru antiguru merged commit de4665a into MaterializeInc:main Apr 1, 2025
80 checks passed
@antiguru antiguru deleted the jsonb_stringify branch April 1, 2025 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants