Fix stats bucket logic for Double values in UNION queries in Orca
When merging statistics buckets for UNION and UNION ALL queries involving a column that maps to Double (eg: floats, numeric, time related types), we could end up in an infinite loop. This occurred if the bucket boundaries that we compared were within a very small value, defined in Orca as Epsilon. While we considered that two values were equal if they were within Epsilon, we didn't when computing whether datum1 < datum2. Therefore we'd get into a situation where a datum could be both equal to and less than another datum, which the logic wasn't able to handle. The fix is to make sure we have a hard boundary of when we consider a datum less than another datum by including the epsilon logic in all datum comparisons. Now, 2 datums are equal if they are within epsilon, but datum1 is less than datum 2 only if datum1 < datum2 - epsilon. Also add some tests since we didn't have any tests for types that mapped to Double.
Showing
想要评论请 注册 或 登录