You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by do...@apache.org on 2021/01/10 23:45:37 UTC

[orc] branch branch-1.6 updated: ORC-724: PPD: Date IN single value comparison throws ClassCastException (#619)

This is an automated email from the ASF dual-hosted git repository.

dongjoon pushed a commit to branch branch-1.6
in repository https://gitbox.apache.org/repos/asf/orc.git


The following commit(s) were added to refs/heads/branch-1.6 by this push:
     new b54d10c  ORC-724: PPD: Date IN single value comparison throws ClassCastException (#619)
b54d10c is described below

commit b54d10cedf5ec1529cf06d77268510c216402cba
Author: Panagiotis Garefalakis <pg...@apache.org>
AuthorDate: Mon Jan 11 01:45:27 2021 +0200

    ORC-724: PPD: Date IN single value comparison throws ClassCastException (#619)
    
    ### What changes were proposed in this pull request?
    PPD evaluation: Date type Pred baseObject normalization to LocalDate (comparable with ColumnStats)
    
    
    ### Why are the changes needed?
    Date baseObject normalization is missing leading to ClassCastException when using single Value IN ppd evaluation.
    
    
    ### How was this patch tested?
    TestRecordReaderImpl.testInDatePredConversion
---
 .../src/java/org/apache/orc/impl/RecordReaderImpl.java  |  3 ++-
 .../test/org/apache/orc/impl/TestRecordReaderImpl.java  | 17 +++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/java/core/src/java/org/apache/orc/impl/RecordReaderImpl.java b/java/core/src/java/org/apache/orc/impl/RecordReaderImpl.java
index 5c0aec3..3934340 100644
--- a/java/core/src/java/org/apache/orc/impl/RecordReaderImpl.java
+++ b/java/core/src/java/org/apache/orc/impl/RecordReaderImpl.java
@@ -649,7 +649,8 @@ public class RecordReaderImpl implements RecordReader {
           // for a single value, look through to see if that value is in the
           // set
           for (Object arg : predicate.getLiteralList()) {
-            if (range.compare((Comparable) arg) == Location.MIN) {
+            predObj = getBaseObjectForComparison(predicate.getType(), (Comparable) arg);
+            if (range.compare(predObj) == Location.MIN) {
               return range.addNull(TruthValue.YES);
             }
           }
diff --git a/java/core/src/test/org/apache/orc/impl/TestRecordReaderImpl.java b/java/core/src/test/org/apache/orc/impl/TestRecordReaderImpl.java
index 4375d3a..4247733 100644
--- a/java/core/src/test/org/apache/orc/impl/TestRecordReaderImpl.java
+++ b/java/core/src/test/org/apache/orc/impl/TestRecordReaderImpl.java
@@ -1083,6 +1083,23 @@ public class TestRecordReaderImpl {
   }
 
   @Test
+  public void testInDatePredConversion() {
+    List<Object> args = new ArrayList<>();
+    args.add(toDate(LocalDate.ofEpochDay(15)));
+    PredicateLeaf pred = createPredicateLeaf
+        (PredicateLeaf.Operator.IN, PredicateLeaf.Type.DATE,
+            "x", null, args);
+    assertEquals(TruthValue.YES_NULL,
+        evaluateInteger(createDateStats(15, 15), pred));
+    assertEquals(TruthValue.YES_NO_NULL,
+        evaluateInteger(createDateStats(10, 30), pred));
+    assertEquals(TruthValue.NO_NULL,
+        evaluateInteger(createDateStats(5, 10), pred));
+    assertEquals(TruthValue.NO_NULL,
+        evaluateInteger(createDateStats(16, 30), pred));
+  }
+
+  @Test
   public void testBetween() {
     List<Object> args = new ArrayList<Object>();
     args.add(10L);