Skip to content

FracturedJson table formatting - #2879

Merged
lemire merged 9 commits into
simdjson:masterfrom
maxbachmann:table
Sep 26, 2026
Merged

lemire merged 9 commits into
simdjson:masterfrom
maxbachmann:table

Conversation

@maxbachmann

@maxbachmann maxbachmann commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

This is based on top of #2878 and updates the table formatting to be closer to FracturedJson. This is a pretty large change, but it wasn't really simple to break this down further since the table and compact array formatting all do the same recursive alignment things.

Aside from unsupported options and presumably some edge cases we should now match the behavior of FracturedJson:

  • we do now properly handle line breaks
  • we sort keys by their first occurrence which keeps the order stable most of the time unlike our alphabetical order before
  • we skip missing keys by adding spaces
  • we handle the alignment recursively both for table and compact array
    • when the recursive alignment doesn't fit compact array falls back to table
    • when the recursive alignment doesn't fit for table it doesn't align the deepest nested elements until it fits. If it still doesn't fit it falls back to the normal expanded layout

Follow up commits:

  • we allow setting the placement for commas in tables
  • we allow setting left/right align for numbers
  • using same defaults

@lemire

lemire commented Sep 24, 2026

Copy link
Copy Markdown
Member

Running tests.

# Conflicts:
#	doc/builder.md
#	include/simdjson/dom/fractured_json-inl.h
#	include/simdjson/dom/fractured_json.h
#	include/simdjson/internal/fractured_formatter.h
#	tests/dom/nan_inf_tests.cpp
#	tests/fractured_json_tests.cpp
* Placement of commas relative to column padding in table-formatted rows
* (default: before_padding_except_numbers).
*/
table_comma_placement comma_placement = table_comma_placement::before_padding_except_numbers;

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.

I wasn't sure about naming since I can't call both table_comma_placement

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.

Same for number_alignment

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.

Seems fine to me.

@maxbachmann

maxbachmann commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor Author

If preferred I can move the follow up commits into a separate PR. They can also just be cherry picked separately.

Features we don't have from the latest released version

  • CommentPadding/CommentPolicy/PreserveBlankLines/AllowTrailingCommas (not relevant for simdjson)
  • EolStyle \n vs \r\n
  • MaxPropNamePadding/ColonBeforePropNamePadding (didn't really look into what they do exactly so far)
  • NumberListAlignment Decimal + Normalize (Bit of a pain since it's no longer the widest cell determining the column width)
  • UseTabToIndent
  • PrefixString

I personally don't need any of these missing features so I will probably not continue work on this beyond this PR aside from fixing edge cases if I happen to run into them.

@lemire

lemire commented Sep 25, 2026

Copy link
Copy Markdown
Member

@maxbachmann I am reviewing.

Note that this PR is possibly the last one before our upcoming major release.

@lemire

lemire commented Sep 25, 2026

Copy link
Copy Markdown
Member

@maxbachmann Please consider maxbachmann#1

If you are good with all that, I would stop there, and release a major simdjson version.

- fix the example output (keys in first-occurrence order, no simple
  bracket padding, aligned columns)
- enable_table_format no longer requires identical keys; describe the
  merged columns and the fallback behavior
- clarify max_table_row_complexity and min_compact_array_row_items
- fix the nested_bracket_padding examples
- list the comma_placement and number_alignment values
- note which FracturedJson options are unsupported, that the default
  number alignment differs, and that min_table_rows and
  table_similarity_threshold were removed
@lemire
lemire merged commit 645e5c8 into simdjson:master Sep 26, 2026
63 of 115 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants