Skip to content

feat(stdlib): jq entries commands#1653

Open
close2code-palm wants to merge 12 commits intovectordotdev:mainfrom
close2code-palm:feat/jq-entries-commands
Open

feat(stdlib): jq entries commands#1653
close2code-palm wants to merge 12 commits intovectordotdev:mainfrom
close2code-palm:feat/jq-entries-commands

Conversation

@close2code-palm
Copy link
Copy Markdown
Contributor

feat(stdlib): Add to_entries and from_entries functions, compatible with commands in jq tool

Summary

Implemented two functions for stdlib with tests
Closes #124

Change Type

  • Bug fix
  • New feature
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

How did you test this PR?

Added unit tests for general cases, ran the vector with my local VRL and made common transfers

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on
    our guidelines.
  • No. A maintainer will apply the "no-changelog" label to this PR.

Checklist

  • Our CONTRIBUTING.md is a good starting place.
  • If this PR introduces changes to LICENSE-3rdparty.csv, please
    run dd-rust-license-tool write and commit the changes. More details here.
  • For new VRL functions, please also create a sibling PR in Vector to document the new function.

Before to add documentation, I want to ensure that this feature is acceptable, as there was no activity in issue

References

@close2code-palm close2code-palm requested a review from a team as a code owner February 22, 2026 10:23
@close2code-palm close2code-palm changed the title Feat/jq entries commands feat(stdlib): jq entries commands Feb 22, 2026
@pront
Copy link
Copy Markdown
Member

pront commented Mar 20, 2026

@codex review

@pront
Copy link
Copy Markdown
Member

pront commented Mar 20, 2026

Apologies for the late review. Please fix and the merge conflicts and we will take a look.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ea98b04ca3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +30 to +32
let key = i64::try_from(index)
.map_err(|_| ValueError::OutOfRange(Kind::integer()))?;
Ok(build_entry(Value::from(key), value))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Emit string keys for array entries

In the array branch, to_entries stores each index as an integer key, but from_entries only accepts string keys (Value::Bytes) and rejects non-strings. This means a direct round-trip like from_entries(to_entries([1,2])) now fails with object keys must be strings, so the two new functions are not interoperable for arrays. Converting the index to a string when building each entry avoids this regression.

Useful? React with 👍 / 👎.

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.

Implementation preserves semantics of original tool, where commands are not opposite to each other

@github-actions
Copy link
Copy Markdown
Contributor

The docs/generated/ folder is out of date but I was unable to push the fix automatically.

Please run the following and commit the result:

./scripts/generate_docs.sh

@pront
Copy link
Copy Markdown
Member

pront commented Mar 23, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6bd0a1d1aa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@close2code-palm
Copy link
Copy Markdown
Contributor Author

I did a little research to know the difference between my implementation and jq`s specification. I found some interesting points. I had only the minimalistic conversion feature on my mind, but I can work on my PoC to keep feature as rich as it is in jq. Let me work on it.

@close2code-palm close2code-palm requested a review from a team as a code owner April 1, 2026 10:51
@jeff-morgan-dd jeff-morgan-dd self-assigned this Apr 1, 2026
@pront
Copy link
Copy Markdown
Member

pront commented Apr 2, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@pront
Copy link
Copy Markdown
Member

pront commented Apr 2, 2026

Please add a changelog to describe these new features.

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.

Add to_entries and from_entries to VRL

3 participants