[
https://issues.apache.org/jira/browse/ORC-971?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17404836#comment-17404836
]
Quanlong Huang commented on ORC-971:
------------------------------------
There are two existing tests that I think are expecting the wrong results:
[https://github.com/apache/orc/blob/12e2f7488a7b5a11f734522dedf3648bd29cd1cc/c%2B%2B/test/TestPredicateLeaf.cc#L521-L522]
{code:cpp}
PredicateLeaf pred(
PredicateLeaf::Operator::LESS_THAN_EQUALS,
PredicateDataType::STRING,
"x",
Literal("c", 1));
...
EXPECT_EQ(TruthValue::YES_NO_NULL, // Should be YES_NULL
evaluate(pred, createStringStats("c", "c", true)));
{code}
[https://github.com/apache/orc/blob/12e2f7488a7b5a11f734522dedf3648bd29cd1cc/c%2B%2B/test/TestPredicateLeaf.cc#L873-L878]
{code:cpp}
PredicateLeaf pred2(PredicateLeaf::Operator::LESS_THAN_EQUALS,
PredicateDataType::TIMESTAMP,
"x",
Literal(static_cast<int64_t>(0), 500000));
EXPECT_EQ(TruthValue::YES_NO, evaluate( // Should be YES
pred2, createTimestampStats(0, 500000, 0, 500000)));
{code}
> LESS_THAN_EQUALS doesn't handle the case when min=max
> -----------------------------------------------------
>
> Key: ORC-971
> URL: https://issues.apache.org/jira/browse/ORC-971
> Project: ORC
> Issue Type: Bug
> Components: C++
> Affects Versions: 1.7.0
> Reporter: Quanlong Huang
> Assignee: Quanlong Huang
> Priority: Major
>
> When evaluating the LESS_THAN_EQUALS predicates, the case that has identical
> minValue and maxValue is not handled correctly. E.g. predicate "x <= 15" on a
> range [15, 15] should get YES or YES_NULL results. But what we currently get
> is YES_NO or YES_NO_NULL.
> The issue is in evaluatePredicateRange():
>
> [https://github.com/apache/orc/blob/12e2f7488a7b5a11f734522dedf3648bd29cd1cc/c%2B%2B/src/sargs/PredicateLeaf.cc#L340-L348]
> {code:cpp}
> case PredicateLeaf::Operator::LESS_THAN_EQUALS:
> loc = compareToRange(values.at(0), minValue, maxValue);
> if (loc == Location::AFTER || loc == Location::MAX) { // 'loc'
> could be MIN and minValue could equal to maxValue. This case is missed here.
> return hasNull ? TruthValue::YES_NULL : TruthValue::YES;
> } else if (loc == Location::BEFORE) {
> return hasNull ? TruthValue::NO_NULL : TruthValue::NO;
> } else {
> return hasNull ? TruthValue::YES_NO_NULL : TruthValue::YES_NO;
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)