tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jihoon...@apache.org
Subject git commit: TAJO-679: TimestampDatum, TimeDatum, DateDatum should be able to be compared with NullDatum. (Alvin Henrick via jihoon)
Date Thu, 27 Mar 2014 04:57:48 GMT
Repository: tajo
Updated Branches:
  refs/heads/branch-0.8.0 9161f8e23 -> 5d6d16571


TAJO-679: TimestampDatum, TimeDatum, DateDatum should be able to be compared with NullDatum.
(Alvin Henrick via jihoon)


Project: http://git-wip-us.apache.org/repos/asf/tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/5d6d1657
Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/5d6d1657
Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/5d6d1657

Branch: refs/heads/branch-0.8.0
Commit: 5d6d16571a23baf901e11f7fc7db53d3e9ce81ee
Parents: 9161f8e
Author: Jihoon Son <jihoonson@apache.org>
Authored: Thu Mar 27 13:57:21 2014 +0900
Committer: Jihoon Son <jihoonson@apache.org>
Committed: Thu Mar 27 13:57:21 2014 +0900

----------------------------------------------------------------------
 CHANGES.txt                                               |  3 +++
 .../src/main/java/org/apache/tajo/datum/DateDatum.java    |  7 +++++--
 .../src/main/java/org/apache/tajo/datum/TimeDatum.java    |  7 +++++--
 .../main/java/org/apache/tajo/datum/TimestampDatum.java   |  7 +++++--
 .../test/java/org/apache/tajo/datum/TestDateDatum.java    |  8 ++++++++
 .../test/java/org/apache/tajo/datum/TestTimeDatum.java    |  8 ++++++++
 .../java/org/apache/tajo/datum/TestTimestampDatum.java    | 10 +++++++++-
 7 files changed, 43 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/5d6d1657/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 41a5a7e..209ceb4 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -283,6 +283,9 @@ Release 0.8.0 - unreleased
 
   BUG FIXES
 
+    TAJO-679: TimestampDatum, TimeDatum, DateDatum should be able to be compared 
+    with NullDatum. (Alvin Henrick via jihoon)
+
     TAJO-716: Using column names actually aliased in aggregation functions
     can cause planning error. (hyunsik)
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/5d6d1657/tajo-common/src/main/java/org/apache/tajo/datum/DateDatum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/org/apache/tajo/datum/DateDatum.java b/tajo-common/src/main/java/org/apache/tajo/datum/DateDatum.java
index 5e0c26d..e489a09 100644
--- a/tajo-common/src/main/java/org/apache/tajo/datum/DateDatum.java
+++ b/tajo-common/src/main/java/org/apache/tajo/datum/DateDatum.java
@@ -157,7 +157,7 @@ public class DateDatum extends Datum {
   public Datum equalsTo(Datum datum) {
     if (datum.type() == TajoDataTypes.Type.TIME) {
       return DatumFactory.createBool(date.equals(((DateDatum) datum).date));
-    } else if (datum.isNull()) {
+    } else if (datum instanceof NullDatum  || datum.isNull()) {
       return datum;
     } else {
       throw new InvalidOperationException();
@@ -168,7 +168,7 @@ public class DateDatum extends Datum {
   public int compareTo(Datum datum) {
     if (datum.type() == TajoDataTypes.Type.DATE) {
       return date.compareTo(((DateDatum)datum).date);
-    } else if (datum.type() == TajoDataTypes.Type.NULL_TYPE) {
+    } else if (datum instanceof NullDatum || datum.isNull()) {
       return -1;
     } else {
       throw new InvalidOperationException();
@@ -176,6 +176,9 @@ public class DateDatum extends Datum {
   }
 
   public boolean equals(Object obj) {
+    if (obj instanceof NullDatum) {
+        return false;
+    }
     if (obj instanceof DateDatum) {
       DateDatum another = (DateDatum) obj;
       return date.isEqual(another.date);

http://git-wip-us.apache.org/repos/asf/tajo/blob/5d6d1657/tajo-common/src/main/java/org/apache/tajo/datum/TimeDatum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/org/apache/tajo/datum/TimeDatum.java b/tajo-common/src/main/java/org/apache/tajo/datum/TimeDatum.java
index 55023da..8b18f08 100644
--- a/tajo-common/src/main/java/org/apache/tajo/datum/TimeDatum.java
+++ b/tajo-common/src/main/java/org/apache/tajo/datum/TimeDatum.java
@@ -129,7 +129,7 @@ public class TimeDatum extends Datum {
   public Datum equalsTo(Datum datum) {
     if (datum.type() == TajoDataTypes.Type.TIME) {
       return DatumFactory.createBool(time.equals(((TimeDatum) datum).time));
-    } else if (datum.isNull()) {
+    } else if (datum instanceof NullDatum  || datum.isNull()) {
       return datum;
     } else {
       throw new InvalidOperationException();
@@ -140,7 +140,7 @@ public class TimeDatum extends Datum {
   public int compareTo(Datum datum) {
     if (datum.type() == TajoDataTypes.Type.TIME) {
       return time.compareTo(((TimeDatum)datum).time);
-    } else if (datum.isNull()) {
+    } else if (datum instanceof NullDatum || datum.isNull()) {
       return -1;
     } else {
       throw new InvalidOperationException();
@@ -148,6 +148,9 @@ public class TimeDatum extends Datum {
   }
 
   public boolean equals(Object obj) {
+    if (obj instanceof NullDatum) {
+        return false;
+    }
     if (obj instanceof TimeDatum) {
       TimeDatum another = (TimeDatum) obj;
       return time.isEqual(another.time);

http://git-wip-us.apache.org/repos/asf/tajo/blob/5d6d1657/tajo-common/src/main/java/org/apache/tajo/datum/TimestampDatum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/org/apache/tajo/datum/TimestampDatum.java b/tajo-common/src/main/java/org/apache/tajo/datum/TimestampDatum.java
index 8dfa318..e7a9861 100644
--- a/tajo-common/src/main/java/org/apache/tajo/datum/TimestampDatum.java
+++ b/tajo-common/src/main/java/org/apache/tajo/datum/TimestampDatum.java
@@ -160,7 +160,7 @@ public class TimestampDatum extends Datum {
   public Datum equalsTo(Datum datum) {
     if (datum.type() == TajoDataTypes.Type.TIME) {
       return DatumFactory.createBool(dateTime.equals(((TimestampDatum) datum).dateTime));
-    } else if (datum.isNull()) {
+    } else if (datum instanceof NullDatum || datum.isNull()) {
       return datum;
     } else {
       throw new InvalidOperationException();
@@ -171,7 +171,7 @@ public class TimestampDatum extends Datum {
   public int compareTo(Datum datum) {
     if (datum.type() == TajoDataTypes.Type.TIMESTAMP) {
       return dateTime.compareTo(((TimestampDatum)datum).dateTime);
-    } else if (datum.isNull()) {
+    } else if (datum instanceof NullDatum || datum.isNull()) {
       return -1;
     } else {
       throw new InvalidOperationException();
@@ -180,6 +180,9 @@ public class TimestampDatum extends Datum {
 
   @Override
   public boolean equals(Object obj) {
+    if (obj instanceof NullDatum) {
+       return false;
+    }
     if (obj instanceof TimestampDatum) {
       TimestampDatum another = (TimestampDatum) obj;
       return dateTime.isEqual(another.dateTime);

http://git-wip-us.apache.org/repos/asf/tajo/blob/5d6d1657/tajo-common/src/test/java/org/apache/tajo/datum/TestDateDatum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/org/apache/tajo/datum/TestDateDatum.java b/tajo-common/src/test/java/org/apache/tajo/datum/TestDateDatum.java
index 8d3b146..dd915f5 100644
--- a/tajo-common/src/test/java/org/apache/tajo/datum/TestDateDatum.java
+++ b/tajo-common/src/test/java/org/apache/tajo/datum/TestDateDatum.java
@@ -108,4 +108,12 @@ public class TestDateDatum {
     assertEquals(4, d.getMonthOfYear());
     assertEquals(1, d.getDayOfMonth());
   }
+
+  @Test
+  public final void testNull() {
+    Datum d = DatumFactory.createDate(DATE);
+    assertEquals(Boolean.FALSE,d.equals(DatumFactory.createNullDatum()));
+    assertEquals(DatumFactory.createNullDatum(),d.equalsTo(DatumFactory.createNullDatum()));
+    assertEquals(-1,d.compareTo(DatumFactory.createNullDatum()));
+  }
 }

http://git-wip-us.apache.org/repos/asf/tajo/blob/5d6d1657/tajo-common/src/test/java/org/apache/tajo/datum/TestTimeDatum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/org/apache/tajo/datum/TestTimeDatum.java b/tajo-common/src/test/java/org/apache/tajo/datum/TestTimeDatum.java
index d2b138e..63f8252 100644
--- a/tajo-common/src/test/java/org/apache/tajo/datum/TestTimeDatum.java
+++ b/tajo-common/src/test/java/org/apache/tajo/datum/TestTimeDatum.java
@@ -121,4 +121,12 @@ public class TestTimeDatum {
     assertEquals(34, copy.getMinuteOfHour());
     assertEquals(56, copy.getSecondOfMinute());
   }
+
+  @Test
+  public final void testNull() {
+    Datum d = DatumFactory.createTime(TIME);
+    assertEquals(Boolean.FALSE,d.equals(DatumFactory.createNullDatum()));
+    assertEquals(DatumFactory.createNullDatum(),d.equalsTo(DatumFactory.createNullDatum()));
+    assertEquals(-1,d.compareTo(DatumFactory.createNullDatum()));
+  }
 }

http://git-wip-us.apache.org/repos/asf/tajo/blob/5d6d1657/tajo-common/src/test/java/org/apache/tajo/datum/TestTimestampDatum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/org/apache/tajo/datum/TestTimestampDatum.java b/tajo-common/src/test/java/org/apache/tajo/datum/TestTimestampDatum.java
index bb06946..246791b 100644
--- a/tajo-common/src/test/java/org/apache/tajo/datum/TestTimestampDatum.java
+++ b/tajo-common/src/test/java/org/apache/tajo/datum/TestTimestampDatum.java
@@ -39,7 +39,7 @@ public class TestTimestampDatum {
 	@Test
 	public final void testType() {
 		Datum d = DatumFactory.createTimeStamp(timestamp);
-    assertEquals(Type.TIMESTAMP, d.type());
+        assertEquals(Type.TIMESTAMP, d.type());
 	}
 
 	@Test(expected = InvalidCastException.class)
@@ -111,4 +111,12 @@ public class TestTimestampDatum {
     assertEquals(50, d.getMinuteOfHour());
     assertEquals(01, d.getSecondOfMinute());
   }
+
+  @Test
+  public final void testNull() {
+   Datum d = DatumFactory.createTimeStamp(timestamp);
+   assertEquals(Boolean.FALSE,d.equals(DatumFactory.createNullDatum()));
+   assertEquals(DatumFactory.createNullDatum(),d.equalsTo(DatumFactory.createNullDatum()));
+   assertEquals(-1,d.compareTo(DatumFactory.createNullDatum()));
+  }
 }


Mime
View raw message