Skip to content

Fix wrong results of pointInPolygon for a polygon with huge coordinates - #123740

Merged
alexey-milovidov merged 7 commits into
ClickHouse:masterfrom
groeneai:fix-point-in-polygon-huge-coordinates
Oct 11, 2026
Merged

alexey-milovidov merged 7 commits into
ClickHouse:masterfrom
groeneai:fix-point-in-polygon-huge-coordinates

Conversation

@groeneai

@groeneai groeneai commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #115035

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fixed wrong results of pointInPolygon for polygons with huge coordinates. With a constant array polygon, a filter on a table whose primary key covers the point columns could also return fewer rows than a full scan. pointInPolygon now throws BAD_ARGUMENTS where it would compute with a polygon coordinate larger than 1e150 in absolute value.

Description

On 26.8.10.6, pointInPolygon((0.9, 5.), [(0., 0.), (1.1920928955078125e-7, 1.7976931348623157e308), (0.9999, 3.4028234663852886e38), (1.0001, 0.)]) returns 0 for an inside point, and the same filter on a table ORDER BY (x, y) returns 812 rows where a full scan returns 900 (also on 26.3, 26.9). Found by the AST fuzzer: report.

Root cause. Both algorithms overflow Float64 for huge coordinates. After #123767 the constant-polygon grid and ray casting match the unscaled result for valid polygons scaled up to about 2^512 (1.3e154), but not above: for [(0., 0.), (1e200, 0.), (0., 1e200)] and 10000 points on a 1e198 grid, master reports 5713 points inside the constant polygon (576 of them with x + y > 1e200) and all 10000 with materialize. Ray casting also serves constant Geometry, Variant and Dynamic polygons, which the Variant adaptor passes as full columns.

Change. Both algorithms now reject a coordinate above 1e150 in absolute value: the grid checks every ring first (degenerate polygons included); ray casting checks the vertices of each edge that crosses the point's ray, right before computing the crossing, so it adds no pass over the polygon. The planning-time execution raises it before index analysis.

Validation. The new test and 01700 fail on master (every rejected line returns a value, wrappers and materialize included) and pass with the fix; the pruning control runs in both primary key analysis modes, and the bound 1e100 fails exactly the eight lines at 1e150. For 40 valid polygons scaled by 2^k up to 2^498 (just under 1e150), the grid, ray casting and the primary key pruning return the same rows as the unscaled polygon. 50 randomized runs and the pointInPolygon tests pass.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/123740]

Version info

  • Merged into: 26.10.1.2165-master (included in 26.10 and later)

groeneai and others added 5 commits October 3, 2026 14:28
…ygon

The grid of a constant polygon clips the polygon to each cell with
boost::geometry::intersection. boost's Float64 overlay multiplies a
coordinate by a coordinate difference, so once a cell extent times a cell
coordinate exceeds the Float64 range the clip comes back empty or equal to
the cell, and the whole cell is classified by its center. For the AST fuzzer
polygon [(0,0), (1.19e-7, DBL_MAX), (0.9999, FLT_MAX), (1.0001, 0)] this made
the x = 0 sliver outside the polygon "inside" and the interior points at
x = 0.9 and 1.0 "outside". The primary key analysis of the pointInPolygon
atom is exact for those boxes, so a table ordered by (x, y) also returned
fewer rows than a full scan (812 vs 900), which is the TLP mismatch the
fuzzer reported.

The measured failure threshold for that shape is a cell height of
sqrt(DBL_MAX) ~ 1.3e154. Coordinates up to 1e150 keep every such product
below 1e301 and give correct results, so reject larger coordinates with
BAD_ARGUMENTS next to the existing "bounding box is unbounded" check. Every
ring is checked (holes and every polygon of a multipolygon). The function
runs on a 0-row block while the query is planned, so the error is raised
before index analysis even when every granule would be pruned.

01700 claimed a 1e200-wide box "stays usable"; it returns 0 for the
interior point (1e197, 1.99), so the bound there moves to 1e150.

Provenance: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=782be4dcec24970dad336d1af4f321c7ff53da40&name_0=MasterCI&name_1=AST%20fuzzer%20%28amd_release%2C%20oracle%29

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… algorithms

Review round 1 found three gaps in the previous commit.

Constant Geometry, Variant and Dynamic polygons never reach the grid: the
Variant/Dynamic adaptors pass them as full columns, so they take the ray
casting path, like every non-constant polygon. Ray casting computes
(x2 - x1) * (y - y1) before dividing, which overflows for a polygon huge in
both axes: [(0,0), (1e200,0), (0,1e200)] answered 1 for the outside point
(9e199, 5e199). isInsideRing now checks the ring it evaluates with one
branch-free pass before casting; it is the only ray casting site.

The grid check ran after the empty-bound return, so a degenerate polygon with
a 1e200 vertex still answered. It is now the first statement of
calcGridAttributes.

boost computes each clip intersection point as a 2x2 determinant times a
coordinate difference, a 3-factor product, so a polygon huge in both axes
breaks the grid much earlier than 1e150. A 41x41 lattice sweep on master
(holes-as-arguments form, which the parseRing Int64 guard does not cover)
found no scale-induced error up to 1e101 and 65 wrong points at 1e103 (E^3
reaches DBL_MAX near 5.6e102). The bound is now 1e100, shared by both algorithms
through max_abs_polygon_coordinate and throwPolygonCoordinateIsTooLarge.

Tests: 05320 gains the degenerate polygon, a 2-D polygon at 1e103, the
Geometry/Variant/Dynamic/materialize forms with a unit-scale control, and the
positive control moves to 1e100; 01700's "stays usable" lines move to 1e100.

Provenance: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=782be4dcec24970dad336d1af4f321c7ff53da40&name_0=MasterCI&name_1=AST%20fuzzer%20%28amd_release%2C%20oracle%29

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the ray

The previous commit checked every ring with a separate pass before ray
casting. That pass is a loop-carried std::max chain over all vertices, for
every row, and cost about 23% on the non-constant 180-vertex polygon workload
of tests/performance/point_in_polygon.xml (Debug: 0.053 s -> 0.065 s on 500k
polygons, median of 30).

Ray casting does arithmetic only for an edge that straddles the point's ray,
where the point's y lies between the edge's y1 and y2. Bounding the four
coordinates of that edge by 1e100 keeps (x2 - x1) * (y - y1) below 4e200 and
the quotient within |x2 - x1|, so the check now runs only there, right before
the crossing is computed. A coordinate on an edge that is never computed cannot
make the answer wrong. The same workload now measures 0.053 s, equal to the
base. The predicate is the grid's, so NaN keeps its behaviour.

The function documentation now states the 1e100 limit. The positive control of
05320 runs in both primary key analysis modes.

Provenance: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=782be4dcec24970dad336d1af4f321c7ff53da40&name_0=MasterCI&name_1=AST%20fuzzer%20%28amd_release%2C%20oracle%29

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ols and document the coordinate limit

The two positive-control lines of 05320 run the same predicate back to back,
once per primary key analysis mode. The query condition cache keeps the ranges
excluded by the first line under a key that does not include
use_lightweight_primary_key_index_analysis, so the second line could pass
max_rows_to_read without doing its own pruning. Both lines now set
use_query_condition_cache = 0.

A ray-casting line with a vertex at exactly 1e100 pins the bound as inclusive,
so a ">=" in the edge check fails the test.

The function's documentation page now states the 1e100 limit, as the function's
own documentation already does.

Provenance: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=782be4dcec24970dad336d1af4f321c7ff53da40&name_0=MasterCI&name_1=AST%20fuzzer%20%28amd_release%2C%20oracle%29

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he documented exception

Ray casting checks only the coordinates of edges that cross the point's ray, so a
polygon with an off-ray huge vertex is answered without an error. The documentation
now says the function throws when it would compute with a larger coordinate, which
matches that behaviour.

The test gains four materialized polygons, each of which trips exactly one of the four
compares in the isInsideRing guard (x1, x2, y1, y2), so deleting any single compare
fails exactly one line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding labels Oct 3, 2026
@groeneai

groeneai commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex), plus my own cold review of the resulting code.

Round 1 (head 8fa0be1e7606), all fixed in the next round:

# Sev Finding Verdict Action
1 ❌ Constant Geometry / Variant / Dynamic polygons are materialized by the Variant adaptor and evaluated by ray casting, which also overflows, so the coordinate check never ran for them AGREE the bound is now checked in ray casting too
2 ⚠️ A degenerate polygon returned before the check AGREE the check runs first
3 ⚠️ The 1e150 bound assumed 2-factor products, but boost computes a clip intersection point as a determinant times a difference AGREE measured on polygons huge in both axes; bound chosen from the measurement

Round 2 (head a5d190f009aa), all fixed in the next round:

# Sev Finding Verdict Action
4 ❌ The ray-casting check was an extra pass over every ring of every row (measured ~20% on a Debug build of the point_in_polygon.xml workload) AGREE the check moved into the only arithmetic ray casting does, the crossing of an edge with the ray, so there is no extra pass
5 ⚠️ The pruning control ran in a random primary key analysis mode AGREE pinned to both modes
6 ⚠️ The function documentation did not mention the new limit AGREE documented
7 💡 Polygon dictionaries clip with the same boost overlay noted not this function, not measured

Round 3 (head 52751c903e0d):

# Sev Finding Verdict Action
8 ❌ parseRing casts coordinates to Int64 (undefined for huge values) before the new check DISAGREE the cast feeds only the existing overflow probe, which throws the same BAD_ARGUMENTS; the polygon keeps the original Float64 coordinates, so the check and the evaluation are unaffected. The probe itself is unchanged
9 ⚠️ The second pinned primary key mode could reuse ranges the query condition cache stored for the first AGREE the cache is disabled on both lines
10 💡 No ray-casting control at exactly 1e100 AGREE added
11 💡 The docs page did not mention the limit AGREE documented

Round 4 (head fcdd9e413a6d):

# Sev Finding Verdict Action
12 ❌ The 1e100 bound rejects some previously correct inputs with no compatibility setting DISAGREE the changelog entry states the new exception and its bound, and the description notes the margin. A setting would be a new knob, and validate_polygons = 0 cannot carry it without reopening the reported row loss. The category stays Bug Fix (wrong results on 26.3 to 26.9); relabelling it is a one-line choice if preferred
13 ⚠️ The docs promised an exception for any larger coordinate, but ray casting checks only edges that cross the point's ray AGREE both copies now say "when it would compute with a larger one"
14 💡 No test line needed the x-coordinate checks of ray casting AGREE one line per coordinate check

Round 5 (head 9862cd956540): no findings from the independent model; my own review noted one nit.

# Sev Finding Verdict Action
15 💡 The normal-scale Geometry control returns 0, so it shows no error is raised but not that the wrapper path evaluates noted not blocking; the materialize path has a 1 arm at 1e100

@groeneai

groeneai commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, default settings, no randomization: on a table ORDER BY (x, y) with index_granularity = 8 over a 100x100 lattice, WHERE pointInPolygon((x, y), <fuzzer polygon>) returns 812, a full scan and countIf return 900, every run. Every newly rejected test line returns a value on pristine HEAD.
b Root cause explained? Both algorithms overflow Float64. The constant-polygon grid clips the polygon to each cell with boost::geometry::intersection, whose intersection point is a 2x2 determinant times a coordinate difference; from about 1e155 (polygon huge in one axis) or 1e103 (huge in both, measured on a 41x41 lattice) the clip comes back empty or full and whole cells take the class of their center. The exact primary key atom then prunes granules whose rows the wrong grid accepts. Ray casting (non-constant polygons, and constant Geometry/Variant/Dynamic ones, which the Variant adaptor passes as full columns) overflows (x2 - x1) * (y - y1) when both axes are huge.
c Fix matches root cause? Yes. One bound (1e100, below the measured 1e103) and one throw helper; the grid checks every ring as the first statement of calcGridAttributes (degenerate polygons included), and ray casting checks each edge that crosses the point's ray in isInsideRing, the single ray-casting site. The primary key analysis is unchanged, because it was right.
d Test intent preserved / new tests added? New 05320_point_in_polygon_huge_coordinates: the fuzzer polygon on PK, no-PK and direct calls, a query where the primary key prunes every granule, a hole, a degenerate polygon, a multipolygon member, a polygon huge in both axes at 1e103, Geometry/Variant/Dynamic/materialize polygons with a unit-scale control, a 1e100 positive control whose max_rows_to_read proves pruning is still live, and a ray-casting control with a vertex at exactly 1e100 (0 1). The 01700 line asserting a 1e200 triangle is usable now expects BAD_ARGUMENTS (measured wrong at (1e197, 1.99)).
e Both directions demonstrated? Yes. Pristine HEAD: both tests fail, and each of the 17 newly rejected lines returns a value. Fix: both pass. Mutations each fail exactly their lines: grid check removed (all plain-constant lines), outer ring only (the hole line), ray-casting check removed (the four wrapper lines), grid check after the degenerate return (the degenerate line), bound 1e150 (the 1e103 line), >= instead of > in the ray-casting check (the exact-1e100 ray-casting line), and single-compare deletions M8a-d each fail exactly their line; the positive control lines pin use_query_condition_cache = 0 so each primary key analysis mode does its own pruning, and on the no-PK table give TOO_MANY_ROWS in both modes. 50/50 randomized runs pass.
f Fix is general across code paths? Grid: single polygon, holes as extra arguments, multipolygon (one grid per polygon), plain Ring/Polygon/MultiPolygon constants. Ray casting: every non-constant shape plus Geometry/Variant/Dynamic constants, all through isInsideRing, which checks each edge that crosses the point's ray. The error is raised by the planning-time execution, before part selection.
g Fix generalizes across inputs (params/datatypes/wrappers)? Probed: negative and positive coordinates on both axes, inner rings, multipolygon members, a degenerate polygon, exactly 1e100 (accepted), NaN vertex (unchanged), inf (still rejected), the three wrapper types and materialize. All 41 tests that call pointInPolygon pass 3 randomized runs each.
h Backward compatible? (maintainer-approved exception only) No setting or format change. Polygons with a coordinate above 1e100 change from wrong (or, near the bound, still correct) results to BAD_ARGUMENTS, the same treatment as the existing unbounded bounding box check. No extra pass: the guard runs only on edges crossing the ray (Debug A/B on 500k 180-vertex polygons: base 0.053 s, r1 0.065 s, r2 0.053 s).
i Invariants and contracts preserved? calcGridAttributes throws before computing the envelope or writing any member, otherwise proceeds as before; isInsideRing checks each edge that crosses the point's ray and throws before computing that crossing; only its local result was written. The preprocessed polygon cache stores only successful loads, so a rejected polygon is never cached (a repeated call still errors).

Session id: cron:clickhouse-impl-slot-5:20261003-174503

@clickhouse-gh

clickhouse-gh Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [58ccc12]

Summary: ✅


AI Review

Summary

This PR adds a 1e150 coordinate guard to both pointInPolygon evaluation strategies, updates the user-facing docs, and adds focused stateless coverage for the huge-coordinate cases that were returning wrong answers. I think the change is close, but the single-column constant-array path still goes through the legacy parseRing Int64 overflow probe before the new guard, so the advertised 1e150 contract is still not true for the most common constant syntax.

Findings

❌ Blockers

  • [src/Functions/pointInPolygon.cpp:716] [dismissed by author -- https://github.com/Fix wrong results of pointInPolygon for a polygon with huge coordinates #123740#discussion_r4174388103] The new contract says polygons are evaluated up to 1e150 and rejected above it, but parseRing still does static_cast<Int64>(x_data[i]) / static_cast<Int64>(y_data[i]) and an Int64 product overflow check before any 1e150 bound check. That leaves the plain constant-array path inconsistent with the new grid/ray-casting rule: for example, [(1e10, 1e10), (-1e10, 1e10), (0., -1e10)] still throws here while materialize / multi-argument forms accept it, and even the new 1e150 happy-path cases still depend on out-of-range FP→Int conversion before reaching the guard. Please drop or rewrite this legacy probe so the single-column constant path enforces the same 1e150 limit before any integer cast.
Final Verdict

❌ Changes requested — make the single-column constant path honor the same 1e150 contract as the rest of the PR, then the rest of the change looks good.

LLVM Coverage Report

Measured on commit 58ccc12.

Metric Baseline Current Δ
Lines 88.30% 88.30% +0.00%
Functions 92.10% 92.10% +0.00%
Branches 79.70% 79.70% +0.00%

Changed lines: Changed C/C++ lines covered: 26/26 (100.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Oct 3, 2026
{
return std::abs(point.x()) > max_abs_polygon_coordinate || std::abs(point.y()) > max_abs_polygon_coordinate;
};
if (std::ranges::any_of(polygon.outer(), is_too_large)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This guard still runs after the single-column constant path has already gone through parseRing in src/Functions/pointInPolygon.cpp:716. That helper still does static_cast<Int64>(x_data[i]) / static_cast<Int64>(y_data[i]) before any bound check, so inputs above 1e100 are already hitting out-of-range FP→Int conversions before we reach the new rejection path here.

That matters for cases like [(0., 0.), (1e200, 0.), (0., 1.)]: the old mulOverflow probe does not necessarily fire there, so today the query still depends on implementation-defined / undefined conversion behavior before eventually throwing later. Please move the max_abs_polygon_coordinate check into parseRing (or before calling it) so huge constant-array polygons are rejected before any integer casts or preprocessing.

@clickhouse-gh clickhouse-gh Bot added the comp-geo Geospatial functions and related libs (e.g., H3, S2, geo distance). label Oct 3, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Commit 58ccc1203cb247e9dffec437d02cf5287b081645 was not compared: the CI logs cluster did not answer (every POST attempt failed with an exception; stopped retrying after the 1250 s read budget).

See the job log for details.

@groeneai

groeneai commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 9862cd9

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Build (amd_fuzzers) / Build ClickHouse not from this PR: the clickhouse_fuzzer link fails with relocation R_X86_64_PC32 out of range against .bss; the same job is red on master and on 143 PRs in the last 24h #123738 (external, open)
Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel) / 04647_spilling_hash_join_post_build_phase not from this PR: under parallel replicas the initiator's system.query_log row reports no JoinBuildPostProcessingMicroseconds (0 0 instead of 1 0); all reruns passed; 3 PRs in 7 days a fix task is created (investigating at full effort, fixing-PR link to follow here)
Stateless tests (arm_binary, s3 storage, DBReplicated, parallel, 1/2) / 05237_with_expression_alias_scope_descendant not from this PR: under a Replicated database the replicated CREATE VIEW stores a nested WITH alias qualified with the database, so the view reads the same-named table; 154 PRs in the last 24h a fix task is created (fix in final review, fixing-PR link to follow here)
Mergeable Check, PR rollups, red only because of the rows above #123738 (external, open) and the fix tasks above (a fix task is created)

None of these touches the pointInPolygon code this PR changes. All checks completed; CIDB has no other FAIL or ERROR on this head.

Session id: cron:our-pr-ci-monitor:20261003-223443

@groeneai

groeneai commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator Author

Ledger follow-up for 9862cd9565404c213c28bbc977b92b7ff822ab8e: 04647_spilling_hash_join_post_build_phase in Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel) is now owned by #123784 (ours, open).

@nihalzp nihalzp self-assigned this Oct 4, 2026
Bartok9 pushed a commit to Bartok9/ClickHouse that referenced this pull request Oct 4, 2026
The test asserts JoinBuildPostProcessingMicroseconds > 0 on the initiator's
query_log row. Under parallel replicas the join-order randomization can put
t_post_build_left, the coordinated read, on the build side. Its marks form
one coordinator segment owned by a remote replica, so when the local
replica's first read request arrives after that replica announces, the local
replica gets 0 marks and builds an empty hash table. The whole build and its
post-build phase then run in the remote replicas' secondary queries, whose
ProfileEvents are forwarded to the client only and are not added to the
initiator's query_log row, so the check reads 0.

Seen in "Stateless tests (arm_binary, ParallelReplicas, s3 storage,
parallel)" on PRs ClickHouse#117005 and ClickHouse#123740 with the output "0 0" instead of "1 0".

Pin enable_parallel_replicas = 0 on the measured join only, as other join
tests asserting join ProfileEvents already do. The test's subject,
SpillingHashJoin running the post-build phase of the wrapped join, does not
depend on how the read is split between replicas.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@nihalzp

nihalzp commented Oct 8, 2026

Copy link
Copy Markdown
Member

Merge master.

@groeneai

groeneai commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author

Merged master in e4f70e7, which brings in #123767.

Re-measured on top of it: the fuzzer's polygon no longer loses rows on master, but huge coordinates still return wrong results there. For [(0., 0.), (1e200, 0.), (0., 1e200)] and a 100x100 grid of points with step 1e198, master reports 576 points with x + y > 1e200 as inside for the constant polygon, and all 10000 points as inside with materialize. With this PR both throw BAD_ARGUMENTS. 05320, 01700 and the other pointInPolygon tests pass on the merged head.

In a sweep of valid polygons scaled by powers of two, both algorithms on master now match the unscaled result up to 2^512 (about 1.3e154) and diverge above it, so the 1e100 limit is conservative after #123767. I can raise it to 1e150 if you prefer.

@nihalzp

nihalzp commented Oct 8, 2026

Copy link
Copy Markdown
Member

Raise.

After ClickHouse#123767 both point-in-polygon algorithms and the primary key
analysis agree with the unscaled result for valid polygons scaled by
powers of two up to 2^512 (about 1.3e154), so 1e100 was more
conservative than needed. 1e150 keeps a margin below that.

The 05320 polygon huge in both axes moves from the rejected lines to the
evaluated ones, at 1e150.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

groeneai commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author

Raised to 1e150 in 58ccc12, together with both doc copies and the tests: the evaluated lines moved to 1e150, and the old 1e100 bound fails exactly those eight lines. For 40 valid polygons scaled by 2^k up to 2^498 (just under 1e150), the grid, ray casting and primary key pruning return the same rows as the unscaled polygon. I updated the description to match.

One leftover I did not touch: the 2021 Int64 probe in parseRing still rejects a single-argument constant polygon once a vertex has |x * y| above 2^63, so [(1e10, 1e10), (-1e10, 1e10), (0., -1e10)] throws on master and here, while its materialize and holes-as-arguments forms return 1. I can remove that probe in this PR, so that 1e150 is the only limit, if you want.

@alexey-milovidov alexey-milovidov 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.

Looks clear.

@alexey-milovidov alexey-milovidov self-assigned this Oct 11, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 11, 2026
Merged via the queue into ClickHouse:master with commit ae0dac4 Oct 11, 2026
152 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-geo Geospatial functions and related libs (e.g., H3, S2, geo distance). groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants