You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@sedona.apache.org by "paleolimbot (via GitHub)" <gi...@apache.org> on 2026/01/30 21:48:37 UTC
[PR] fix(rust/sedona): Fix panic when displaying very long content [sedona-db]
paleolimbot opened a new pull request, #565:
URL: https://github.com/apache/sedona-db/pull/565
Fixes a panic when the content of a table is unexpectedly large. The first issue I hit this was was explain plans.
In addition to at least one issue here, there is quite a lot of unchecked addition in the underlying renderer, which we work around by truncating any u16s or strings to 32,000.
Closes #388.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(rust/sedona): Fix panic when displaying very long content [sedona-db]
Posted by "paleolimbot (via GitHub)" <gi...@apache.org>.
paleolimbot commented on code in PR #565:
URL: https://github.com/apache/sedona-db/pull/565#discussion_r2785014696
##########
rust/sedona/src/show.rs:
##########
@@ -521,7 +533,12 @@ impl DisplayColumn {
/// Create a cell for this column. This is where alignment for numeric
/// output is applied.
fn cell<T: ToString>(&self, content: T) -> Cell {
- let cell = Cell::new(content).set_delimiter('\0');
+ // Never return content longer than WIDTH_MAX because comfy table may
+ // do arithmetic with it without checking for overflow.
+ let content_str = content.to_string();
+ let content_safe: String = content_str.chars().take(WIDTH_MAX as usize).collect();
Review Comment:
These are uniocde widths! https://doc.rust-lang.org/std/primitive.str.html#method.chars . (We also have tests for unicode output to ensure the character math works for that).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(rust/sedona): Fix panic when displaying very long content [sedona-db]
Posted by "zhangfengcdt (via GitHub)" <gi...@apache.org>.
zhangfengcdt commented on code in PR #565:
URL: https://github.com/apache/sedona-db/pull/565#discussion_r2783386223
##########
rust/sedona/src/show.rs:
##########
@@ -521,7 +533,12 @@ impl DisplayColumn {
/// Create a cell for this column. This is where alignment for numeric
/// output is applied.
fn cell<T: ToString>(&self, content: T) -> Cell {
- let cell = Cell::new(content).set_delimiter('\0');
+ // Never return content longer than WIDTH_MAX because comfy table may
+ // do arithmetic with it without checking for overflow.
+ let content_str = content.to_string();
+ let content_safe: String = content_str.chars().take(WIDTH_MAX as usize).collect();
Review Comment:
This seems to be limiting the character length, but not display length (width). They may not be the same or may have issues with multi-byte characters. Maybe use unicode width string handling?
##########
rust/sedona/src/show.rs:
##########
@@ -316,29 +322,32 @@ impl<'a> DisplayTable<'a> {
/// number of characters in other columns (based on user options).
fn minimum_width(&self) -> Result<u16> {
// Leftmost border
- let mut total_size = 1;
- let mut hidden_count = 0;
+ let mut total_size: u16 = 1;
+ let mut hidden_count: u16 = 0;
for col in &self.columns {
// Padding on both sides plus separator
- total_size += 3;
+ total_size = total_size.saturating_add(3);
Review Comment:
Not very clear to me why "3" here? Maybe define a constant or add comments?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(rust/sedona): Fix panic when displaying very long content [sedona-db]
Posted by "paleolimbot (via GitHub)" <gi...@apache.org>.
paleolimbot merged PR #565:
URL: https://github.com/apache/sedona-db/pull/565
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(rust/sedona): Fix panic when displaying very long content [sedona-db]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #565:
URL: https://github.com/apache/sedona-db/pull/565#discussion_r2748322138
##########
rust/sedona/src/show.rs:
##########
@@ -521,7 +533,19 @@ impl DisplayColumn {
/// Create a cell for this column. This is where alignment for numeric
/// output is applied.
fn cell<T: ToString>(&self, content: T) -> Cell {
- let cell = Cell::new(content).set_delimiter('\0');
+ // Never return content longer than WIDTH_MAX because comfy table may
+ // do arithmetic with it without checking for overflow.
+ let content_str = content.to_string();
+ let content_safe = if content_str.chars().count() > WIDTH_MAX as usize {
+ content_str
+ .chars()
+ .take(WIDTH_MAX as usize)
+ .collect::<String>()
+ } else {
+ content_str
+ };
Review Comment:
Counting all characters before truncation is inefficient for very long strings. The `.chars().count()` call iterates through the entire string even when it exceeds WIDTH_MAX. Consider using `.chars().take(WIDTH_MAX as usize + 1).count()` to avoid processing characters beyond the limit, or simply always truncate with `.chars().take(WIDTH_MAX as usize).collect()` without the conditional check.
```suggestion
let content_safe: String = content_str
.chars()
.take(WIDTH_MAX as usize)
.collect();
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(rust/sedona): Fix panic when displaying very long content [sedona-db]
Posted by "paleolimbot (via GitHub)" <gi...@apache.org>.
paleolimbot commented on code in PR #565:
URL: https://github.com/apache/sedona-db/pull/565#discussion_r2785016230
##########
rust/sedona/src/show.rs:
##########
@@ -316,29 +322,32 @@ impl<'a> DisplayTable<'a> {
/// number of characters in other columns (based on user options).
fn minimum_width(&self) -> Result<u16> {
// Leftmost border
- let mut total_size = 1;
- let mut hidden_count = 0;
+ let mut total_size: u16 = 1;
+ let mut hidden_count: u16 = 0;
for col in &self.columns {
// Padding on both sides plus separator
- total_size += 3;
+ total_size = total_size.saturating_add(3);
Review Comment:
There is a comment `// Padding on both sides plus separator` but I am happy to clarify in a follow-up if needed!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org