ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [05/16] ignite git commit: IGNITE-3175 BigDecimal fields are not supported if query is executed from IgniteRDD: fix java.sql.Date mapping
Date Mon, 06 Jun 2016 13:06:52 GMT
IGNITE-3175 BigDecimal fields are not supported if query is executed from IgniteRDD: fix java.sql.Date
mapping


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4506c215
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4506c215
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4506c215

Branch: refs/heads/ignite-3258
Commit: 4506c215b43ffb5e6319c318196e713c8c5aefbd
Parents: c10097e
Author: tledkov-gridgain <tledkov@gridgain.com>
Authored: Thu Jun 2 16:56:20 2016 +0300
Committer: Valentin Kulichenko <valentin.lulichenko@gmail.com>
Committed: Fri Jun 3 19:49:59 2016 +0300

----------------------------------------------------------------------
 .../src/main/scala/org/apache/ignite/spark/IgniteRDD.scala  | 3 ++-
 .../ignite/spark/JavaStandaloneIgniteRDDSelfTest.java       | 9 ++++++++-
 .../org/apache/ignite/spark/EntityTestAllTypeFields.scala   | 7 +++++--
 3 files changed, 15 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/4506c215/modules/spark/src/main/scala/org/apache/ignite/spark/IgniteRDD.scala
----------------------------------------------------------------------
diff --git a/modules/spark/src/main/scala/org/apache/ignite/spark/IgniteRDD.scala b/modules/spark/src/main/scala/org/apache/ignite/spark/IgniteRDD.scala
index 9ef9846..fa96212 100644
--- a/modules/spark/src/main/scala/org/apache/ignite/spark/IgniteRDD.scala
+++ b/modules/spark/src/main/scala/org/apache/ignite/spark/IgniteRDD.scala
@@ -315,9 +315,10 @@ class IgniteRDD[K, V] (
         case "java.lang.Long" ⇒ LongType
         case "java.lang.Float" ⇒ FloatType
         case "java.lang.Double" ⇒ DoubleType
-        case "java.math.BigDecimal" ⇒ DecimalType.SYSTEM_DEFAULT
+        case "java.math.BigDecimal" ⇒ DataTypes.createDecimalType()
         case "java.lang.String" ⇒ StringType
         case "java.util.Date" ⇒ DateType
+        case "java.sql.Date" ⇒ DateType
         case "java.sql.Timestamp" ⇒ TimestampType
         case "[B" ⇒ BinaryType
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/4506c215/modules/spark/src/test/java/org/apache/ignite/spark/JavaStandaloneIgniteRDDSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/spark/src/test/java/org/apache/ignite/spark/JavaStandaloneIgniteRDDSelfTest.java
b/modules/spark/src/test/java/org/apache/ignite/spark/JavaStandaloneIgniteRDDSelfTest.java
index e600c6c..343158b 100644
--- a/modules/spark/src/test/java/org/apache/ignite/spark/JavaStandaloneIgniteRDDSelfTest.java
+++ b/modules/spark/src/test/java/org/apache/ignite/spark/JavaStandaloneIgniteRDDSelfTest.java
@@ -39,6 +39,7 @@ import org.apache.spark.sql.DataFrame;
 import org.apache.spark.sql.Row;
 import scala.Tuple2;
 
+import java.io.Serializable;
 import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.util.List;
@@ -279,10 +280,16 @@ public class JavaStandaloneIgniteRDDSelfTest extends GridCommonAbstractTest
{
                     assertTrue(String.format("+++ Fail on %s field", fieldName),
                         ((Comparable<BigDecimal>)val).compareTo((BigDecimal)res) ==
0);
                 }
+                else if (val instanceof java.sql.Date)
+                    assertEquals(String.format("+++ Fail on %s field", fieldName),
+                        val.toString(), df.collect()[0].get(0).toString());
                 else if (val.getClass().isArray())
                     assertTrue(String.format("+++ Fail on %s field", fieldName), 1 <=
df.count());
-                else
+                else {
+                    assertTrue(String.format("+++ Fail on %s field", fieldName), df.collect().length
> 0);
+                    assertTrue(String.format("+++ Fail on %s field", fieldName), df.collect()[0].size()
> 0);
                     assertEquals(String.format("+++ Fail on %s field", fieldName), val, df.collect()[0].get(0));
+                }
 
                 info(String.format("+++ Query on the filed: %s : %s passed", fieldName, f.getType().getSimpleName()));
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/4506c215/modules/spark/src/test/scala/org/apache/ignite/spark/EntityTestAllTypeFields.scala
----------------------------------------------------------------------
diff --git a/modules/spark/src/test/scala/org/apache/ignite/spark/EntityTestAllTypeFields.scala
b/modules/spark/src/test/scala/org/apache/ignite/spark/EntityTestAllTypeFields.scala
index a936091..36d8274 100644
--- a/modules/spark/src/test/scala/org/apache/ignite/spark/EntityTestAllTypeFields.scala
+++ b/modules/spark/src/test/scala/org/apache/ignite/spark/EntityTestAllTypeFields.scala
@@ -35,7 +35,9 @@ class EntityTestAllTypeFields(
     @ScalarCacheQuerySqlField(index = true) val dateVal: Date,
     @ScalarCacheQuerySqlField(index = true) val timestampVal: Timestamp,
     @ScalarCacheQuerySqlField(index = true) val byteArrVal: Array[Byte],
-    @ScalarCacheQuerySqlField(index = true) val bigDecVal: java.math.BigDecimal
+    @ScalarCacheQuerySqlField(index = true) val bigDecVal: java.math.BigDecimal,
+    @ScalarCacheQuerySqlField(index = true) val javaSqlDate: java.sql.Date
+
 ) extends Serializable {
     def this(
         i: Int
@@ -52,6 +54,7 @@ class EntityTestAllTypeFields(
             new Date(i),
             new Timestamp(i),
             Array(i.toByte, i.toByte),
-            new java.math.BigDecimal(i.toString))
+            new java.math.BigDecimal(i.toString),
+            new java.sql.Date(i))
     }
 }


Mime
View raw message