Added a test for IGNITE-3077
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/377c4055 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/377c4055 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/377c4055 Branch: refs/heads/ignite-2788 Commit: 377c405579d9267463561ab5f8b32a2f15112408 Parents: 3624e18 Author: Alexey Goncharuk <[email protected]> Authored: Fri Apr 29 18:14:46 2016 -0700 Committer: shtykh_roman <[email protected]> Committed: Fri May 13 16:11:17 2016 +0900 ---------------------------------------------------------------------- .../org/apache/ignite/spark/IgniteRDDSpec.scala | 40 +++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/377c4055/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRDDSpec.scala ---------------------------------------------------------------------- diff --git a/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRDDSpec.scala b/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRDDSpec.scala index 071897a..a41839d 100644 --- a/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRDDSpec.scala +++ b/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRDDSpec.scala @@ -17,6 +17,8 @@ package org.apache.ignite.spark +import java.time.LocalDate + import org.apache.ignite.Ignition import org.apache.ignite.cache.query.annotations.{QueryTextField, QuerySqlField} import org.apache.ignite.configuration.{CacheConfiguration, IgniteConfiguration} @@ -165,6 +167,33 @@ class IgniteRDDSpec extends FunSpec with Matchers with BeforeAndAfterAll with Be sc.stop() } } + + it("should successfully query complex object fields") { + assert(false, "https://issues.apache.org/jira/browse/IGNITE-3077") + + val sc = new SparkContext("local[*]", "test") + + try { + val ic = new IgniteContext[Integer, WithObjectField](sc, + () â configuration("client", client = true)) + + val cache: IgniteRDD[Integer, WithObjectField] = ic.fromCache(PARTITIONED_CACHE_NAME) + + cache.savePairs(sc.parallelize(0 to 1000, 2).map(i â (i:java.lang.Integer, new WithObjectField(i, new Entity(i, "", i))))) + + val df = cache.sql("select i, ts from WithLocalDate where i = ?", 50) + + df.printSchema() + + val res = df.collect() + + assert(res.length == 1, "Invalid result length") + assert(50 == res(0)(0), "Invalid result") + } + finally { + sc.stop() + } + } } override protected def beforeEach() = { @@ -188,6 +217,12 @@ class IgniteRDDSpec extends FunSpec with Matchers with BeforeAndAfterAll with Be } } +case class WithObjectField( + @(QuerySqlField @field)(index = true) val i : Int, + @(QuerySqlField @field)(index = false) val ts : Object +) { +} + /** * Constants and utility methods. */ @@ -242,7 +277,10 @@ object IgniteRDDSpec { ccfg.setName(PARTITIONED_CACHE_NAME) - ccfg.setIndexedTypes(classOf[String], classOf[Entity]) + ccfg.setIndexedTypes( + classOf[String], classOf[Entity], + classOf[Integer], classOf[WithObjectField] + ) ccfg }
