geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jasonhu...@apache.org
Subject incubator-geode git commit: GEODE-224: Spark Connector parser is not processing type casting properly * This issue is related to wrong regex of query string.
Date Tue, 29 Nov 2016 18:24:34 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/develop ea0ef97ae -> 60af9ce78


GEODE-224: Spark Connector parser is not processing type casting properly
* This issue is related to wrong regex of query string.

This closes #300


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/60af9ce7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/60af9ce7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/60af9ce7

Branch: refs/heads/develop
Commit: 60af9ce7856c5c4be13b3c2fa79eb22b10df600d
Parents: ea0ef97
Author: Kai Jiang <jiangkai@gmail.com>
Authored: Tue Nov 29 03:21:00 2016 -0800
Committer: Jason Huynh <huynhja@gmail.com>
Committed: Tue Nov 29 10:24:00 2016 -0800

----------------------------------------------------------------------
 .../geode/spark/connector/internal/oql/QueryParser.scala  |  2 +-
 .../spark/connector/internal/oql/QueryParserTest.scala    | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/60af9ce7/geode-spark-connector/geode-spark-connector/src/main/scala/org/apache/geode/spark/connector/internal/oql/QueryParser.scala
----------------------------------------------------------------------
diff --git a/geode-spark-connector/geode-spark-connector/src/main/scala/org/apache/geode/spark/connector/internal/oql/QueryParser.scala
b/geode-spark-connector/geode-spark-connector/src/main/scala/org/apache/geode/spark/connector/internal/oql/QueryParser.scala
index 7888d13..22bb3ad 100644
--- a/geode-spark-connector/geode-spark-connector/src/main/scala/org/apache/geode/spark/connector/internal/oql/QueryParser.scala
+++ b/geode-spark-connector/geode-spark-connector/src/main/scala/org/apache/geode/spark/connector/internal/oql/QueryParser.scala
@@ -36,7 +36,7 @@ class QueryParser extends RegexParsers {
 
   def PACKAGE: Parser[String] = """[\w.]+""".r
 
-  def projection: Parser[String] = "*" | repsep("""["\w]+[.\w"]*""".r, ",") ^^ {
+  def projection: Parser[String] = "*" | repsep(opt("""\([A-Za-z]+\)""".r) ~> """["\w]+[.\w"]*""".r,
",") ^^ {
     _.toString
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/60af9ce7/geode-spark-connector/geode-spark-connector/src/test/scala/org/apache/geode/spark/connector/internal/oql/QueryParserTest.scala
----------------------------------------------------------------------
diff --git a/geode-spark-connector/geode-spark-connector/src/test/scala/org/apache/geode/spark/connector/internal/oql/QueryParserTest.scala
b/geode-spark-connector/geode-spark-connector/src/test/scala/org/apache/geode/spark/connector/internal/oql/QueryParserTest.scala
index f5c32dc..8d377c4 100644
--- a/geode-spark-connector/geode-spark-connector/src/test/scala/org/apache/geode/spark/connector/internal/oql/QueryParserTest.scala
+++ b/geode-spark-connector/geode-spark-connector/src/test/scala/org/apache/geode/spark/connector/internal/oql/QueryParserTest.scala
@@ -80,4 +80,14 @@ class QueryParserTest extends FunSuite {
     val r = QueryParser.parseOQL("SELECT r.id, r.\"type\", r.positions, r.status FROM /obj_obj_region
r, r.positions.values f WHERE r.status = 'active' and f.secId = 'MSFT'").get
     assert(r == "List(/obj_obj_region, r.positions.values)")
   }
+
+  test("SELECT (Int)r.id, r.\"type\", (Double)r.positions, r.status FROM /obj_obj_region
r, r.positions.values f WHERE r.status = 'active'") {
+    val r = QueryParser.parseOQL("SELECT (Int)r.id, r.\"type\", (Double)r.positions, r.status
FROM /obj_obj_region r, r.positions.values f WHERE r.status = 'active'").get
+    assert(r == "List(/obj_obj_region, r.positions.values)")
+  }
+
+  test("SELECT distinct (Double)f1, (Float)f2 FROM /r1/r2 WHere f = 100") {
+    val r = QueryParser.parseOQL("SELECT distinct (Double)f1, (Float)f2 FROM /r1/r2 WHere
f = 100").get
+    assert(r == "List(/r1/r2)")
+  }
 }


Mime
View raw message