-
Notifications
You must be signed in to change notification settings - Fork 19.8k
fix(dataset): detect dimensions across sparse object-row datasets #21699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
plainheart
merged 2 commits into
apache:master
from
rahul37wallst-sudo:fix-11322-object-row-dimensions
Jul 23, 2026
+96
−6
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this issue. I agree that collecting keys from all object rows is necessary to handle sparse fields correctly, but it also adds an
O(total number of object keys)pre-scan during source initialization whendimensionsis not explicitly provided.Could you please add a small performance check to verify that this does not introduce a noticeable overhead for large datasets? It would be useful to compare:
dataset.dimensionsis explicitly providedFor example, testing with around 100k rows would be helpful, covering both stable object shapes and sparse keys that appear only in later rows. Measuring
setOptionor source creation time should be sufficient. This would help us assess the practical impact of the additional scan.Also, the current implementation creates a
keys(obj)array and uses a callback for every row. If this shows up in the benchmark, could we avoid the intermediate allocation and callback overhead with something like:This preserves the intended semantics, collecting every field while retaining first-seen order, while potentially reducing allocations and per-row overhead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. I ran a local benchmark with 100k object rows on Windows / Node 22.18.0, using two warmups and nine measured runs.
Median source-creation times:
dataset.dimensions0.02 ms.I also isolated the collector implementation:
keys(obj)plus callback: 38.47 ms stable / 34.86 ms sparse.for...inplushasOwn: 3.10 ms stable / 3.67 ms sparse.I updated the implementation to the allocation-free
for...inloop in commitb6ace83a5. The full scan remains O(total object keys), as required to discover late sparse fields, but the measured source-initialization overhead was about 5 ms for 100k three-field rows. Supplyingdataset.dimensionscontinues to bypass the scan.The focused regression tests,
npm run lint,npm run checktype, andgit diff --checkall pass.