⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@paleolimbot
Copy link
Member

@paleolimbot paleolimbot commented Jan 30, 2026

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.

Reprex from original issue now renders without panicing:

import sedona.db

sd = sedona.db.connect()

buildings_url = (
    "s3://overturemaps-us-west-2/release/2026-01-21.0/theme=buildings/type=building/"
)

target_wkt = (
    "POLYGON ((-73.21 44.03, -73.21 43.98, -73.11 43.97, -73.12 44.03, -73.21 44.03))"
)

sd.read_parquet(
    buildings_url,
    options={"aws.skip_signature": True, "aws.region": "us-west-2"},
).to_view("buildings")

sd.sql(f"""
SELECT count(*) FROM buildings
WHERE ST_Intersects(geometry, ST_SetSRID(ST_GeomFromText('{target_wkt}'), 4326))
""").explain("extended").show()
#> ...very, very long output that does not crash

Closes #388.

@paleolimbot paleolimbot marked this pull request as ready for review January 30, 2026 23:04
@paleolimbot paleolimbot requested a review from Copilot January 30, 2026 23:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a panic that occurred when displaying tables with unexpectedly large content, particularly in explain plans. The fix addresses unchecked arithmetic operations that could cause integer overflow by introducing saturating addition and conservative maximum width limits.

Changes:

  • Introduced WIDTH_MAX constant (32,000) to prevent overflow in comfy table's internal arithmetic
  • Replaced unchecked addition with saturating_add throughout width calculations
  • Added content truncation in the cell method to limit string length to WIDTH_MAX

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// 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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

for col in &self.columns {
// Padding on both sides plus separator
total_size += 3;
total_size = total_size.saturating_add(3);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not very clear to me why "3" here? Maybe define a constant or add comments?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a comment // Padding on both sides plus separator but I am happy to clarify in a follow-up if needed!

@paleolimbot paleolimbot merged commit e8147cf into apache:main Feb 9, 2026
15 checks passed
@paleolimbot paleolimbot deleted the show-extra-wide-values branch February 9, 2026 23:21
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.

Attempt to show() value > 65536 characters wide results in a panic

2 participants