Skip to content
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

Fix #14842 #14885

Merged
merged 1 commit into from
Jan 22, 2025
Merged

Fix #14842 #14885

merged 1 commit into from
Jan 22, 2025

Conversation

zhiburt
Copy link
Contributor

@zhiburt zhiburt commented Jan 21, 2025

Sorry was a little bit busy

close #14842

I've added a test but I'd check if it solved it.

cc: @fdncred


Unrelated

Recently got a pretty good format idea (zhiburt/tabled#472)
Just wanna highlight that we could probably experiment with it, if it being a bit elaborated.

It's sort of KV table which nushell already has,
But it's more for a default table where each row/record being rendered as a KV table.

It's not something super nice I guess but maybe it could get some appliance.
So yes pointing it out just in case.

Like these.

┌──────────────┬───────────────────────────────────────────────┐
│ Field        │ Value                                         │
├──────────────┼───────────────────────────────────────────────┤
│ Company      │ INTEL CORP                                    │
├──────────────┼───────────────────────────────────────────────┤
│ Street       │ 2200 MISSION COLLEGE BLVD, RNB-4-151          │
├──────────────┼───────────────────────────────────────────────┤
│ City         │ SANTA CLARA                                   │
├──────────────┼───────────────────────────────────────────────┤
│ ZIP code     │ 95054                                         │
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
│ Company      │ Apple Inc.                                    │
├──────────────┼───────────────────────────────────────────────┤
│ Street       │ ONE APPLE PARK WAY                            │
├──────────────┼───────────────────────────────────────────────┤
│ City         │ CUPERTINO                                     │
├──────────────┼───────────────────────────────────────────────┤
│ ZIP code     │ 95014                                         │
└──────────────┴───────────────────────────────────────────────┘


┌──────────────────────────────────────────────────────────────┐
│                         INTEL CORP                           │
├──────────────┬───────────────────────────────────────────────┤
│ Street       │ 2200 MISSION COLLEGE BLVD, RNB-4-151          │
├──────────────┼───────────────────────────────────────────────┤
│ City         │ SANTA CLARA                                   │
├──────────────┼───────────────────────────────────────────────┤
│ ZIP code     │ 95054                                         │
├──────────────┴───────────────────────────────────────────────┤
│                         Apple Inc.                           │
├──────────────┬───────────────────────────────────────────────┤
│ Street       │ ONE APPLE PARK WAY                            │
├──────────────┼───────────────────────────────────────────────┤
│ City         │ CUPERTINO                                     │
├──────────────┼───────────────────────────────────────────────┤
│ ZIP code     │ 95014                                         │
└──────────────┴───────────────────────────────────────────────┘

PS: Now thinking about it,
it's sort of like doing a iteration over rows and building a current KV table,
Which is interesting cause we could do it row by row, in which case doing CTRLC would not ruin build but got some data rendered.
All though it's a different kind of approach. Just saying.

@fdncred
Copy link
Collaborator

fdncred commented Jan 21, 2025

ya, that looks cool. I'm up for adding something like that. I'm just not sure how we'd indicate the default row/record. 🤔

Another thing I've wanted to do for a long time is specify column widths manually in a record. something like pipeline | table --column-widths {name: 15, type: 5, size 4, modified: 20}

@zhiburt
Copy link
Contributor Author

zhiburt commented Jan 21, 2025

table --column-widths {name: 15, type: 5, size 4, modified: 20}

If adding a --oneline it could be then greatly optimized. (Meaning all content will be 1 line at max)
I mean tabled already has such a backend it's a bit limited on purpose.

But performance will had to be somewhat better.
*Must be :)


In this regard I wanna highlight an approach which some tools take, in regard of large datasets.
Is doing column-widths estimation based on first X rows. We get 1000 rows buffered do estimations and then basically treat all other rows as if they were as large as the max from the batch.

It's considered also a performance optimization.


Hmmmm now thinking about .... 😄

I guess even current approach could be optimized.
At present we are doing calculations of all columns and then do remove them.
Whether we could do 1 by 1 and remove them right when we can't fit in.

Well it's a small but if there's lots of columns measurable optimization.
*Must be :)

@fdncred
Copy link
Collaborator

fdncred commented Jan 21, 2025

We're definitely up for buffering x amount to estimate widths. I wrote something like this with our original table implementation a long time ago, but it was really to try and get emoji to line up properly. I now know that emoji is a hard problem, so I'm not as concerned with it these days. I'd still like to be able to manually specify column widths at some point because the estimates will never be 100% perfect.

@fdncred fdncred added tabled Issues about our new table renderer (tabled) pr:bugfix This PR fixes some bug labels Jan 22, 2025
@fdncred
Copy link
Collaborator

fdncred commented Jan 22, 2025

Thanks! This PR looks good. I'm looking forward to seeing the other parts of our conversation prototyped somewhere.

@fdncred fdncred merged commit 9a0ae7c into nushell:main Jan 22, 2025
15 checks passed
@github-actions github-actions bot added this to the v0.102.0 milestone Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:bugfix This PR fixes some bug tabled Issues about our new table renderer (tabled)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

index column does not get collapsed to # when rendered with table command
2 participants