Skip to content

Commit fee1b5f

Browse files
committed
IGNITE-17190 Minor fix regarding calcite selectivity
1 parent f46e7d4 commit fee1b5f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/IgniteMdSelectivity.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,16 @@ private double estimateRefSelectivity(ProjectableFilterableTableScan rel, RelMet
324324
ColumnStatistics colStat = getColumnStatistics(mq, rel, ref);
325325
double res = 0.33;
326326

327-
if (colStat == null) {
327+
if (colStat == null || colStat.max() == null || colStat.min() == null) {
328328
// true, false and null with equivalent probability
329329
return res;
330330
}
331331

332-
if (colStat.max() == null || colStat.max().compareTo(BigDecimal.ONE) != 0
333-
|| colStat.max().compareTo(BigDecimal.ZERO) != 0)
332+
// Check whether it can be considered as BOOL.
333+
boolean isBool = (colStat.max().compareTo(BigDecimal.ONE) == 0 || colStat.max().compareTo(BigDecimal.ZERO) == 0)
334+
&& (colStat.min().compareTo(BigDecimal.ONE) == 0 || colStat.min().compareTo(BigDecimal.ZERO) == 0);
335+
336+
if (!isBool)
334337
return res;
335338

336339
Boolean min = colStat.min().compareTo(BigDecimal.ONE) == 0;

0 commit comments

Comments
 (0)