Skip to content

bug fix: truncate wide columns in print.data.table #7788

Open
venom1204 wants to merge 6 commits into
masterfrom
issue771188
Open

bug fix: truncate wide columns in print.data.table #7788
venom1204 wants to merge 6 commits into
masterfrom
issue771188

Conversation

@venom1204

@venom1204 venom1204 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

closes #7718
sorry for the new pr ,as there was some error in the previous one

  • here is the summary of teh previous pr

the earlier pr mainly used a fixed getOption("width") - 5L style truncation approach which worked for some simple cases but failed once row labels became larger (for example 1000000:) because the full rendered line width was not being accounted for correctly.

  • in this updated implementation, the truncation width is now calculated dynamically using the actual row label width and console width instead of a fixed constant.
  • i also added a saftey handelling using allowNA=TRUE in nchar() calls to avoid invalid width failures during tests,while preserving thr original datatable.prettyprint.char.

with these changes the ouput now takes the full options(width) limit for the entire rendered line.
hi @joshhwuu @tdhock can you please have a look at it when you got time ,
thanks

@venom1204 venom1204 changed the title new pr bug fix: truncate wide columns in print.data.table Jun 10, 2026
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.85%. Comparing base (d65e46f) to head (6a1d3a8).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7788   +/-   ##
=======================================
  Coverage   98.85%   98.85%           
=======================================
  Files          87       87           
  Lines       17128    17137    +9     
=======================================
+ Hits        16932    16941    +9     
  Misses        196      196           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
  • HEAD=issue771188 faster P<0.001 for DT[by] max regression fixed in #7480
    Comparison Plot

Generated via commit 6a1d3a8

Download link for the artifact containing the test results: ↓ atime-results.zip

Task Duration
R setup and installing dependencies 2 minutes and 56 seconds
Installing different package versions 24 seconds
Running and plotting the test cases 5 minutes and 28 seconds

Comment thread inst/tests/tests.Rraw
Comment thread R/print.data.table.R Outdated
}

format_col.default = function(x, ...) {
dots = list(...)

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.

could you explain the motivation behind this dots = list(...) pattern? imo it makes the code a lot harder to read, would rather us be more specific about method contracts and declare it as a parameter

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.

it was done to avoid the codoc mismatch between teh doc and the code , now i have updated the doc and reverted it

Comment thread R/print.data.table.R Outdated
Comment thread R/print.data.table.R Outdated
Comment thread NEWS.md Outdated

11. `between()` now supports `Date` and `IDate` bounds with default `NAbounds=TRUE`, avoiding errors like "Not yet implemented NAbounds=TRUE for this non-numeric and non-character type" when date bounds contain `NA`, [#7281](https://github.com/Rdatatable/data.table/issues/7281). Thanks @grcatlin for the report and fix, and @ben-schwen and @aitap for assistance.

12. `print.data.table()` now correctly truncates long character columns and list-column summaries to avoid horizontal console overflow, [#7718](https://github.com/Rdatatable/data.table/issues/7718). When `datatable.prettyprint.char` is `NULL` (the default), the truncation limit is now dynamically calculated as `getOption("width") - 5L`. Thanks @tdhock for the report and @venom1204 for the fix.

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.

is this still true? also we may not want to be too verbose about implementation details here

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.

sorry for the news entry I simply gave the previous file forgot to modify it.

@tdhock tdhock left a comment

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.

this looks good, but can you please add some examples in Rd and PR comments (with output) ?

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.

print should abbreviate columns larger than options(width)?

3 participants