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:44:06 UTC

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

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

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


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

commit 0156ad7a2ec1a05aa57a7709c52ad4598301404c
Author: Panagiotis Garefalakis <pg...@apache.org>
AuthorDate: Mon Jan 11 01:43:57 2021 +0200

    ORC-724: PPD: Date IN single value comparison throws ClassCastException (#618)
    
    ### 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 c767640..9b6d563 100644
--- a/java/core/src/java/org/apache/orc/impl/RecordReaderImpl.java
+++ b/java/core/src/java/org/apache/orc/impl/RecordReaderImpl.java
@@ -669,7 +669,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 deb49b8..e871c16 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);