KaiqiJinWow commented on PR #18879: URL: https://github.com/apache/iceberg/pull/18879#issuecomment-7052612465
Thanks! All four follow one rule: bounds can be a bit too big, but should never be too small, because a box that is too small can skip a file with matching rows. So whenever rounding makes a case unclear, the code picks the bigger box. The constants aren't proven minimums. They are much larger than double rounding error (around 1e-16) and much smaller than anything a query cares about (1e-6° is about 0.1 m). I added a short comment for each in [91518cf](https://github.com/apache/iceberg/pull/18879/commits/91518cf6878996455ba0046761c3162d028ed25d). 1. `1e-12` arc tolerance: near an endpoint, rounding can flip the sign test and reject a vertex that is on the arc. Accepting one just outside only widens the box by under a meter. 2. `1e-6` cross-product cutoff: the length is `sin(theta)`, so a small value means the endpoints are almost the same or almost opposite, and the normalized plane is unreliable. A short arc can't change latitude by more than its length (about 6 m at the cutoff), so we pad by that. A nearly antipodal edge can flip to the other side of the globe, so only world bounds are safe. 3. Latitude padding: `asin` loses precision near the poles, so the relative part grows with latitude. The absolute part covers extrema near the equator, where a relative margin vanishes. Both are at most about 1 m on Earth. 4. Longitude: away from the poles, a minor arc stays within the shorter circular interval. Near a pole, rounding can pick the wrong side. For example, `134.3 - (-45.7)` rounds to exactly `180`, but the arc from `(-45.7, 60)` to `(134.3, 60)` passes just beside the pole, near longitude `-135.7°`. So any bound that reaches ±90° gets full longitude, and I added this case as a test. Exact pole endpoints keep their stored longitude, as you suggested on #17788. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
